Sunday, 20 December 2015

Adding my usb 64gb drive to the pi

I picked up a 64gb Nano usb for the pi this week. I used Amazon but, in the rather bizarre way I have of buying, I also use a service called for a lot of my Amazon purchases. It actually allows you to use digital Bitcoins via Amazon wishlists to make purchases. The mechanics of it are a bit dull but you usually get a discount via purse  of 5% upwards. So I shave a few pence off each purchase.

However after the device arrived my troubles began. It basically wasn't recognised. There is a reason for this and it goes back about 30 years.

USB drives were designed as floppy disk replacements originally. Big floppy disks but definitely removeable. For this reason they use a variation of the FAT filesystem. FAT is 'File Allocation Table'. The original 8 bit FAT format was designed for floppy disks with a capacity of 180kb (single sided).
Image result for floppy disk
The original floppy was 8 inches, which then became 5.25 and then became 3.5 inch. It was always 'floppy' but the external cases got harder to make them more resilient. Early data destruction stories include the secretaries that stapled the floppy to the printed hard copy to keep it "safe". Other stories are of disks folded to put into envelopes and so on. Data recovery of the floppy disk was big business at one point.

Back to my issue. As capacity of hard disks rose the FAT file system had to grow. It had to have more space and be able to store the tables of where the files were located. Simply put the numbers kept growing and in the 1980s the maths stopped FAT using disks over over 32mb. FAT12 limited the size to 32MB for a logical sector size of 512 bytes. Hard disks were then often partitioned and weird extenders were used such as disk compression.

Help was at hand. A usable FAT16 came in 1987 with Compaq's DOS 3.31 and the world breathed a sigh of relief. Unfortunately disks started growing again. Extended attributes to files came with IBM OS/2 operating system. On the Microsoft side of the fence Windows 3.x arrived and FAT was straining with friendly file names because FAT supported just 8 characters, a full stop and a 3 character file extension. So with Windows 95 so called 'long file names' were supported but everything stayed compatible with the older systems.

In the 1990s it looked like FAT was now too old because NTFS was the new fully permissioned Microsoft file system for big drives. FAT was being relegated quickly to consumer PCs and old floppy disks. It was dead.

That was until the arrival of USB. Everything still understood FAT so USB memory sticks came with FAT drives. Then the same problem happened. Capacity rose dramatically and the USB drive stopped looking like a big floppy disk. To cope with every expanding USB drives Exfat turned up to be backwards compatible but able to address huge disks of up hundreds of gigs on USB and memory cards for cameras.

Back to my raspberry pi. Simply put beyond 32gb it didn't recognise the USB disk. Immediately the 32 number stuck in my head. It turns out it can't boot from exfat beyond 32gb but does support FAT 32.

Rather than spend too much time with this I used 'fdisk /dev/sda1' to view the partitions on the storage. I deleted all the FAT stuff and created a Linux partition. A format with 'ext2' completed the transformation. Editing fstab allowed me to mount the USB as a native Linux disk and I changed the permissions to let everyone read/write. Since I am the only user it's not really a problem.

All done. It just felt that operating system history had come back to bite me....