Saturday, July 01, 2006

External USB drives, Linux and Windoze

I recently bought a Maxtor 250GB external USB drive. This was to share files between my Linux and Windoze systems without having to worry about blowing away my linux installation if I decided to go with a new distro. There were several problems. First, the maxtor drives comes preformatted as NTFS so by default it can only be read on Linux. That was no good for me. I needed to reformat it as FAT32 but this proved to be much harder than you might think. I blanked out using the disk using dd so start completely from scratch. Windoze 2000 and Windows XP do not seem to recognise completely blank disks. The option to partition them is greyed out. Third party tools such as Partition Magic also seem to have the same problem. I tried to set the disk up under Linux using fdisk. This was very problematic but I did eventually get it to work. Here's what happened: using fdisk to set the partition to FAT32 (type = 'c') did not seem to do the trick. The next time I went into fdisk it claimed the partition table was empty. Eventually I came across some info that said the mkdosfs command has to be used and there is where I found a very nasty gotcha. Unlike most unix commands the mkdosfs command takes the options AFTER the device filename. If you put the options first as I did then the command claims to be working and sits there for ages as if it is working, but it does not produce any output. When it eventually finishes you think it has done the job but actually it has done nothing. Trying to mount the partition gives errors because the disk is still empty (you get various errors that basically indicate it could not find what it wanted from the superblock). The command that I used that does give the right results is: mkdosfs /dev/sdb -c -F 32 -I -v The command I was using was mkdosfs -F 32 -I -v /dev/sdb. When the command does work it takes a very long time but you can see it is working because it comes up with a long list of during the bad block search. Another gotcha to be aware of is to avoid having the disk mounted during boot time. This is because because large partitions can cause problems for certain boot loaders.