How to change the UUID of a partition in Linux

UUID on Linux

La UUID (Universally Unique IDentifier) is a universal unique identifier that uniquely identifies a partition of a file system or FS. It is a standard code used in Linux that you can see in / etc / fstab, for example, and that is composed of 16 bytes, that is, 128 bits. Therefore, it is composed of 36 alphanumeric characters divided into five groups with format: 8-4-4-4-12. That gives a lot of codes available and the chance of two codes matching is quite low.

For example, a typical UUID might be 6700b9562-d30b-5d52-82bc-655787665500. Well, if you find yourself managing a GNU / Linux operating system and you want to change it for any reason, now you will see how you can modify it easily. But before that, I will show you how you can see the UUIDs of your partitions present in your distro by executing any of the following commands:

cat /etc/fstab
sudo blkid|grep UUID

But if you want view the UUID of a specific partition or device, you can do it like this:

sudo blkid | grep sdd4

Once you know the UUIDs, you can change it in a simple way with the following command, assuming that this is the partition you want to change the UUID for:

umount /dev/sdd4
tune2fs /dev/sdd4 -U random

As you see, you must first unmount the partition you want to modify, then run the following command so that it randomly generates a new UUID and then you can check the UUID of that partition again to verify that it has changed.

Don't forget to modify the UUID in the corresponding field of / etc / fstab either. if that partition is in this file so that it is mounted automatically with the system boot. Otherwise there will be problems not recognizing the UUID. You can copy the displayed UUID and paste it into the appropriate fstab field to replace the old one using your favorite text editor ...


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Humberto Molinares said

    When you mention "and the possibility of two codes matching is quite low" in itself I do not agree with your mention, since I have cloned a 7GB partition (indifferent size for the test) in five partitions and guess IF they all had the same UUID . But if you make mention that they are completely self-generated, I am giving you the reason since at the time of generating it the System assigns a different UUID for all of them. Thanks for reading me.