Setting up Ubuntu 10.10 on an USB Pendrive – persistent

This is a short description of how i setup a 16Gb USB pendrive to run Ubuntu 10.10 as a solidstate (ish) drive.

Step1:

Get your hands on a virtualization software, VMWare player, Virtualbox, whatever thats free.

Step2:

Install Ubuntu 10.10 onto a virtual drive that has similar capacity as your USB pendrive, my was 16gb, so i setup a 10gb expansive partion.

Step3:

Complete the Ubuntu installation, pull all the necessary driver for 3D accleration, pull all the updates, setup whatever you would like the installation to run, in my case XBMC with a default standalone session.

Step4:

Fire up the terminal.. Sudo into the bash, by typing “sudo bash”.. congrats you are persistent root user.

Step5:

Edit /etc/fstab so that the root drive (prob, something like UUID={YADAYADA} mounts at … well anyway where it saids error=something, add “,noatime”.
also add a ramdrive for tmp files. byadding this line to the fstab.

tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0

Edit your /etc/rc.local and add this before exit 0

echo deadline > /sys/block/sda/queue/scheduler
echo deadline > /sys/block/sdb/queue/scheduler
echo deadline > /sys/block/sdc/queue/scheduler
echo 1 > /sys/block/sda/queue/iosched/fifo_batch
echo 1 > /sys/block/sdb/queue/iosched/fifo_batch
echo 1 > /sys/block/sdc/queue/iosched/fifo_batch

That should cover all the usual scsi devices the usb pendrive shows up as (usual sdb).

Step6:

Happy? Logout, shutdown your vmware/whatever player and go the VM machine directory and copy you virtual drive.
Mount it to your virtualization software as a “second” hardrive. And start the virtualzation up again. If you are using vmware it will now groan something about the drives has the same UUID, ignore this…

Step7:

Back in ubuntu, fire up the terminal, sudo bash again, and type mount.. take note of what drive is mounted to / (root). In my case it was /dev/sdb.
This means that your copy has taken over the system and /dev/sda is just floating around there.
Goodie! Connect your usb pendrive to your virtualization software, and attach it and wait for ubuntu to se it show up on your desktop.

Step8:

Unmount  the pendrive by typing umount /dev/sdc (orwhat ever device it was). DONT disconnect it from the virtual computer….

Step9:

In your terminal type “dd if=/dev/sda of=/dev/sdc bs=1440” and sitback and wait, THIS will take a while.. depending on how big your original installation on sda was it will copy it bit by bit to your usb pendrive.
Make sure you send it to the correct device… in my case the usb device connected as scsi device c.. (/dev/sdc)..
I went with a blank fat32 formatted drive.. i belive this will not matter cause dd will write over all partions and such. And include the boot sectors onto the usb drive…

Now after about 30minutes (again my case) it should have said something 5000bytes in 5000 bytes out.. bla bla.. goodie your done.. disconnect the usb thumbdrive from virtualization software.. Turn the virtualization off. And reboot your computer.. hit whatever button you need to boot from USB Harddrive/Device and watch linux boot up. If you didnt install all drivers and crap earlier do that now, i managed to get nvidia up and running.

This is not an optimal way of running linux, due to the fact the usb drives are damn fuckin slow. But it’s a solution when you want a persistent linux system on a pendrive.. And not one of those retarded live cd’s…