dosfslabel - Linux


Overview

dosfslabel is a utility used to get or set the volume label of a MS-DOS compatible FAT filesystem. It can be used to view or modify the name of the filesystem.

Syntax

dosfslabel [options] <device>

Options/Flags

  • -h, –help: Display help information.
  • -V, –version: Display version information.
  • -n, –newlabel: Set the new volume label.
  • -f, –force: Override any existing label.
  • -b, –boot: Set the label for the boot partition.

Examples

Get the volume label of a device:

dosfslabel /dev/sda1

Set the volume label of a device to "MyLabel":

dosfslabel -n MyLabel /dev/sda1

Set the volume label of the boot partition to "BootLabel":

dosfslabel -b -n BootLabel /dev/sda

Common Issues

  • "Volume label not found": The filesystem does not have a volume label.
  • "Write error": Ensure you have write permissions to the device.
  • "Invalid volume label": The label must be between 1 and 11 characters long and cannot contain special characters.

Integration

dosfslabel can be used in conjunction with other commands to automate tasks:

fdisk -l | grep ext4 | awk '{print "/dev/" $1}' | xargs -n1 -P2 dosfslabel

Related Commands

  • fdisk – Manages partition tables.
  • mount – Mounts a filesystem.
  • mkfs – Creates a filesystem.