Instructions to install Ubuntu on USB key

You can install Ubuntu on a USB key, this will allow you to boot from this USB key without installing your laptop/computer with Ubuntu. It is a full install and not a live USB key so you can create files/directories etc that will be permanent.

Prepare for 80+ minutes of install time. It make take even longer on slow machines.

The install will be done using qemu and kqemu kernel mode accelerator.

Install Qemu

$ sudo apt-get install qemu

kvm & kvm-intel/kvm-amd modules

On my HP bios virtualization was disabled, boot into your bios and enable virtualization. Then load the kvm-intel/kvm-amd and kvm modules.

$ sudo modprobe kvm kvm-intel

Install kqemu kernel mode accelerator

You will need to install kqemu or your install will be slow and die of old age before install is complete!

Edit your /etc/apt/sources.list file and add universe to your repositories so that you can install the kqemu. Next install kqemu:

$ sudo apt-get install kqemu-source kqemu-common

This will install the correct version of the kqemu accelerator and automatically build the kernel module using DKMS.

Install as follows:

sudo modprobe kqemu

And add yourself to the kqemu group to allow you access to the /dev/kqmeu device. To do this, sudo edit the /etc/group file and append your user name to the kqemu entry; for example, user joeuser would look something like:


You need to logout and log back in for this to take effect. Alternatively change the ownership permissions to /dev/kqemu (this is a dirty hack and should be avoided):

sudo chown joeuser:joeuser /dev/kqemu

If you don't get any of these steps correct then QEMU will no use the accelerator and will run very slow. You will also see the following warning message from QEMU:

Could not open '/dev/kqemu' - QEMU acceleration layer not activated: Permission denied

Create a clean image file to install to (3.5GB recommended)

Create a 3.5GB image file to which you can install Ubuntu on, I suggest 3.5 so that it will nicely fit on 4GB or 8GB USB keys, if you create a 4GB image it might not fit well in 4GB USB keys, as some 4GB USB keys are actually less than 4GB in size.

$ dd if=/dev/zero of=karmic.img bs=1M count=3584

Download the ISO image

Download the i386 ISO image that you wish to install from

Install ISO on the img image

You will use the following qemu command to install the ISO on the image file that you created.

$ qemu -cdrom karmic-i386.iso -hda karmic.img -m 1024 -vga cirrus -no-hpet -no-acpi

You could use -vga std, but might get errors in the qemu install window saying could not start X. the -m options says use 1G ram, no point in using a higher value as it does not make it much faster. Don't use a -m size greater than your host free memory size otherwise your host will swap quite severely and installation will take hours.

Usual Install process

Install Ubuntu as you would on any HDD, clicking on the qemu window grabs the mouse, and CNTRL+ALT releases mouse focus from the qemu window. I use the following settings:

  • I select Auto login
  • username: ubuntu password: ubuntu (just my preference)

Once the install is complete

Once the install is complete it, click on reboot, and let the it reboot from the installed image, hit enter when it prompts you to remove the CDROM. When it starts to reboot, it may run fsck and fix errors etc and reboot again, be patient. Once it reboots, you can click on System->Shutdown, that will shutdown gracefully and close the qemu window. And that is it!

dd to USB key

In karmic the usb-creator will write .img files to USB key, you could also use dd to write the USB key.

In case you use dd over usb-creator, after you insert your USB key, figure out where it is mounted /dev/sdXX, (in my case it is /dev/sdb1) right click on it and say unmount *NOT* eject then do:

$ sudo dd if=karmic.img of=/dev/sdb bs=1M
$ sync; sleep 1; sync; sync; sync; sync

KernelTeam/InstallonUSBkey (last edited 2010-07-20 09:29:02 by 193)