mlabel Command in Linux



mlabel is a command used in Linux to label MS-DOS filesystems, such as those on floppy disks or USB drives. With this command, you can assign or change the volume label of a disk. This will make it easier to identify and organize your storage devices.

By using mlabel, you can avoid the need to use Windows tools to label your disks. It's a simple yet powerful command that helps you in managing the labels of your MS-DOS file systems directly from your Linux terminal.

Table of Contents

Here is a comprehensive guide to the options available with the mlabel command −

Syntax of mlabel Command

The general syntax to use the command mlabel on Linux is provided below −

mlabel [options] [-N serial] drive:

Where −

  • [options] are optional flags you can use to modify the behavior of the command.
  • [-N serial] allows you to set the volume serial number.
  • drive: specifies the target drive letter followed by a colon (e.g., a:, b:).

mlabel Command Options

Listed here are various options available for use with the Linux mlabel command −

Option Description
-v Verbose mode; shows detailed information during execution.
-c Prompts for confirmation before making any changes.
-s Shows the current volume label instead of setting a new one.
-N serial Sets the volume serial number.
-n Generates a new, randomly assigned serial number for the disk.

Examples of mlabel Command in Linux

The following are some examples of the command malable in Linux environment −

  • Setting a Volume Label
  • Displaying the Current Volume Label
  • Setting a Serial Number
  • Prompt for Confirmation
  • Skipping if Already Labeled

Setting a Volume Label

To assign a new label to a USB drive, use the mlabel command followed by the drive identifier and the desired label. This operation sets the volume label on the specified USB drive −

sudo mlabel -i /dev/sdb1 ::MyUSBLabel

This command sets the volume label of the USB drive identified as /dev/sdb1 to "MyUSBLabel".

Displaying the Current Volume Label

If you wish to display the current volume label of a USB drive, utilize the -s option −

sudo mlabel -s /dev/sdb1

This command shows the current volume label of the USB drive identified as /dev/sdb1 in the terminal.

Setting a Serial Number

To assign a new serial number to a USB drive, use the -N option followed by the serial number −

sudo mlabel -N 12345678 /dev/sdb1

This command sets the serial number of the USB drive identified as /dev/sdb1 to "12345678".

Prompt for Confirmation

For those who require confirmation before any changes, the -c option ensures user validation −

sudo mlabel -c /dev/sdb1 ::MyUSBLabel

This command prompts for confirmation before setting the volume label of the USB drive /dev/sdb1 to "MyUSBLabel".

Skipping if Already Labeled

If you prefer to skip labeling when the drive already has a label, use the -n option −

sudo mlabel -n /dev/sdb1 ::MyUSBLabel

This command avoids overwriting an existing volume label on the USB drive /dev/sdb1.

Conclusion

The mlabel command in Linux is a fundamental tool for labeling MS-DOS filesystems, including those on floppy disks and USB drives. By understanding its syntax and exploring the various options available, you can effectively utilize mlabel to streamline your file management tasks.

Whether you need to set new labels, view current ones, or configure serial numbers, mlabel offers a robust solution to meet your requirements.

Advertisements