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:
- Identify the partition that you want to label. You can use the
lsblkcommand 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.
- Unmount the partition. If the partition is currently mounted, you need to unmount it before you can label it. You can use the
umountcommand to unmount the partition:sudo umount /dev/sdb1
Replace “/dev/sdb1” with the actual device name of the partition that you want to label.
- Label the partition. You can use the
e2labelorxfs_admincommand 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
e2labelcommand: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_admincommand: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.
- 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.