![]() |
| A Unix box ;-) |
I picked up one of those snazzy (ignoring reports of dodgy firmware bricking players) Creative Zen portable media players lately (more on that elsewhere) so that left the old 512MB iPod Shuffle without function… or so I thought. I’ve been playing around a bit lately with making a portable Cygwin install and the old shuffle might just be an ideal medium for it – a Unix-style shell in your pocket for when you’re given no choice but to use Windows. I’m writing this as I put it together so hopefully there’ll be enough detail in here to take you through from start to finish. Most of the information here was collected from around the web, hassling the folks on #linux and a little experience using Cygwin day to day – there’s nothing new here but I don’t think the info’s ever been gathered in one place before.
![]() |
| Windows CMD shell – click for larger version |
Right, first things first, delete everything on your iPod (OK, you don’t need to do this but you’ll need about 70MB for a base install – I recommend at least 512MB. Remember, your home directory will be on the portable disk too and you’ll probably want to install more tools as you use Cygwin more, eg; ssh with rxvt is a nice alternative to PuTTY.)
Start by downloading the Cygwin installer (usually found here) to your portable disk. We’ll be able to use this to update Cygwin from any machine later on. For now we’ll use it to install the base system. Launch the installer (Note: You’ll need internet access for this part). Click next to move on from the about screen and select the following options on the next screens:
For “Choose A Download Source” select “Install From Internet” -> Next
For “Root Directory” enter “E:\cygwin” where E: is the drive letter your portable disk is mounted on. Select “Just Me” and “Unix / binary” (Unix format text files are better for configs – some apps might have issues with DOS format configs) -> Next
For “Local Package Directory” you might like to choose a directory on the portable disk – this is useful if you have no write access to other disks on the machine but uses a lot of space so is not ideal for a small disk. I chose to cache packages in “C:\pkg” but where they go isn’t that important. -> Next
For “Select Your Internet Connection” it might be best to select “Use IE5 Settings” if you’re unsure about your network parameters. If you know better, configure appropriately… -> Next
For “Available Download Sites” try to select a mirror geographically close to you. For Ireland that means something on esat.net or heanet.ie. Again, if you’re unsure of your network settings it’s probably safer to choose a http source rather than ftp. -> Next
For “Select Packages” the base install is already selected so just click Next here. Nothing to do now but wait for the install to complete.
When it’s done it’s probably best not to create icons on the start menu or desktop… -> Finish.
We now have a base Cygwin install. Time to make it portable. Create a plain text file named “cygwin.bat” in the root directory of your portable disk and insert the following into the file (notepad will do):
for /F %%A in ('cd') do set WD=%%A
set path=%WD%cygwin\bin;%WD%cygwin\usr\X11R6\bin;%path%
set SHELL=/bin/bash
set CYGWIN=codepage:437
set HOME=/home/fuzzix
cygwin\bin\mount -bfu %WD%cygwin/ /
cygwin\bin\mount -bfu %WD%cygwin\bin /usr/bin
cygwin\bin\mount -bfu %WD%cygwin\lib /usr/lib
cygwin\bin\bash --login -i
The first line in the file establishes the working directory so we can deal with whatever drive letter Windows assigns your portable disk. Then we set the path and some other environment variables, create a few mount points and finally run the shell. You should set “HOME” to whatever directory inside your Cygwin install you want to use as a home directory. You might notice some X11 elements in the path – we’ll talk about that a little later…
![]() |
| rxvt shell – click for larger version |
By default Cygwin uses Windows’ own Command Prompt window. This has several shortcomings including lack of a full screen mode and limited character/ANSI support. There’s an alternative available in the form of rxvt. Cygwin provides a Win32 native build of this which is a breeze to set up. To begin run setup.exe again…
The installer should remember your selections from last time you ran it so you can proceed straight to the “Select Packages” screen. Click the “View” button once to get a full package view. Scroll down to rxvt in the Package column (it might be best to maximise the window for this). A few columns to the left of Package you should see the word “Skip”. Click this once to install the latest available version (“Skip” should change to something like “20050409-7″). Click “Next” to install rxvt. I wish the Cygwin installer would remember that I don’t want to create desktop/start menu icons but it doesn’t…
Before I paste the rxvt batch file I’ll explain a little something about its character support… it’s limited. Some apps (such as the Midnight Commander file manager) relying on “box drawing” characters . There’s a font called Lucida ConsoleP which, when installed on the host machine, can help mitigate this. The problem is, no way exists (that I know of – I’d love to hear different) to install a font from a batch file without requiring a reboot. Dragging the ttf file into the Windows fonts directory works… Following is the rxvt batch file (perhaps call this “cygwin_rxvt.bat” if you want to compare its function with the cmd version). It’s much the same as the previous one:
for /F %%A in ('cd') do set WD=%%A
set path=%WD%cygwin\bin;%WD%cygwin\usr\X11R6\bin;%path%
set SHELL=/bin/bash
set DISPLAY=:0
set HOME=/home/fuzzix
cygwin\bin\mount -bfu %WD%cygwin/ /
cygwin\bin\mount -bfu %WD%cygwin\bin /usr/bin
cygwin\bin\mount -bfu %WD%cygwin\lib /usr/lib
run rxvt -sl 1500 -bg black -fg gray -sr -fn 'Lucida ConsoleP-13' -tn rxvt-cygwin-native -e bash --login -i
This gives us a nice rxvt terminal with black background, grey foreground, scrollbar positioned on the right and 1500 lines of scrollback (I’m wacky for scrollback). If you can’t/don’t want to install the Lucida ConsoleP font change the last line to:
run rxvt -sl 1500 -bg black -fg gray -sr -tn rxvt-cygwin-native -e bash --login -i
![]() |
| mrxvt shell – click for larger version |
rxvt isn’t the only option. Cygwin comes with its own X server which we can install by running setup, navigating to the “Select Packages” screen and Selecting X11 -> xorg-x11-base and xorg-x11-devel in much the same matter we used to install rxvt. Note: Installing X can take some time. For this step we’ll also need to install a compiler and build tools. You’ll need Devel -> gcc and make. We can use these packages to download and build the X terminal of our choice. In this example I’ll be installing mrxvt, essentially a tabbed version of rxvt (and my terminal of choice).
Download the mrxvt source tarball (tar.gz file) from the homepage to your Cygwin home directory and in your shell enter the following:
$ tar xzf mrxvt-0.4.2.tar.gz
$ cd mrxvt-0.4.2
$ ./configure --prefix=/usr && make && make install
…now create another familiar looking batch file (cygwin_mrxvt.bat?):
for /F %%A in ('cd') do set WD=%%A
set path=%WD%cygwin\bin;%WD%cygwin\usr\X11R6\bin;%path%
set SHELL=/bin/bash
set DISPLAY=127.0.0.1:0.0
set HOME=/home/fuzzix
cygwin\bin\mount -bfu %WD%cygwin/ /
cygwin\bin\mount -bfu %WD%cygwin\bin /usr/bin
cygwin\bin\mount -bfu %WD%cygwin\lib /usr/lib
run XWin -silent-dup-error -multiwindow -clipboard -xkblayout gb -xkbmodel pc105
run mrxvt -at -sl 1500 -bg black -fg gray -sr -tn rxvt -e /bin/bash --login -i
Note that mrxvt does not run natively in Windows but in Cygwin’s X server. This is essentially an entire separate window manger from the Windows Explorer with its own environment so you’ll need to pass parameters for keyboard layout etc. (-xkblayout gb is provided as an example). XWin’s -silent-dup-error parameter is supposed to (as I understand it) make XWin silently exit if another instance of X is running but this is not the case in my experience. I’d be keen to hear a solution for this.
Hopefully by now you’ll have a USB disk of some sort containing three easily launched Unix-like terminals for your comfort. You could create an autorun.inf which will launch your favourite terminal as you plug in your disk or you could add another few useful apps… My install at this stage weighs in at about 240MB – room for improvement!
![]() |
| A few essentials… |
portableapps.com contains USB storage oriented versions of popular Free applications. While the likes of Firefox and PuTTY are most useful on a USB disk the PortableApps launcher is a little heavy. An alternative is Pegtop Pstart, a launcher which can exist as a tray icon. Portable installation should be obvious – remember to add an autorun file from the Setup menu. Now it’s simply a matter of dragging your Cygwin launchers (and anything else you installed) onto the Pstart window. It’s worth noting that the Cygwin setup.exe binary should work in your portable setup once you’ve run a shell and set up the environment – you may need to change drive letters depending on where the host mounts your disk but it should be simple enough to add/update things in the Cygwin environment.
![]() |
During my endeavours to put together a comfortable environment on machines I’m not comfortable with I encountered a few brain farts… occasionally confused about whether I should be thinking in Windows or GNU/Linux or MagicalDoWhatIMeanOS… Here’s a good example:
10:23 < fuzzix> I'm trying to set up a cygwin install here. Anyone ever encounter ssh and some other apps ignoring http_proxy?
10:28 < elrond> fuzzix: WTF would ssh be doing even looking at http_proxy ?
10:28 < fuzzix> elrond: That is a fair point.
I blame lack of sleep. Anyway, in a fit of bloody mindedness I knocked together the ssh invocation which reads http_proxy…
ssh -p 443 user@host -o ProxyCommand="corkscrew `echo $http_proxy | sed -e 's/http:\/\///' -e 's/:.*//'` `echo $http_proxy | sed -e 's/.*://g' -e 's/\///'` %h %p"
…assuming your sshd is accessible on port 443 (which makes access through proxies trivial – the proxy considers it https traffic).





