Copy partition, keep destination UUID ? [CLOSED]

Archived topics about LMDE 1 and LMDE 2
Locked
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Copy partition, keep destination UUID ? [CLOSED]

Post by ron_h »

LMDE 201403 Cinnamon 64bit

Is there any tool which will copy a partition from a hard drive, to a different partition on the same hard drive, keeping the destination partition's UUID ? If the tool would do a 'smart copy' of /etc/fstab replacing the /dev line with the destination partition's name and replacing the UUID line with the UUID of the destination partition that would be great.

As best I can tell Gparted, Clonezilla and qt4-fsarchiver will not do this as they produce a complete clone in the destination partition, which gets the source partition's UUID (so there are then duplicate UUIDs on the drive) and a straight copy of the /etc/fstab showing the /dev and UUID lines from the source partition.

Ron
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
eanfrid

Re: Copy complete partition, keep destination UUID ?

Post by eanfrid »

UUID or LABEL are only volume metadata. If you need these metadata in your file system configuration, you will need to modify manually the related files to adjust to metadata changes. The purpose of volume cloning is to make exact copies of the source, otherwise it would be a nightmare for forensics analysis.
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: Copy partition, keep destination UUID ?

Post by ron_h »

The purpose of volume cloning is to make exact copies of the source
Yes, I agree. I do NOT want to clone, I want to copy. That's why I asked the question.

And in fact, the other question that has now been added to this thread.

Ron
Last edited by ron_h on Sat Jun 21, 2014 5:36 am, edited 1 time in total.
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

UUID in any file other than /etc/fstab ?

Post by ron_h »

LMDE 201403 Cinnamon 64bit

If I have a partition on a hard drive that is cloned from another partition on the same hard drive, the 2 partitions have duplicate UUIDs and the /etc/fstab files are identical. To differentiate the partitions, I need to assign a new UUID to the destination partition, which I can do with Gparted. I also need to correct the /dev line and the UUID line of /etc/fstab to point to the destination partition, which I can do with an editor.

Are there any other files in the destination partition which contain the UUID ? If so, I need to correct them as well.

Ron
Last edited by ron_h on Sat Jun 21, 2014 9:39 pm, edited 1 time in total.
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: Copy partition, keep destination UUID ?

Post by ron_h »

If you need these metadata in your file system configuration,
Well, I think I do, in order, down the track, to get a correct GRUB menu generated. I may be wrong, in which case I hope to get feedback to say why.

Ron
User avatar
Fnux
Level 1
Level 1
Posts: 18
Joined: Mon Aug 19, 2013 10:32 am
Location: Palm Beach, Florida, USA
Contact:

Re: Copy partition, keep destination UUID ?

Post by Fnux »

Hi ron_h,
ron_h wrote:
If you need these metadata in your file system configuration,
Well, I think I do, in order, down the track, to get a correct GRUB menu generated. I may be wrong, in which case I hope to get feedback to say why.

Ron
I don't know exactly what you expect to do, but for what I've understood of your post (please correct me if I'm wrong), I guess that you plan:
a) to duplicate a partition to another one (on the same hard drive or not doesn't change the problem),
b) then have a different UUID for the cloned partition to be able to create a new grub menu that differenciates the first and the second partition.

If this is what you want to acheive, here is how I do so:

Let's say the partition you want to duplicate is (and it's only a sample) /dev/sda3.

You can duplicate this partition using gparted as well as using the following command line:

Code: Select all

sudo ddrescue /dev/sda3 /dev/sdXN
where "X" is the letter of the target drive and where "N" is the number of the new cloned partition.

NOTE 1:
If the command "ddrescue" isn't available on your system, you can install the relevant package using the following command line:

Code: Select all

sudo apt-get install -y gddrescue
NOTE 2:
If you plan to clone a partition from one hard drive to another one, the generic command line to do so is:

Code: Select all

sudo ddrescue /dev/sdAB  /dev/sdCD
              ---------  ----------
               source     target
where:
A is the letter of the source drive,
B is the number of the source partition,
C is the letter of the target drive
and D is the number of the target partition.

i.e. the command line:

Code: Select all

sudo ddrescue /dev/sda3 /dev/sdb6
will clone the source partition "3" of the source drive "a" to the target partition "6" of the target drive "b".

Then, after performing such a copy (that's nothing but a pure clone of the source partition to the target partition), the UUID of the target partition (/dev/sdAB) will hopfully be the same than the one of the source partition (/dev/sdCD).

Now, to change the UUID of the cloned partition (/dev/sdCD), you can use the option "Partition->New UUID" of gparted as well as the following command line:

Code: Select all

sudo tune2fs -U `uuidgen` /dev/sdCD
Once this is done, you can get the new UUID of the cloned partition /dev/sdCD with gparted or when using the following command line:

Code: Select all

/sbin/blkid /dev/sdCD
Then, you MUST change the UUID of the new cloned partition in its own /etc/fstab file

To do so, please mount the new partition and use the following command line:

Code: Select all

gksudo gedit /media/your_user_name/name_of_the-cloned-partition/etc/fstab
Then, replace the UUID of the partition with the new one and save the file.

Then, to create a new grub menu that will take care of the cloned partition as a new entry, please use the following command line:

Code: Select all

sudo update-grub
And you must be done.

Then, please reboot your system and you should have a new enty in the grub menu.

Hope this helps and responds to your needs.

All the best.
Don't start a discussion during a diner since the one who's not hungry will have the last word.
Apple iMac 27- RAM 32 Gb - SSD 2 Tb - HDD 4 Tb - 2 screens 2560x1440
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: Copy partition, keep destination UUID ?

Post by ron_h »

Thank you for the detailed response. I think you are confirming that the UUID is metadata associated with a partition, and can be changed, for example by Gparted. Also that the only file inside the partition that contains the UUID is /etc/fstab and this needs to be changed so as to be in synch with the changed UUID for a partition.

OK, I can do that. Thanks to these forums, and responses to topics I have raised, I think I now I understand things better (starting from a low base of knowledge).

I have looked at backup/archiving/cloning methods and it seems that they all, when handling a complete partition, copy over the UUID of the source partition to the destination partition. The only way I can see to avoid copying the UUID is to set up a backup job which backs up every directory in a partition then a restore job to restore the backed up directories to a different partition. This could be tedious to set up and I suspect would be slow to execute. And even then, I'd still have to manually adjust, or create if I chose not to copy it, the /etc/fstab of the destination partition after the restore is complete.

I'll mark this thread as CLOSED.

Ron
Locked

Return to “LMDE Archive”