The information on how to label an ms-dos formatted drive seems scattered across the internet, and might seem overwhelming at first. But it’s not too hard. Here’s my recipe!
1. If not already installed, install the mtools package. This is an open source package for manipulating ms-dos file systems, under Linux.
to do that simply install the package:
sudo apt-get install mtools
We’re half way there!
3. Most systems should auto-mount the drive. If not, view this article, on how to mount a usb or micro-sd card.
4. We’ll use
to get the device id!
$ sudo blkid
[sudo] password for :
/dev/sde1: LABEL=”" UUID=”1B44-206B” TYPE=”vfat”
That’s the guy I want! sde1! Your device WILL probably have a different device name.
5. Let’s fix /etc/mtools.conf first.
using your favourite editor (nano in my case) let’s change mtools.
as always the # (octothorpe) is a comment and need NOT be coded.
cd /etc # change to the /etc directory
sudo cp mtools.conf mtools.conf.org # make a backup of the current file
sudo nano mtools.conf # edit the mtools.conf file
add a line at the bottom which reads:
drive p: file="/dev/sde1"
control+O (OH) to write, and then control x to exit. Again, your device name, might be different.
cd ~ # change back to my home directory
to get back to your home directory, after editing /etc/mtools.conf.
6. So now I try to label the drive, p: but I get:
nwayno@Homer:~$ sudo mlabel p:WAYNOFLSH
Total number of sectors (1957888) not a multiple of sectors per track (62)!
Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
Oh-oh! It turns out the it tells you how to fix the problem right there, but it may not be obvious. (All this to label an ms-dos drive under Linux? YES, unfortunately!)
Using your favourite editor, create .mtoolsrc (yes the period at the beginning is important!)
and add the line:
to the file. Save and exit. Again, all this is not hard, it’s just a pain.
7. Let’s try again!
$ sudo mlabel p:WAYNOBKFLSH
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sde1 955M 203M 752M 22% /media/WAYNOBKFLSH
8. Flush the buffers with sync
Look Ma, I didn’t have to use Windows, after all!