I did a small research before making the question,but I couldn't find an answer.My question is how can I change the uuid (universally unique identifier) of a hard drive disk.I am asking this because every time I want to access a hard drive from terminal I have to find these random uuid which the system has generated automatically which are quite long.Also,I want to know the dangers of making this kind of change.
-
Did you consider using a disk label instead? – Marco Mar 04 '12 at 15:22
-
1Dang Marco, you got there before I did ;) – Chuck R Mar 04 '12 at 15:24
-
see also: http://askubuntu.com/a/49296/3940 – Takkat Mar 04 '12 at 15:48
4 Answers
You can change a partition UUID or label, how to do so is dependent on the file system.
For changing the label see
https://help.ubuntu.com/community/RenameUSBDrive
For changing the uuid, you can use uudigen
and tune2fs
uuidgen
tune2fs /dev/hdb1 -U `uuid`
Change "/dev/sdb1" to the device you wish to change the uuid on.
You almost certainly will need to update /etc/fstab
if you change the UUID on a partition that is mounted by fstab, such as / or /home or /swap

- 102,067
If you add a label to your partition using a tool like gparted, parted, etc. your disk will show up as /media/mydisklabel instead of /media/somerandomhex-digits-38characters
If you're in the terminal you could also do something like:
disk=/media/fb0* #If your UUID starts with fb0
to set a variable and instead of using cd /media/somerandomhex-digits-38characters
you can use cd $disk
. Or, if you memorize the first few characters, cd /media/fb0*
works too.
The only way I know of to change a UUID is to re-format the disk, but it will just result in a different 38-character UUID, so it doesn't solve the problem.

- 4,918
-
Okay guys!I did it the relabeling with gparted and it worked.Thank you all for your answers!
BTW,IS THERE ANYWAY TO CHANGE THE LABEL OF THE HDD THAT I HAVE INSTALLLED THE UBUNTU,WHICH I AM CURRENTLY RUNNING?
– el10780 Mar 04 '12 at 15:53 -
yeah you are right Githlar!But I just want to organize my hdd space according to hdd labels.Like SecA(for the first hard drive),SecB (for the second hard drive) etc.... – el10780 Mar 04 '12 at 20:25
-
The hard drives themselves cannot be changed, they are referenced as /dev/sdX (IDE may still be /dev/hdX, but I don't own any IDE drives to check that). The X is either it's order in the SATA/IDE array (0=a, 1=b, 2=c, etc) or the order in which it was hot-plugged in the case of fireware/USB. This is a udev/kernel function and cannot be easily changed without hacking some source code. Even then I'm not sure how you'd identify a specific drive, but if you did manage it would make that kernel specific to that computer and you'd have to re-hack it for each computer you intend to install on. – Chuck R Mar 05 '12 at 07:51
You can change the LABELS of the hard drives but when doing so they will have to be unmounted. If you are booted into the system then it is not able to be revised. Recommend using Gparted Live CD because it will do the job an not regress the installed system.

- 16,127
-
-
A screen-shot could be very helpful. Please post a screen-shot of the changed hdd label. – Curious Apprentice May 08 '12 at 15:54
When I had faced the same problem, I've also tried to find solution for my question here. The question is just about how to identify HDD disk. So the solution for me was just to set identify as a "LABEL" instead of "UUID" in the Disks -> Mount Options. The details can be found here: How to change mounted HDD UUID to human-readable?

- 143
-
-
I just give another simple solution which worked for me, and that I wish I found here in this post. But unfortunately was forced to find a solution by myself. That's why some people may find it useful. – Ivan Sidaruk Feb 21 '19 at 17:05