Label a Partition

Author:

baizabal.jesus@gmail.com

Label a Filesystem

How to properly label a partition filesystem Partition Map

Rename USB Drive

This guide is primarily for external drives such as USB harkd drives, USB flash drives, and flash memory cards. You can label internal disks, but to change their mount points, use MoveMountpointHowto which uses the file called Fstab. This guide covers editing partition labels (disk names) for FAT16/FAT32, NTFS, ext2/ext3, JFS, ReiserFS, and XFS filesystems.

Tip

external drives automatically mounted at /media/disk then /media/disk-1 and so on. This is not very helpful when trying to find the drive you are looking for, especially if you have multiple devices plugged in. Labeled devices that are automatically mounted will be mounted in the /media directory using their label as the mount point, /media/. ex: /media/my_external .

Important

When choosing labels, be sure that the new mount point /media/ does not already exist since the directory will be created when the disk is mounted.

Using the Partition Editor

The file manager (Nautilus) currently does not support renaming disk partitions, but Gnome’s Partition Editor (GParted) does. To change a partition’s label, follow these directions. (Be careful using Partition Editor, as it’s capable of making your computer completely unusable if you do the wrong thing.)

1.Open the System > Administration menu and see if there’s an entry for GParted (previously Partition Editor).

2.If there is, launch it. If there isn’t, install the “gparted” package and it should now appear in the menu. Enter your password when prompted.

3.Disk drives are divided up into partitions. To find the partition you want to re-label, you first have to find the disk drive that contains it, using the drop-down menu in the upper right. It will show a device name like /dev/sdb and the drive’s total size in parentheses. After selecting a drive, you will see a list of all partitions on that drive.

4.If the partition is mounted (has a key icon next to it), right-click on the partition and select Unmount.

5.With the key icon gone, right-click on the partition and select Label. If you can’t select it, install the ntfsprogs package.

6.Enter the new partition name and press Ok.

7.The label change is now pending, but has not been completed. Press the Apply button near the top of the window. After confirming, it should say “All operations successfully completed”. The drive now has a new label.

Using the Command line

There are at least 6 separate command line tools used to label a partition the program used depends on the partition’s filesystem type:

  • For FAT16 and FAT32 partitions, use mlabel from the mtools package.

  • For NTFS partitions, use ntfslabel from the ntfs-3g package.

  • For ext2, ext3, or ext4 partitions, use e2label.

  • For JFS partitions, use jfs_tune.

  • For ReiserFS (v3) partitions, use reiserfstune.

  • For XFS partitions, use xfs_admin

Identify your Partition

Note

For help with the terminal, see UsingTheTerminal.

Plug in your USB device and list your partitions with:

sudo fdisk -l

You can also list your mounted devices and their descriptions with:

mount

Note

For the rest of this tutorial we will use the following:

  • device = your device /dev/sdxy, ex: /dev/sdb1

  • label = your desired (new) label, ex: my_external

Install the Labeling Program

Based on the package names listed above for each filesystem type, install the correct package for your partition:

sudo apt-get install <package>

Here are all the different ones:

Install tools
sudo apt install mtools ntfsprogs e2fsprogs jfsutils reiserfsprogs xfsprogs hfsprogs exfat-utils exfatprogs btrfs-progs

or install the appropriate package from Synaptic.

Verify the Change

Now for the easiest part: unplug the drive, wait a second, then plug it back in. It should appear on your desktop with the new label and have its new mount point. Without unplugging and having the device remount, you can also just run:

sudo blkid

Last update: Nov 20, 2024