Change hdd's uuid

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.


Solution 1:

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

Solution 2:

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.

Solution 3:

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.