Wednesday, November 21, 2007

Format and Label a FAT32 External Disk

It took me a while to accept the fact that my backup disk is simply too small. It proved too small even after carefully selecting the files and directories to backup, and calculating the files and job retention periods, and backup rates, to match my 60GB disk. It only takes a few days of leaving large files lying around to fill up the backup disk - it has no slack.

I felt it was time to indulge myself and buy some hardware - I got a Western-Digital 250GB Elements USB external disk. It comes with no software at all, FAT32 formatted, and is readily recognized by my box.

I decided to format it after checking the disk with fsck.vfat (part of the dosfstools package) - it complained about differences between the FAT's on the disk, and about hidden sectors. The interesting bit of trivia regarding FAT32 is that you can't format a FAT32 volume larger than 32GB - get this - under Windows! Under Linux you just run the following:

mkfs.vfat -F 32 -n volume_name /dev/sda1

(you should, obviously, replace /dev/sda1 with the correct device path). The generated file system (233GB in size) is perfectly usable on both Windows and Linux.

As it happens, I did not specify a volume label, and went on to copy the backup files from the old disk to the new disk. I (and my Linux box) only realized that the volume label was now empty, at the next reboot, two days later. So I needed a way to label the disk without formatting it. This can be done with mlabel (part of the mtools package) like this:

mlabel c:volume_label

But you must first edit /etc/mtools.conf to make sure that the drive letter c: maps to the correct Linux device path - in my case it was just a matter of un-commenting the following line:

drive c: file="/dev/sda1"

I don't know why this mapping is necessary, but that's how these tools work.

Slack is good.

[7 Feb. 2008] UPDATE: labeling a disk updates just one FAT, causing fsck.vfat to complain about differences between FAT's on the labeled disk - this seems to be perfectly harmless.


  1. Regarding the mlabel command, you can specify the image file or device node on the command line, without changing any configuration files:

    mlabel -i /dev/sdb1 ::Label

    The ":" pseudo-drive-letter corresponds to the image/device after "-i". As far as I know this works for all the mtools commands.

  2. Thanks.

    Why is it necessary at all? Never mind. At least it works.

  3. sudo dosfslabel /dev/sdb1 MyLabel

  4. Thanks.

    Your comment made me curious - how did I miss this? well, it's simple actually: dosfslabel was introduced almost a year after this post was published...

    It's good to know that things are improving :-)


Note: Only a member of this blog may post a comment.