Wednesday, December 30, 2009

U3 Howto #1

So here's how you do it: 

First, I run linux.  These commands are all available under Windows, but I don't care.  If you are looking for a Windows how-to, go here first: WUBI

Now once you have a nice sane Ubuntu install here's how you do it:

Supplies:
1 U3 crapware thumb drive (preferably with nothing important on it)
1 bootable iso (Anything will do, but if you want to point and click, HERE YOU GO.)
1 copy of u3-tool  (It builds just fine on Ubuntu 9.10.  Follow the directions.  I'll probably throw it in my PPA for people who are lazy.)

Syntax:
>> A command you can copy and paste
[something you need to fill in for yourself]

Howto:
Insert your thumb drive.

Keep things clean:
>>mkdir customu3
>>cd customu3
Figure out what drive letter it was:
>> sudo fdisk -l
 ...
    Device Boot      Start         End      Blocks   Id  System
/dev/md0p1               1   122095984   488383934   83  Linux

Disk /dev/sdd: 7605 MB, 7605321216 bytes
255 heads, 63 sectors/track, 924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         976     7839698    b  W95 FAT32
If you just plugged it in, chances are it's the last thing in the list.  Also, quickly verify that the size is about right.  My drive is an 8GB drive do 7605MB is about right.  If you have trouble remembering /dev/sdd1, write it down, but beware that it may change in subsequent steps.

If you want the small iso I recommended above (for a first try) you can run this:
>> wget -c http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.7.iso
or
>>cp [../myiso.iso] .
Next, find out how big the iso is:

>> ls -l *.iso
-rw-r--r-- 1 myuser myuser 10614784 2009-12-30 22:09 tinycore_2.7.iso
The tinycore 2.7 iso is 10614784 bytes.  I typically add 1000 bytes just to be on the safe side.


Next, make room for the custom iso image:

>>sudo [path to]/u3-tool -p  10615784 /dev/[sdd1]
Ubuntu will remount things for you.  Make sure the drive location didn't change.  Notice that my thumb drive changed size slightly.  Yours should have too or else something didn't work.
>>sudo fdisk -l
...
Disk /dev/sdd: 8055 MB, 8055029248 bytes

255 heads, 63 sectors/track, 979 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         976     7839698    b  W95 FAT32
Now write the new image and you're done.
>> sudo [path to]/u3-tool -l tinycore_2.7.iso /dev/[sdd1]
That's it.  You should have a new virtual cdrom:
>> ls -l /dev/scd*
lrwxrwxrwx 1 root root 3 2009-12-27 15:04 /dev/scd0 -> sr0
lrwxrwxrwx 1 root root 3 2009-12-30 22:16 /dev/scd1 -> sr1
I like to then check that it worked right using a virtual machine.  It's faster than rebooting.  If this works, you have a bootable, virtual CDROM running from your thumb drive.  Congratulations!
>>kvm -cdrom /dev/scd1