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

Thursday, December 24, 2009

I used to hate U3...

U3 is that annoying software that comes pre-installed on your Sandisk thumb drives.  It mounts a virtual CD on your PC when you plug it in and auto-runs a piece of crappy software when all you want is to drag and drop files onto your thumb drive.  I hate that.

But wait - I USED to hate U3. U3 was a closed, windows-only, back-door, auto-run, BS that Sandisk forced me to borrow a Microsoft PC to rip out of my thumb-drive...

I was so wrong. 

I discovered I could hack it. And that CD partition on the U3 drive... looks like a real CD to the computer... and it's bootable! The CD acts like a separate device on an USB hub!

I now have a bootable, 8GB Sandisk Cruzer thumbdrive with all the useful boot CD's I use - all selectable from a little menu. I haven't perfected it yet, but I have half a dozen of them already on there. I want to work on it some more and then post it so all zero of you can easily do this too. :-p

For now, here are some links to the bits and pieces I used (both are cross platform Windows-Linux-Mac-whatever that has mkisofs):
u3-tool - Allows customization of the u3 partition.
UBCD - Has a bunch of boot images pre-installed and easy directions for customizing.


So far, I left all the stuff that came on the UBCD with a few tweaks:
  • I upgraded to the latest memtest86+, and DBAN.
  • I added SpinRite. (The only piece of software I've bought in a decade.)
  • I added the following Live CD's:
  1. TinyCore v2.7 - 10MB, runs almost everything useful, boots into ram 5-10 seconds. Enough said.
  2. Puppy Linux v4.3.1 - A little bigger, also runs in RAM, less customization needed.
  3. Slax 6.3.1 - Most polished Live CD I ever used. Only 200 MB base image. Online customization. Check it out.
  4. BackTrack 4 - 1.3GB of evil hacker tools
    "computer security tools". Mwahahaha.

Really this was mostly a no-brainer with just the two links above. I had to do some hacking editing of the isolinux configs (which requires a bit more than monkey skills) to get things just right, but it was really pretty easy.

The coolest thing is that the live CD's are read only and behave just like a giant CD. The thumb-drive still shows up as a thumb-drive too. It acts like a separate device to the PC. (An U3 thumb-drive acts like a hub with two devices plugged into it.) This has some really cool implications.

Now I say... U3 ROCKS!