change linux partition label names

How to Change Linux Partition Label Names

A disk partition is a part of your system’s hard disk that is used for data storage or to run system software such as operating systems. Partitions used for data storage work independently of other partitions. Each partition is stored on your hard disk or external storage, depending on how you configure it, and had a label associated with it, for easy identification. Sometimes you may need to change Linux partition label names. In this article, we will learn how to do this.

Each Linux partition can be of SCSI, SATA, PATA or virtual hard disk type. There can be a maximum of 16 partitions on a disk. By default, Linux assigns them labels for quick identification. These labels are of the format /dev/sdxn or /dev/vdxn where x is an alphabet and n is a number. s is for SATA or SCSCI, v is for virtual disk, and d is for device. That is how Linux labels partitions as /dev/sda1, /dev/sda2,.. on your primary hard disk, and /dev/sdb1, /dev/sdb2,… on your secondary hard disk, and so on.


How to Change Linux Partition Label Names

There are several types of Linux partitions such as Primary partition, Extended partition, Logical partition, Linux LVM partition, and Volumes. There are several tools and commands to change Linux partition label names, some are meant for a specific type of disk format such as Ext, or NTFS while some are meant for all types of disk format.

1. e2label or tune2fs

e2label and tune2fs are commands to change partition labels of ext2, ext3, ext4 partitions.

# e2label /dev/sda1 ROOT
OR
# tune2fs –L ROOT_PART /dev/sda1

In the above command, ROOT and ROOT_PART are labels to be added to /dev/sda1 which is ext4 formatted partition.

2. ntfslabel

ntfslabel command is used to changing labels of NTFS partitions.

# ntfslabel /dev/sda5 NTFS_DIR

3. reiserfstune

If you want to change label of reiserFS formatted partition, you can use reiserfstune command.

# reiserfstune –l HOME_PART /dev/sdb1

In the above command, /dev/sdb1 is the partition formatted as reiserFS filesystem.

4. mkswap

You can also use mkswap to command to change label of SWAP partition. After you unmount the SWAP partition, you can run the following command to change its label.

# mkswap -L SWAP_PART /dev/sda5

5. exfatlabel

If your partition is exFAT formatted, you can use the following command to change its label.

# exfatlabel /dev/sda3 EX_PART

Basically, there are many specific tools meant for each type of disk format. There are also many GUI based tools such as GParted that help you manage your disk partitions.

In this article, we have learnt how to change Linux partition label names.

Also read:

How to Disable Output Buffering in Python
How to Read Large Files in Python
How to Copy File Permissions & Ownership in Linux
Display Command Output & File Content in Column Format
How to Create Nested Directory in Python

Leave a Reply

Your email address will not be published.