"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Saturday, 29 September 2018

Things to remember: mount your USB drives using UUID


This is just a short post to remember myself, and hopefully to my few readers, how a little more research before doing things could save from problems in future. I had to disconnect all my computer, the Raspberry and every devices because of some maintenance works I hhad to do at home. As often happens when I connected all back not everything worked as before.
Worst of all was the Raspberry Pi 3 that didn’t boot anymore or, at least, the boot process crashed betore turning on the network. I had to attach the Raspberry to my TV to discover that the boot process failed while trying to mout the attached USB drives. After some swapping of available USB slots I managed to get back to the original working position. I had to solve the problem definitively.

Mounting drives using UUID

USB drive devices are assigned on a per position basis. This is usually irrilevant for removable drives but it can become a problem when using USB for fixed, mounted on boot, drives. The solution is defining drives non by using their assigned device but the device unique identifier (UUID). The funny thing is that the solution was already on display in Raspberry “fstab” file since the system uses a similar identifier (PARTUID) in order to mount boot and root partitions.
The drive UUID can be easly printed by using “blkid” or “lsblk” commands. Here the vary informative output produced by “lsblk” command:
sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL

once identified drive UUIS is just matter of replacing it inside “/etc/fstab” file like this:
# USB Disk
#/dev/sda1 /media/usbdisk ext4 rw,defaults 0 0
#/dev/sdb1 /media/backup xfs rw,defaults 0 0
UUID=bc83dfb9-ebc5-4a96-9cd2-0657fa767717 /media/usbdisk ext4 rw,defaults 0 0
UUID=debd0d49-549a-4187-8284-f20dc3c8f986 /media/backup xfs rw,defaults 0 0