Label a Linux Partition

In Linux, you can label a partition to give it a meaningful name that can help you identify its purpose. Here are the steps to label a Linux partition:

  1. Identify the partition that you want to label. You can use the lsblk command to list all the available disks and partitions on your system:
    lsblk

    This will display a list of all the disks and partitions on your system, along with their device names and mount points.

  2. Unmount the partition. If the partition is currently mounted, you need to unmount it before you can label it. You can use the umount command to unmount the partition:
    sudo umount /dev/sdb1

    Replace “/dev/sdb1” with the actual device name of the partition that you want to label.

  3. Label the partition. You can use the e2label or xfs_admin command to label the partition, depending on the file system that the partition uses.

    If the partition uses the ext2, ext3, or ext4 file system, use the e2label command:

    sudo e2label /dev/sdb1 new-label

    Replace “/dev/sdb1” with the actual device name of the partition, and “new-label” with the label that you want to assign to the partition.

    If the partition uses the XFS file system, use the xfs_admin command:

    sudo xfs_admin -L new-label /dev/sdb1

    Replace “/dev/sdb1” with the actual device name of the partition, and “new-label” with the label that you want to assign to the partition.

  4. Mount the partition. After labeling the partition, you can remount it:
    sudo mount /dev/sdb1 /mnt/data

    Replace “/dev/sdb1” with the actual device name of the partition, and “/mnt/data” with the mount point of the partition.

That’s it! The partition should now be labeled with the new label that you assigned to it. You can use the lsblk command to verify that the partition is labeled correctly.

Leave a Comment