1 (edited by gedakc 2016-05-04 19:05:19)

Topic: [SOLVED] UUIDs should be unique - Add ability to set New UUID

Hi,

I noticed that when copying a partition and pasting it on the same harddisk,
the UUID of both the partitions IS the same.

I found this uncomfortable and would ask for a change in this aspect, please.

IMHO, in a harddisk there should NEVER be two partitions with the same UUID.

Regards,
blueyes

2

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

Hi!

You're right, there should not be two partitions using the same UUID on the same hard drive... To be precise, there even should not be two partitions using the same UUID in the universe.
However, the point is the the UUID is not a property of the partitoopn, but of the file system inside this partition. So changing the UUID requires modifying the file system - which might be not desirable if you need an exact clone of a partition (think about e.g. forensics after a crime or a virus attack, or about scenarios where you try to rescue data from broken hard drive or simply want to have a backup of your Linux install - since Ubuntu identifies file systems using their UUIDs, your backup would be unusable if its UUID was changed, since Ubuntu would not find its root partition after restoring unless you edited the fstab and put the new UUID there).
As you can see, changing the UUID can cause as much trouble as keeping it! Thus, I think keeping the UUID unchanged is the right approach - howeverm, if you need ti changed, you can set a new one using the tune2fs command line tool:

tune2fs -U random /dev/sda3

will set a new random UUID for the ext2 or ext3 file system on /dev/sda3. If you use other file systems than ext2/ext3, you can change the UUID using

xfsadmin         for XFS file systems
jfs_tune         for JFS file systems
reiserfstune     for ReiserFS (not Reiser4!) file systems

Please have a look at the man paghes for these tools to learn how they work. Similar tools might exist for other Linux file systems as well; I've only listed the most commonly used ones here.

3

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

hi and thank you for the answer

I see the point of your arguments but it seems to me that there is a contrast:

1.     let's say that uuid is really absolutely unique in all the universe:
    then, right, that partition is that partition, without any doubt

2.    now, let's see that with gparted I can copy that partition, make
    a lot of mess inside, change here and there and still the uuid
    is the same of the original copied partition: how can you say
    which one is the real true original partition if they have the same
    identifier number?

only if the uuid is linked to one (and only one) partition then
it would have a solid meaning for, for instance, forensic purpose

otherwise it isn't "Universally Unique", but just an IDentifier




anyway, it's not such a big problem afterall

thanks again

regards,
blueyes

4

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

Hi!

About "Universally Unique" IDs: These are just generated from some random data - there's no global database against fresh UUIDs are checked if they are already in use, so there's no guarantee that a UUID is really universally unique. It's just a matter of probability!
Then, in your scenario, the partitons are the same at the moment you clone them - you could trash any one of the copies and use another one instead, and you ynd your Linux system won't notice any difference. But as you use one of the copies, it is clear that it gets modified - but since the UUID simply identified the file system (and not its contents), it will not be changed.
It's just the same as printing a document two times, then locking away one copy and using the other one as a work paper: One will remain unchanged, the other one will be commented and passed on, maybe parts will be corrected or replaced... In the end, you will have two completely different pieces of paper, even if they started off as the same document (and maybe with the same archive number printed on the sheet...).

5

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

I see the whole point of also copying the UUID, on the other hand it turns your system into a sort of gambling system as most distributions use UUIDs to mount the disks. Which one does it take, the backup or the original?
It took me once more than an hour before I recognized were my lost new files were gone to: the system had mounted the backup accidentally instead of the original when I made the files, and during the next boot it mounted the original filesystem again, making me believe that I lost the files....

Could it be an idea to include an checkbox whether the UUID should be copied or regenerated?

6

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

For what it is worth this is what I use to change the UUID:

You can boot from a live CD/USB from Ubuntu (for example), go to terminal and use this code:

dd if=/dev/urandom of=/dev/[ntfspartition] bs=8 count=1 seek=9

Replace the [ntfspartition] with the proper partition that you want the UUID changed on (ie: sda1)


!!!!!!!!!!!!!!! WARNING WARNING WARNING !!!!!!!!!!!
For [ntfspartition] YOU MUST make sure you Identify the PROPER partition!!
ie:  sda1   or   sda2   or  sdb1  or  sdb2  or  sdc1  or sdc2   etc etc etc.
DO NOT put sda in there or you will SCREW your MBR !
Also you will want to run:  sudo blkid to make SURE you are modifying the proper partition.
!!!!!!!!!!! END OF WARNING WARNING WARNING !!!!!!!!!!!!!!!!

7

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

Thank you for the tip GMHilltop.

Work is currently in progress to add the ability to set a new UUID in GParted.

See Bug 667278 - Add support for setting UUID

8

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

With GPT Partitioned drives becoming more main stream I was wondering if GParted's ability to create a random UUID works on GPT partitioned drives also?

I haven't had the opportunity to test it out yet myself yet and thought I'd ask.

Thanks

9

Re: [SOLVED] UUIDs should be unique - Add ability to set New UUID

GMHilltop wrote:

With GPT Partitioned drives becoming more main stream I was wondering if GParted's ability to create a random UUID works on GPT partitioned drives also?

I haven't had the opportunity to test it out yet myself yet and thought I'd ask.

Thanks

Short answer is yes it works with GPT.

The UUIDs in question are the file system UUIDs.  These are the ones changed by the "New UUID" function in GParted.  Therefore it is independent of the partitioning and will work with MSDOS, GPT or any other support partitioning type.