Cygwin on portable storage devices
Ali Devin Sezer, 5 Feb 2005
Cygwin is a software package that
enables one to work in a UNIX-like environment
under a Windows machine. It is fast, reliable and easy
to install. It has most of the applications
one uses on UNIX (gcc, X, xfig, latex, Perl, bash, ps
tools, textutils,...) and most of it is covered by the GNU
public license. Cygwin supports many flavors of Windows:XP, 2000,
98, etc. For more info on cygwin go to
The goal of this page is to describe a way of
installing cygwin on a portable storage device like a portable hard drive
or a USB memory stick. The main use of such a setup, obviously, is that
it enables you to carry a UNIX like system in your pocket everywhere
you go and use any Windows machine (e.g. Windows pc's at your
university library) with your own powerful cygwin/UNIX tools.
Choice of Portable device
The choice of device doesn't really change the installation process.
However here are some notes on this issue:
The rest of this note is independent of the choice of portable storage device.
- USB memory stick:
A core cygwin installation doesn't need more than a
couple of hundred MBs. Thus a 1 GB USB memory stick easily gives
you the capacity you need to install cygwin. But, remember that
USB memory sticks are slow
(bearable with NTFS crawling with FAT32)
if you install a big file system
- CDROM's. Because CDROMs are read-only, they are
a poor choice of media to install cygwin.
See the following posts at cygwin.com:
- Portable Hard drives : Portable Hard drives are great.
If you are getting one, make sure you get one that receives power through the
USB cable and from the computer.
Choice of Filesystem
You have two realistic choices for a file system (FS) on your portable storage
device:fat32 and ntfs. (For those who are not familiar with
FSs: FS is what is installed on a storage device when you format
it. The formatting software asks you which kind of FS you want).
Although NTFS is a much better FS, I had read/write permission problems
with it when using different computers on which i had different accounts.
A simplistic solution to this problem is to use fat32.
That's what I do.
I assume that your portable storage device is already formatted.
Here are the steps:
This is it. double clicking
"X.bat" will make cygwin operational and start an X server as well as an
rxvt. When you exit all cygwin software, double click "uninstall.bat".
- Go to cygwin.com and
install cygwin on your portable storage device.
Let's designate your
portable storage device with "E:\" and assume that you installed cygwin in
As is, this installation will work only when your portable storage device
is connected to the computer on which you performed the installation. What
what you need to do so that your cygwin can work with any host
- Unless it is not there, create the directory "E:\cygwin\home". Then
create the directory "E:\cygwin\home\username", where
username is a user name that you pick. (e.g. your name).
This will be your home directory:
whenever you start an rxvt or an xterm it will start with this directory
as the current directory.
- Copy profile to E:\cygwin\etc. Open it
with an editor (e.g. notepad) and replace the phrase "username" (it
occurs twice) with the user name you have chosen above.
The scripts ``X.bat'' and ``uninstall.bat'' modify host's registry. They insert several keys in the CURRENT USER
and LOCAL MACHINE
sections of the registry. These keys are modified through the ``mount'' command of cygwin and are
referred to by cygwin to find out which directories on the Windows directory structure are going to be
mapped to /bin, /lib and /. If cygwin is already installed on the host, "X.bat"
will save these entries before changing them. The modified entries are
later restored when you are done using your portable cygwin and run
the "uninstall.bat" script.
X.tab and put it in "E:\". Rename it "X.bat" [*].
assumes that you installed cygwin under "E:\cygwin" on
your storage device. If you installed it in some other directory
you will need to modify this script to reflect that (
X.bat figures out the drive label of the portable device [assumed
to be E in this discussion] on its own. So you have to change X.bat only
if cygwin is installed in some directory other than "cygwin" in the
root directory of your portable storage device).
X.bat inserts several keys into the windows
registry. This is required for cygwin to work. It also saves any key
values that it might alter.
Finally it starts a copy of the X server and a terminal
(assuming that X and rxvt were installed in step 1).
- Download uninstall.tab and put it in "E:\".
Rename it to "uninstall.bat" [*]. Run this script once you are done
using cygwin and quit all cygwin software. It restores any registry
keys that might have been altered when running "X.bat".
If you are using a very old windows, replace
for /f %%A in ('cd') do set WD=%%A
in "X.bat" with
and start "X.bat" from "Run" in the Start menu by typing
"X.bat [DRIVE]:\" in the Run box,
where [DRIVE] is the letter that Windows assigned to your portable storage
device (`E' in the above examples).
This script is based on a script by Fergus in the CD-ROM
related postings at cygwin.com (see the links above).
Back to Devin Sezer's home