Sunday, December 6, 2009

How to nuke U3 from your USB key using Linux

Don't you hate it when potentially simple hardware comes with all kinds of useless software and annoying features? USB keys that auto-install software on your PC are pretty high on my hate-that list. Anyway, it turned out to be possible to nuke this beautiful feature.

I did this on Ubuntu 9.10, on other Linux versions it may be a bit more complicated.

The general idea is to use an Open Source removal tool, and apply it to the specific 'generic device' that corresponds to the U3 CD-ROM image. Please note that following these instructions will likely erase all data on the USB key, so only proceed if you don't care.
  • Install u3-tool using apt-get (alternatively download it from http://sourceforge.net/projects/u3-tool/ and build it yourself).
  • Insert the USB key, notice that both an U3 CD-ROM image and a normal filesystem are mounted
  • Use 'df' to check which device is linked to the U3 image, it will show a line like this:
    /dev/sr1                  6828      6828         0 100% /media/U3 System
  • 'dmesg|grep sr1' will show a line like this:
    [ 2161.461482] sr 8:0:0:1: Attached scsi CD-ROM sr1
  • 'dmesg|grep 8:0:0:1' will show a line like this:
    [ 2161.461548] sr 8:0:0:1: Attached scsi generic sg6 type 5
  • This finally gives us the device we were looking for; sg6.
  • u3_tool_sg -p 0 /dev/sg6
  • Agree at the prompt, and poof, U3 will be gone.
  • Now you can use a partition editor like GParted to repartition the USB key and reclaim the space used by U3.
And thanks Sandisk, for making me have to spend half an hour on removing your annoying, insecure 'feature' when all I wanted was a plain USB key.

Update

On the bright side: the reverse also works. Always wanted to have a USB key that you could load an ISO onto and then boot from it as if it was a real CD-ROM drive?
  • u3_tool_sg -p 5000000000 /dev/sg5
  • (re-insert the key and re-determine the generic device)
  • u3_tool_sg -l some_dvd.iso /dev/sg6
  • (optionally re-partition and reformat the plain USB part, which will be sized to the remained of your USB key)
Assuming you have a USB key with at least 5 GB of capacity these commands will enable/resize the virtual CD-ROM image and write the ISO image of some DVD onto it. The main downside is that writing a DVD image in this way takes about an hour, much longer than burning a real DVD. However, after writing the image, booting from it will be blazing fast.

No comments:

Post a Comment