The term label, in regards to disk partitions, can refer to two different things. A disk
label can be used as another name for a partition table, as seen in parted output. A
partition label can also be the name of an individual partition. To see a partition’s label,
use the e2label command: $ sudo e2label /dev/sda2
/home
To set the label on a partition:
$ sudo e2label /dev/sda2 mypartition
Bear in mind that /etc/fstab sometimes uses the partition label to mount the partition
as in the following example. Changing this label may render the system unbootable.
LABEL=/boot /boot ext3 defaults 1 2
To find a partition when you know only the label, type the following:
$ sudo findfs LABEL=mypartition
/dev/sda2
-------------------------------------------------------------------------------------------
The oldest method to refer to devices in always the same way is by adding a file system label.This label is stored in the file system and not in the metadata. Using file system labels is useful
for mounting devices, as the mount command will check for a label. However, you cannot depend on it in situations where you need to address the device itself and not the file system that is in it.
Typically, you will add a label to a file system when formatting it. For instance, to add a label to an Ext3 file system, you would use the following command:
mkfs.ext3 -L mylabel /dev/sda2
On most file systems, you can also set a label to an existing file system. On Ext2/Ext3, you would do this using the tune2fs utility:
tune2fs -L mylabel /dev/sda2
Once the file system label is set, you can use it when mounting the device. Just replace the name of the device by LABEL=labelname to do this. For instance, the following command would mount the file system that has the label mylabel:
mount LABEL=mylabel /mnt
No comments:
Post a Comment