To use a disk partition or block device in Linux, it must first be mounted. There are various ways to mount a partition, such as by device or partition name, partition label, or UUID. Mounting via UUID is the most reliable method because the UUID remains consistent, unlike a device name. Additionally, using UUIDs helps avoid potential name conflicts that can occur with labels.
You can manually mount a disk partition or block device in Linux using the UUID through the terminal and add the relevant entries to the fstab file.
Steps to mount disk partition by UUID in Linux:
- Open the terminal.
- Create a folder for mounting the partition if one doesn't already exist.
$ sudo mkdir -p /mnt/uuidtest
- Temporarily mount the partition using the UUID to test the process.
$ sudo mount UUID=39ea80c4-e748-47eb-835c-64025de53e26 /mnt/uuidtest
- Unmount the filesystem you just mounted.
$ sudo umount /mnt/uuidtest
- Open the /etc/fstab file with your preferred text editor.
$ sudo vi /etc/fstab
- Add an entry to /etc/fstab, including the UUID in the first field (block special device).
UUID=39ea80c4-e748-47eb-835c-64025de53e26 /mnt/uuidtest ext4 defaults 0 1
- Re-mount the partition using the /etc/fstab entry.
$ sudo mount /mnt/uuidtest
Comment anonymously. Login not required.