Articles

Install Linux on U3 USB drive

Yesterday i made some tests with my SandDisk Cruzer 16GB USB pendrive, this is what i discovered (i know, most of you already know that, but for the others that could be interesting): 

  1. U3 pendrives are made by a CD-like read-only partition + a mass storage device (USB pendrive)
  2. They appear as 2 different devices (/dev/sr1 and /dev/sdxY)
  3. The memory is shared between the CD and the memory, so, the bigger is the CD, the smaller is the free Memory
  4. You can replace the ISO image on your pendrive with an ISO of your choice (with u3-tool), and it will appear as a real CD device
  5. The CD device can be booted as a normal CD, probably also on devices which don't allow boot from USB, anyway not sure about that (not on APPLE stuff, tested)
  6. The CD part is readonly, (i.e. noobproof, you can borrow it to anyone, and they will not accidentally delete your slax nor boot folder)
  7. The ID (/dev/disk/by-id/*) of the CD device is similar to the ID of the mass storage part (i.e. the pendrive partition can be easily recognized by any script)


How-to (assuming you don't have any encrypted partition on your pendrive):

DISCLAMER: if you don't know what commands mean, don't do it, this could destroy you computer, your fridge, and even your microwave oven. :evil:

  1. Make | take an ISO of your preferred live distro
  2. Insert your U3 pendrive into your computer
  3. Backup ALL the data on your pendrive, they will be lost after this process
  4. # u3-tool -i /dev/sdxY (where sdxY is your u3 pendrive)
  5. # u3-tool -p XXXXXXXXX /dev/sdxY (where XXXXXXXX is the size in bytes of your ISO (may be something more than the size, you can get the size with "ls -l YOUR_ISO.iso")
  6. u3-tool -l YOUR_ISO.iso /dev/sdxY
  7. wait for the process to finish --> your CD is ready, now you have to partition the memory device according to the new size
  8. # fdisk /dev/sdx
  9. create a fat32 partition on the device (maximum size)
  10. save the new partition table
  11. # mkfs.vfat /dev/sdxY
  12. enjoy your customized CD+USB pendrive