Mounting your hard drive,ssd by UUID can be usfull specially if you always want to have the disk mounted in the same location, for example you may have adb,sdc mounted at specific point on the file system all with differnet data, it important that the disk is always mounted in this location in the event a disk is swapped or added, this is can happen when the disk register in a differnet order so the name can get messed up, I tend to see this with raid cards where the disks spinup with a delay, I have a 16 port card which does this.

What I will show you is how to mount a disk to a specific location.

First off you will need to add your new disk to the server setup the partitions and format it as required.

Once you have formatted the disk check in this example sdc and created the partitions (only 1 in this example partition sdc1) then we will need to find out the UUID of the disk partition, to find the UUID run

ls -l /dev/disk/by-uuid/

This should provide some results like

lrwxrwxrwx 1 root root 10 May 7 18:24 5a5426fc-6c41-4495-a977-8d4b0ac4271d -> ../../sda1  
lrwxrwxrwx 1 root root 10 May 7 18:24 8057b2c6-5b82-4e14-b945-1c169824347a -> ../../dm-0  
lrwxrwxrwx 1 root root 10 May 7 18:24 a22c8a18-e9ab-4f06-91d7-9e107f60055d -> ../../sdc1  
lrwxrwxrwx 1 root root 10 May 7 18:24 b5dbaebd-cda7-45e9-969b-eb53a062a7d6 -> ../../dm-1  
lrwxrwxrwx 1 root root 9 May 7 18:24 b83d06c2-b5e4-4545-928d-4d446c3e9816 -> ../../sdb

now you will need to take the partitions UUID (highlighted in RED) and add this to fstab, by adding this to fstab this is mounted at boot time.

When adding to fstab this is done in much the same way as a normal disk except you specify the UUID rather than the volume group or disk name.

Here I am going to add this and have it mount at /storage/disk-01

cat "UUID=a22c8a18-e9ab-4f06-91d7-9e107f60055d /storage/disk-01 ext4    defaults        0       2"  >> /etc/fstab

once this has been added you can no mount the partition without a reboot  by using

mount -a

you can check that this mounts correctly with a system reboot, after the reboot this should mounted at /storage/disk-01

Thanks for reading and I hope this helps.

Add a comment

0.0(0 votes)

Next Post