Today, in an article of little use to anyone, we’re going to learn how to change the UUID for your disk partitions. It’s not something you’ll want to do often, or even at all. There really isn’t much motivation to do so. In fact, this might just be one of the more useless articles (that isn’t a meta article) on the entire site! (I should mark it as ‘important’ for my own amusement.)
Why then is this an article? Well, it’s kinda neat, a little informative, and it was in my notes! As to why it is in my notes, I think I documented the process for a person on one of the various forums. I have no idea why they wanted to do this, but it is something you can do. I did check to ensure that it should still work.
A ‘UUID’ is a Universally Unique Identification. Your partitions have one. It’s a 128-bit alpha-numeric identification used internally seldom by you the user. At 128 bits, odds are very good that your ID is truly unique – but there’s no actual verification or anything. Your system generates ’em more or less pseudo-randomly and that’s the end of it.
If you want, run this command in your terminal (open a terminal, per my usual remarks):
1 | blkid |
That should show you your partitions and their UUID. It’ll also spit out a bunch of information that will help you identify it – such as the label field. That’s good, as you’ll want to pick one that you just don’t like and we’ll work on changing that one UUID to something new.
Change The UUID For Your Disk Partitions:
Up above, you should have opened a terminal and loaded up some information about your various partitions. Lemme see if I can get you a good example output – I’ll plug in an external drive with a bunch of partitions:
1 2 3 4 5 6 7 | $ blkid /dev/sda1: UUID="325A-C799" TYPE="vfat" PARTUUID="344a9235-01" /dev/sda5: UUID="5015896d-5947-4658-96b0-80efbfae4577" TYPE="ext4" PARTUUID="344a9235-05" /dev/sdb1: LABEL="elements1" UUID="46891b6c-4d86-48f8-b375-4729b2093d82" TYPE="ext4" PARTLABEL="Elements" PARTUUID="fad5fd22-1f11-499a-9f8b-b1e29d9de1b4" /dev/sdb2: LABEL="elements2" UUID="349b1b6e-7748-4e86-b358-2e27ca7bd998" TYPE="ext4" PARTUUID="d801cf31-3ce8-471a-b0f8-a47ca0bf9b56" /dev/sdb3: LABEL="elements3" UUID="f01814cd-6e7b-4f1d-82a6-22023afd9349" TYPE="ext4" PARTUUID="095a7aa9-17d8-454c-8fc0-bc6f88098c19" /dev/sdb4: LABEL="elements4" UUID="2f9fe4b2-bdb1-4fdd-af58-c552a4638486" TYPE="ext4" PARTUUID="a33f5cbf-092c-40af-9026-0290f9d6317f" |
So, there… You can see some data and see the UUID. Should you want to actually change the UUID, now’s the time to pick it.
Now, we’re going to generate a new UUID. Yup, you can do that. Try one of the following two commands – though both should probably do the trick:
1 | uuidgen |
Or:
1 | cat /proc/sys/kernel/random/uuid |
One, or both, of those will surely work on any modern Linux distro – unless it’s stripped down. If you don’t like the first one, you can keep generating them until you’re happy with the results. (You’re very, very unlikely to have a duplicate – as I’ll explain later, in the closure section.)
Now that you have your new UUID in hand, you’ll need to unmount the partition you’re going to change. If you don’t know how to do that, it’s just:
1 | sudo umount /dev/<disk_location> |
For example, that might be /dev/sdb2
or /dev/sdb4
that you’ll use to unmount the partition.
With that unmounted, let’s go ahead and finally change the UUID! You do that with:
1 | sudo tune2fs /dev/<disk_location> -U <new_UUID> |
Be sure to change the obvious for the obvious. Copy and paste from your terminal, perhaps even using two terminals, to ensure you get all the information correct.
When you’re done, the effects should be immediate. though you may need to mount the partition first. Run the following command to check:
1 | blkid |
If you’re satisfied with the results, great! If you need to first mount the partition, you can try this:
1 | sudo mount /dev/<disk_location> /mnt |
All should be wrapped up nicely in a bow, with your UUID happily changed to something else. Again, I don’t really have any good reasons for doing this – but you can do so if you want. I did mention that this was pretty useless… You were warned!
Closure:
Well, there you have it – another article? Hmm… Let’s really wrap it up. You know how it says it’s a “Universally Unique Identification”? Let’s look into that with some math.
Well, it’s 128 bits. That’s 2128 (less if a signed integer) which is equal to ~3.4 x 1038. I decided to look that up and find someone who did the work for me. This is that number represented in English:
three hundred forty undecillion, two hundred eighty-two decillion, three hundred sixty-six nonillion, nine hundred twenty octillion, nine hundred thirty-eight septillion, four hundred sixty-three sextillion, four hundred sixty-three quintillion, three hundred seventy-four quadrillion, six hundred seven trillion, four hundred thirty-one billion, seven hundred sixty-eight million, two hundred eleven thousand, four hundred fifty-five
Source: Quora
So, is the UUID you have truly unique? If you change the UUID, is it truly unique among all others? Perhaps, but you have better odds of winning the lottery multiple times in a row than you have of finding a matching UUID anywhere on the planet. 128 bits is a lot, an amount your human brain isn’t able to understand, which is also kinda why we will likely be a while longer before we move there from 64 bit. 64 bit is still pretty darned huge and there’s no real need for 128 bits at this time.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.