A portable virtual Windows via Linux on a bootable USB drive

23 April 2011

I am traveling a lot and in my case this means with a small backpack on public transport through
third world countries. I do not take a phone or a computer, but occasionally I need to do some IT work.
For this I need a a full development environment with Visual Studio, IIS and SQL Server.

So rather than carrying my own computer, I am using public ones in hotels, hostels or Internet cafes.

On previous trips, most public PCs I encountered were Windows XP and the default user had
administrative rights. Now with the appearance of Vista and Windows 7 with UAC, it will be more likely
that I'm no longer an administrator.

My setup this time is to use a hard drive with a virtual machine created in Virtual Box.
When I find a Windows machine where I can be an administrator, all I need to do is start TrueCrypt
to mount an encrypted volume and then Virtual Box to start the virtual machine.

If I can not get admin access to the machine, but it possible to boot from USB, I can use a portable Linux.
I can use TrueCrypt to mount my same encrypted volume and Virtual Box for Linux to run the same
virtual machine.

For the hardware I choose the SAMSUNG S1 Mini, a 120Gb 1.8" hard drive, they are smaller and lighter
than 2.5" drives but bigger and faster than normal USB memory sticks. I bought two, so I always
have two copies of everything. I keep them in different parts of my luggage too.
Even better would be a USB3 SSD drive, but they are pretty expensive and not many public computers
have USB 3.0 yet.

On the drive I created a FAT32 partition for Linux, I choose 5Gb, but it can be less, even 1GB should be enough.
I created a second partition (NTFS) for the windows tools and the data, it takes the remaining 105 Gb.

In Virtual Box on my Windows machine, I created a new virtual machine to develop on.
I choose a Windows Server 2003, because it needs less resources than Windows 7 or Server 2008.
I used three different virtual hard drives, one for the OS, one for my data and
one for temp stuff. This way I can back up the data drive without having to back up the big system drive all the time. I installed all the usual goodies: VS2010, IIS, SQL-Server, subversion etc.

I created a 50 GB encrypted volume with TrueCrypt to put the virtual hard drive files onto it.

Along with other portable tools, I copied the TrueCrypt executables and Portable Virtual Box for Windows onto the second partition of the S1 drive.

Both TrueCrypt and VirtualBox need admin rights to run, but if I have them, it is pretty quick to
mount the volume and start up my virtual machine.

Setting up the portable Linux:

Download an Ubuntu ISO, other distributions should work as well.

Install Ubuntu using Linux Live USB Creator, make sure to set some space
for Persistence. This feature allows us to store settings and data on the otherwise read-only live-CD.

Install Virtual Box for Linux
Install TrueCrypt for Linux

After booting the Linux you always end up with a user with root access without even logging in.

You may considering changing this by creating a new user and disable the auto login. However I ran into problems doing this and as I don't plan to keep any data on this Linux system, and my VM is secured by TrueCrypt, I may just leave the default auto login enabled.

I added TrueCrypt to the Startup Programs to launch it automatically after boot.
(it is in /usr/bin/) You can also add the data volume to your favorites to get to it quicker.

Before you create a new VM in VirtualBox on Linux, open the preferences dialog and change
the 'Default Machine Folder' to a location on the TrueCrypt volume, otherwise the saved state
of your machine is saved unencrypted on the drive.

Then I created a new machine and attached the existing three hard drives to it.

Saved state: It would be great if you could save the machine state in Linux and then use that under
a Windows hosts, but it turns out that does not work. Even loading the state saved on
a different physical machine may not work.

I have two different VM definitions, one for Linux and one for Windows, but I do share the
three hard drive files. If I have saved the state of a machine on a Linux host, but then move on
and start it up on a Windows host I get the same saved files from the hard drives. I have to test
this more to see how well this works.

What if the machine does not boot from a USB device. Is there a way to have a bootable CD with a bootloader
to tell this machine to load an OS from a USB drive? It turns out there is. There are some instructions on how to create such a CD at pendrivelinux.com.


Pages in this section


ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows