This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to make your own portable Cygwin on CD

This topic has received some attention on this list since about May. I think
the following procedure works well (it does for me, and the finished CD has
worked faultlessly on a selection of other Windows machines). I got through
half a box of CD blanks to get where I wanted, and a lot depends on the
degree of personalisation that a user will require. But if you felt like
trying this out and offering any enhancements or improvements to the
instruction sequence, that would be really nice. Thank you. Enjoy, I hope.


Step 0

If you already have Cygwin installed on your machine, climb into it and then

        mount -m > /bin/remount.txt
        umount -A

and exit. Then, from Windows, rename your Cygwin directory to something
else: for the avoidance of doubt, why not use the name CygOld. This
installation will be recovered as the final step in this instruction list

Step 1

Make a fresh up-to-date Cygwin installation by changing from "All Default"
to "All Install" in Setup and then de-selecting entirely the groups
Publishing and XFree86 (and Games, maybe) by again choosing "Default" for
these three (the default being, not to install them). Clicking the "View"
button once to move on to the detailed view of what is to be installed,
additionally de-select the associated files lily*, tetex* and texmf*,
residing in Dev, Doc, Text, etc. Do not select any source files.

This set of choices will lead to an almost complete provision that will also
fit on a CD. (You might prefer a different compromise but this works well.)

Step 2

Having installed this "almost-maximal" version, start a Cygwin session. The
supplied Desktop shortcut provides exactly what is needed to do this, but if
you did not say Yes to that shortcut when you were offered it, the required
command is

        Start -> Run -> \Cygwin\bin\bash --login -i

N.B. From now on, everything that follows, up to the Exit at Step 6, is run
in this single Cygwin session.

Step 3

Depending on the Windows machine at which you are now seated, your HOME will
be /home/admin or /home/Guest or something similar. In this architecture,
you should be aware that HOME will be set to /home/user/, a convenient
default. Prepare for that change now, by making a new directory /home/user/
and moving there, deleting the existing /home/admin/ (or whatever). It does
not matter that you will lose the file /home/admin/.bash_profile.

Copy, or create, any extra material you require under /home/ and under
/usr/local/. (So, copy anything that you are used to having available in
~/bin/, for instance; or if you normally have a directory called ~/tmp/,
create that too. (Remember, once burned, your CD is immutable. However, CD
blanks are cheap: it is unlikely that you will have things entirely as you
want them at your first attempt, and you might find that you are only happy
with your 3rd or 4th. Coping with anything normally to be found in your
startup files ~/.bash_profile or ~/.bashrc is the subject of Step 4.

Don't forget to create some convenient links to other drives than your CD
drive, if you want them, as in

        ln -s /cygdrive/a /a
        ln -s /cygdrive/c /c
        ln -s /cygdrive/d /d

Step 3a

At this point I re-named all of /etc/profile, /etc/group and /etc/passwd to
*.0 to conceal them from what is intended to be a maximally portable system,
and thereby remove some opportunities for confusion. It is not clear to me
that this step is actually necessary, and you will end up on most machines
named "unknown" and belonging to group "mkpasswd". If there's a convenient
approach that leads to a neater (more elegant) id that can be maintained
across all systems, it would be nice to know it.

Step 4

This is the only slightly difficult step: it consists of tweaking existing
files or making new ones, all to render the CD version usable.

There are five files attached to this instruction document.

One attachment is a script to help you make the CD version: it is called It should be copied to your home directory ~.

Two of the attachments are to be located in /. They are cygmin.bat and
cygmin.ini. The batch file cygmin.bat is the only one of the five
attachments that should be DOS terminated <CR><LF>: all others are
Unix-terminated <LF>. It would be a good idea to check this after the files'
correct placement.

The file cygwin.bat is sent as to get through gateways.

The 4th attachment is an example file, providing the basis for a
CD-bound ~/.bashrc. You may not require or even desire some of the entries:
you may want others. These vital details are attended to next. For the
moment place the file in your home directory ~ and re-name it  .bashrc).

Finally: the default startup mode is barest bash, defined in cygmin.bat. The
5th attached file called provides an example of an enhanced
environment which you might prefer (possibly after editing some of the
detail of it).

Now we will look at three of the files in more detail.


This file does not need altering (though after some usage you might decide
to change it: in particular, you might wish to incorporate the terminal
window rxvt into your default startup). However, notice that it seeks and,
if necessary, creates, a directory on your C: drive called c:\tmp\. (Most
people's day-to-day usage will probably involve a requirement for some such
scratch area. If you don't like the name, or know your requirement to be a
different location, then change it, but note the requirement for a matching
change to the file /cygwin.ini.)


This sets export'd variables once and for all. They are the usual suspects,
SHELL, HOME, PATH and PS1. You will find that one or both of TEMP and TMP
are inherited from your Windows environment. Earlier testing of a CD version
was frustrated by one application's insistence on writing to a specifically
named temporary directory called TMPDIR, and so that is defined
appropriately here. You may well find other similar requirements and
barriers to convenient usage emerging, in which case you can make the
appropriate adjustments to this file and burn another CD.


The provided example sets preferred aliases (if any) and with the final
command (cd) sees to the user's starting location. As you can see from
scrutinising the contents of /cygmin.ini, this is called anyway by the
starting procedure. However, this re-statement is necessary if during a
single session you decide to initiate new processes.

Having re-located and re-named this file as ~/.bashrc, edit it to suit
yourself, possibly with reference to your "own" startup files residing in
the directory currently known as c:\CygOld.

Notice two important lines: (1) history-writing is turned off to forestall
attempts to write to the CD. Also (you might not need this) you can see from
its alias that vim is directed to a specific vimrc file rather than a
default ~/.vimrc, and this turns off ~/viminfo, another file that would by
default be written to disk during vim usage. (The designated vimrc should
contain the additional line set vi=<space> to achieve this.)

Note: you will almost certainly discover additional tweaks and commands that
you will wish to add to your ~/.bashrc, specific to CD usage. These
discoveries will almost certainly not all be obvious to you now.

That's it. If you have other standard easements with which you are familiar,
don't forget to make these too.

Step 5

This step is designed to cope with the later transfer of symlinks to the CD.
Its point is to identify these links on the HD whether they have been
created as Windows System files or Windows Read-only *.lnk files, and to
re-create them all as Read-only *.lnk files. The reason for this is that
files on the CD will necessarily be marked +R, and the +S attribute does not
migrate properly to CDs.

(You will probably have as many as about 3000 such links, so this step takes

>From your home directory ~, run the script as


[This procedure is achieved step by step through the creation of temporary
files and can certainly be shortened. An earlier version reduced the whole
thing to one piped instruction, but I found that that the -sf switch for ln
(replacing the sequence rm then ln -s) did not work as I wanted (or as I

Step 6

You are about to exit this "temporary" Cygwin system. Because of the minor
tweaks to files that were made in Step 4, it is not quite ideal as your
standard HD provision, and should be un-mounted in the interests of

(Anyway, the type of user who has successfully come this far will typically
already possess a HD-based Cygwin system that they will not normally wish to
replace with this one.)

>From ~, run

        /bin/umount -A

and, finally


Step 7

As a final step before copying to CD and, absolutely essential, recovering
your previous and "real" Cygwin installation, it will be nice to clear up
any straggling unwanted files from Windows. (You should not want or need
c:\Cygwin\cygwin.bat, which will have survived. Delete any .bash_history
files, c:\Cygwin\home\user\, and any other temporary files you
can see but don't want.). Then

        rename \Cygwin to \CygNew;

        rename \CygOld to \Cygwin

Step 8

Recover your pre-existing installation with


to obtain a bash window. You might get a "warning: could not find /tmp"
error message, but this does not matter. From here


to check your location (it should be /cygdrive/c/Cygwin/bin/) and then

        bash ./remount.txt

Step 9

Burn your CD: that is, copy across everything in \CygNew (not \CygNew
itself) to the root of the CD.

Step 10

And start your CD in any Windows machine, containing a pre-existing Cygwin
installation or not, with the command


where h: is the local CD driveletter. (Notice: no trailing slashes. This too
it would be nice to tidy, but CD driveletters vary across machines, and I do
not know any better startup command.)

Description: Binary data

Description: Binary data

Attachment: cygmin.ini
Description: Binary data

Description: Binary data

Description: Binary data

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]