How to retrieve and change partition's UUID Universally Unique Identifier on linux - LinuxConfig.org
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-retrieve-and-change-partitions-universally-unique-identifier-uuid-on-linux
It’s even simpler to use “tune2fs /dev/sda1 -U random”, you won’t even need to install the uuid utility.
Great tutorial. I didn’t realize there were so many ways to look up the UUID.
I’ve found another that I like very much. I’m not sure if it was around when you wrote this tutorial. findmnt
When I need to find our where a particular filesystem is mounted in a particular place I do
if findmnt -n --evaluate --output=target UUID='6c670636-94b1-4434-95bc-353041cb2de5' | grep '/mnt/corsair_USB_Data'; then echo TRUE; else echo FALSE; fi
Of I can find the mount point first and save it for later use in the script
mount_point=$(findmnt -n --evaluate --output=target UUID='6c670636-94b1-4434-95bc-353041cb2de5')
This will output the mount point (if mounted) of a filesystem with UUID: 6c670636-94b1-4434-95bc-353041cb2de5
Then I just need to check that it is actually mounted, because if the filesystem wasn’t mounted $mount_point will be empty.
if [ $mount_point ]; the echo "MOUNTED"; else echo "NOT MOUNTED"; fi