Add a line to /etc/fstab
to assign a mount point for the drive on every boot by following the below instructions from How to label disk partition in Linux .
Label disk partition examples
To see the device path of all your hard disk partitions, you can use the fdisk
command.
sudo fdisk -l
The blkid
command can be used to show the current partition label (if any) and UUID of the disk partition. Simply specify the device path of the partition you wish to see.
$ blkid /dev/sda1
/dev/sda1: UUID="a80ad9d4-90ff-4903-b34d-ca70d82762ed" TYPE="ext4" PARTUUID="75efe5f1-05"
One way to add a label to a disk partition is with the e2label
command. Use the below syntax to add a label to any disk partition of your choosing.
sudo e2label /dev/sda1 "MY_BACKUP"
Another way to add a label is with the tune2fs
command. The following syntax would be used to add a label to the /dev/sda1
partition.
sudo tune2fs -L "MY_BACKUP" /dev/sda1
The e2label
and tune2fs
commands will work fine for ext2, ext3 and ext4 formatted partitions. To label a partition that's been formatted as ntfs, you will need to use ntfslabel
instead.
sudo ntfslabel /dev/sda1 NTFS_DRIVE
To label a swap partition, you can use the mkswap
command with the following syntax.
sudo mkswap -L SWAP_PARTITION /dev/sda1
Mount hard drive partitions by label
Now we are able to refer to /dev/sda1
as MY_BACKUP, after adding that label to the disk partition in an earlier step. To do so edit the /etc/fstab
file and add the following line:
LABEL=MY_BACKUP /mount/point ext4 defaults 0 2