Restoring USB keys

Q I've tried out Ubuntu 8.10 using a new 8GB USB stick. Ubuntu is a keeper, so I installed it to disk, but how do I get my USB stick back to where it was?

A Did you set up the USB stick as a live device? If so, it still has a standard FAT filesystem and you only need to delete all the files from it in the usual manner. If you installed to it as if it was a hard disk, you need to restore the default setup of a single FAT32 partition, which you can do with GParted - you can install this through Synaptic.

Make sure your USB stick is plugged in but not mounted - right-click its icon and select Unmount Volume - then run GParted. Make sure you pick the correct device (it's probably /dev/sdb, but the size of 8GB should be a dead giveaway), delete the partitions on it and click on Apply. You can now create a new partition using the FAT32 filesystem to fill the device completely.

You may also want to remove the bootloader from the device. It won't do any harm leaving it there, unless you reboot with the stick in place, when the computer could try to boot from it instead of your hard disk and fail. Remove the bootloader by running this in a terminal:

dd if=/dev/zero of=/dev/sdb bs=446 count=1

This command zeros out the first 446 bytes of data on the stick, which is the area that contains the bootloader. Make sure you specify the right device the first time, as dd doesn't offer you any second chances. You see, it's a low-level tool whose name could just as well stand for delete and destroy.

Follow us on or Twitter

Username:   Password: