Linux mount disk UUID and /etc/fstab

Almost everyone knows how to add an automatic mounting /etc/fstab, perhaps not used as it should the mounting is using UUIDs.

The UUID (Universally Unique Identifier) is a unique identifier for each file system. It is very interesting because it allows use as a reference for installation, ie instead of using /dev/sdb1 (physical connection reference) may use UUID and thus could change the connections of the discs without the mount points they saw affected.

The tool to know the UUID of the discs is:

Source   
[root@test ~]# blkid
/dev/sdb1: UUID="a210f4aa-0333-4827-b4f0-4a987c3364cf" TYPE="ext4"
/dev/sdb2: UUID="2133ef48-5eb9-4413-8b42-2f5f023a765b" TYPE="ext4"
/dev/sda1: UUID="0cdd3b92-349c-407f-87d2-63242782b531" TYPE="ext4"
/dev/sda2: UUID="rNf0sI-d44o-5c3f-VJMJ-zdhk-eT4q-Lc8xXT" TYPE="LVM2_member"
/dev/mapper/vg_test-lv_root: UUID="6c9fa623-8bc4-4143-b8a5-f7d0966980c9" TYPE="ext4"
/dev/mapper/vg_test-lv_swap: UUID="b382f6a5-0a63-4ab8-aaf4-8b8c1c0b969d" TYPE="swap"

For example if we want to mount the UUID “a210f4aa-0333-4827-b4f0-4a987c3364cf” (which is a HD connected to local) on /vol, the file /etc/fstab must include the line:

Source   
UUID=a210f4aa-0333-4827-b4f0-4a987c3364cf       /vol    ext4    defaults 1      2

It is mounted with the defaults options (rw, etc.), the 1 indicates that when the OS closes a dump of outstanding data and 2 is a mount point to be checked at boot will (option 0 indicates that filesystem is not verified and 1 reserved for /).

After changing /etc/fstab can force without restarting your reading:

Source   
mount -a

Remember that it is also possible to perform a remount with new settings before changing anything in /etc/fstab:

Source   
mount -o remount,acl /vol

In this case, the acl option added (work with ACLs).

Using UUID massively used when working with disk arrays, in these cases there is no guarantee that the discovery of the devices is always in the same order and can have serious problems. UUIDs are the only way to ensure proper mounting the discs.

If we add disks in hot (from any system virtualization) it is possible that the OS does not know until we do a rescan of the SCSI bus, this can be done with the tool:

Source   
rescan-scsi-bus.sh

To install Red Hat:

Source   
yum install sg3_utils

Leave a Reply