Copy partition, keep destination UUID ? [CLOSED]

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

Copy partition, keep destination UUID ? [CLOSED]

Postby ron_h on Sat Jun 21, 2014 2:10 am

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 ron_h on Sun Jun 22, 2014 3:48 am, edited 1 time in total.
ron_h
Level 3
Level 3
 
Posts: 180
Joined: Tue Apr 15, 2014 7:03 am
Location: Sydney, NSW, AU

Linux Mint is funded by ads and donations.
 

Re: Copy complete partition, keep destination UUID ?

Postby eanfrid on Sat Jun 21, 2014 3:56 am

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.
Main desktop: Debian GNU/Linux Wheezy 64bit w/custom 3.14 longterm kernel - MATE 1.8.1
(i5 2400@3.7GHz - 16GB DDR3 - HD6770 w/radeon driver - SSD+RAID1)
True private storage on SpiderOak
User avatar
eanfrid
Level 7
Level 7
 
Posts: 1784
Joined: Mon Apr 30, 2012 2:49 am
Location: FR

Re: Copy partition, keep destination UUID ?

Postby ron_h on Sat Jun 21, 2014 5:20 am

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 3
Level 3
 
Posts: 180
Joined: Tue Apr 15, 2014 7:03 am
Location: Sydney, NSW, AU

UUID in any file other than /etc/fstab ?

Postby ron_h on Sat Jun 21, 2014 5:27 am

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 3
Level 3
 
Posts: 180
Joined: Tue Apr 15, 2014 7:03 am
Location: Sydney, NSW, AU

Re: Copy partition, keep destination UUID ?

Postby ron_h on Sat Jun 21, 2014 5:38 am

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
ron_h
Level 3
Level 3
 
Posts: 180
Joined: Tue Apr 15, 2014 7:03 am
Location: Sydney, NSW, AU

Re: Copy partition, keep destination UUID ?

Postby Fnux on Sat Jun 21, 2014 10:49 pm

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.
ASUS Sabertooth 990FX - AMD FX8150 8 cores @ 4.2 Ghz - 32 Mb DDR3 - SSD 240 Gb - HDD 3 Tb - 2 x 1920x1080
Image
User avatar
Fnux
Level 1
Level 1
 
Posts: 14
Joined: Mon Aug 19, 2013 10:32 am
Location: Palm Beach, Florida, USA

Re: Copy partition, keep destination UUID ?

Postby ron_h on Sun Jun 22, 2014 3:48 am

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
ron_h
Level 3
Level 3
 
Posts: 180
Joined: Tue Apr 15, 2014 7:03 am
Location: Sydney, NSW, AU

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: No registered users and 4 guests