Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 2327  / 3 Years ago, mon, may 3, 2021, 12:13:31

I have always seen people discuss using UUIDs in hard drives instead of /dev/sdN.



What is the real benefit of using a UUID? Is it faster, more reliable, easier to remember (ha lol no), what?



And, isn't it possible to change a UUID? Is there a way to identify a drive (especially in GRUB) that can never change?


More From » uuid

 Answers
5

What is the real benefit of using a UUID?


Generally, the UUID is constant for the same drive/partition no matter what system it is attatched to.


The /dev/sdN naming scheme increments the final letter (N) for each device plugged in (a, b, c, d, etc.). This means that the /dev/sd identifier assigned to the device changes if it is attached in a different order.


And, isn't it possible to change a UUID?


Yes, see here.


Is there a way to identify a drive (especially in GRUB) that can never change?


That's what UUIDs are for. They're probably the most stable solution you can get.




Using UUIDs in scripts and the like


If you are instructed to perform a command like this:


dd if=/dev/sda of=/dev/null 

... you can replace /dev/sda with a file in /dev/disk/by-uuid/ to reference the disk by UUID instead of sdN.


Run these commands to get the UUIDs (and sdN notation) of drives on your system:


for disk in /dev/disk/by-uuid/*; do
readlink -e "$disk"
echo "${disk#/dev/disk/by-uuid/}"
echo
done

[#27333] Tuesday, May 4, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ranquctive

Total Points: 391
Total Questions: 103
Total Answers: 104

Location: South Sudan
Member since Thu, Feb 4, 2021
3 Years ago
ranquctive questions
;