disk cloning with dd -howto?

Hi all,
This question came up before in various circumstances. i read some threads but I do not fully understand the suggestions - or perhaps i am somewhat hesitant to edit whatever was suggested in order not to destroy my operating system.

Essentially, i would like to be able to clone an entire disk with the dd command but the newly created disk does not want to boot because of a disk- id issue. Obviously the source and destination disk, while being the same size, are not the same brand.

What runs here is a version 11.2 64 bits. I do have two disk racks on the pc to facilitate cloning. My aim is to make an exact copy of the current O/S and then update the cloned copy with version 11.3 to ascertain proper upgrading.

Given the long preamble above, I am looking for some good soul to describe the process as to what needs to be edited and with what package (yast or otherwise) so that dd will achieve the desired results. there may be other cloning apps out there like clone zilla but they appear to depend on this disk-id issue as well - IMHO.

Thank you very kindly in advance for taking time to read this and reply to it

-hr

dd makes a bit for bit copy of everything.
If you are cloning the os, you need to edit the boot menu and fstab and replace the disk by id references for the drive with something like /dev/sdx where x is the drive number.

On Fri, 16 Jul 2010 22:26:01 +0000, ve3fd wrote:

> Given the long preamble above, I am looking for some good soul to
> describe the process as to what needs to be edited and with what package
> (yast or otherwise) so that dd will achieve the desired results. there
> may be other cloning apps out there like clone zilla but they appear to
> depend on this disk-id issue as well - IMHO.

The disk-ID issue isn’t a cloning issue, but rather a configuration
issue. By default, openSUSE mounts partitions by ID rather than by
device.

When cloning a disk, the easiest solution that I’ve read is to switch to
mounting the partitions by device rather than by ID (since the ID is tied
to the hardware and the device name isn’t).

There’s a setting in the YaST partitioner that should take care of this -
look under “settings”.

You can also do this manually by modifying the /etc/fstab file, but make
sure you get things set up properly or you’ll find that the system won’t
boot.

A third option is to clone the drive as-is and modify the fstab file on
the cloned drive before booting it - that is safer, just mount the cloned
drive’s root partition someplace and make the changes (either to use by
ID or by device, you’ll just need to identify either as /dev/sdaX or
whatever).

Jim

Jim Henderson
openSUSE Forums Administrator

…or you could fire up a live system and check /dev/disk/by-id/ and replace the respective line in /etc/fstab.

ve3fd wrote:

> Given the long preamble above, I am looking for some good soul to
> describe the process as to what needs to be edited and with what
> package (yast or otherwise) so that dd will achieve the desired
> results.

Unless you’re keen on dd for a reason, I would just use tar or cpio, it
works very well.


Per Jessen, Zürich (21.2°C)
http://en.opensuse.org/User:Pjessen

Thank you very kindly Jim for your expert advice. I have looked at Yast and the disk partitioner application. The setting is currently set by ‘Device ID’. There are other possibilities such as Volume label, Device Path and UUID. Should I choose ‘Decice Path’ ? Again, I am rather cautious about this since i depend on Suse 11.2 and no longer on Windoze. In the past I always upgraded to new versions by way of ‘new installation’. Now I want to try upgrading over an existing installation.

Looking forward to your reply.
Sincerely,
Heribert Riesbeck

This is similar to Jim Hendersons suggestion. Thank you very much for you reply. I will try the Yast route to edit fstab and wait Jim reply to my follow up question.

Yes Per there are all sorts of possibilities out there including clone zilla which I tried. But I like to go by what the system offers as this seems to me the safest way for there is more to live than play with Linux all the time. It is summer here in Canada and I want to go biking from time to time.

-hr

ve3fd wrote:

>
> Yes Per there are all sorts of possibilities out there including clone
> zilla which I tried. But I like to go by what the system offers as
> this seems to me the safest way

tar is probably one of the safest/most used.


Per Jessen, Zürich (19.7°C)
http://en.opensuse.org/User:Pjessen

Well Per, out of curiosity and for the sake of learning new things, how is it done given my hardware setup described earlier and will it circumvent the disk-ID issue? Does the fstab file still need to be edited?

Heribert Riesbeck

ve3fd wrote:

> Well Per, out of curiosity and for the sake of learning new things,
> how is it done given my hardware setup described earlier and will it
> circumvent the disk-ID issue? Does the fstab file still need to be
> edited?
>
> Heribert Riesbeck

Hi Heribert

Using tar (or cpio), you copy everything on the filesystem level, file
by file. The underlying disk structure is not important. Yes, you will
need to amend certain config files, for instance if you mount disks by
id. In a situation where you expect to clone or copy an entire system,
maybe mounting by label is a better idea.

I maintain a number of remote systems (that I have never even seen). I
have one reference system, which I have a tarred copy of. Whenever I
need to set up a new server, I boot up a rescue system on it, copy over
the tar-file and untar it to the new filesystem(s). Then I chroot to
the new system and change whatever config I need (usually ip-addresses
and hostname). Then I run lilo, and boot it up.


Per Jessen, Zürich (17.9°C)
http://en.opensuse.org/User:Pjessen

On Sat, 17 Jul 2010 13:16:01 +0000, ve3fd wrote:

> I have looked at Yast
> and the disk partitioner application. The setting is currently set by
> ‘Device ID’. There are other possibilities such as Volume label, Device
> Path and UUID. Should I choose ‘Decice Path’ ?

Do you not have a “Device Name” option? In YaST for me (on GNOME) it’s
the first option in the list.

Jim


Jim Henderson
openSUSE Forums Administrator

On Sat, 17 Jul 2010 07:36:03 +0000, Per Jessen wrote:

> ve3fd wrote:
>
>> Given the long preamble above, I am looking for some good soul to
>> describe the process as to what needs to be edited and with what
>> package (yast or otherwise) so that dd will achieve the desired
>> results.
>
> Unless you’re keen on dd for a reason, I would just use tar or cpio, it
> works very well.

With the caveat that the extracted system isn’t bootable - it seems he
wants to clone the disk so he can boot from it and upgrade in-place, tar
or cpio won’t leave him with a bootable system.

Might also create some issues in crossing filesystem boundaries - if he
starts from /, for example, he’ll end up (by default) pulling in /proc
and /dev, which wouldn’t be desirable.

Jim


Jim Henderson
openSUSE Forums Administrator

Jim Henderson wrote:

> On Sat, 17 Jul 2010 07:36:03 +0000, Per Jessen wrote:
>
>> ve3fd wrote:
>>
>>> Given the long preamble above, I am looking for some good soul to
>>> describe the process as to what needs to be edited and with what
>>> package (yast or otherwise) so that dd will achieve the desired
>>> results.
>>
>> Unless you’re keen on dd for a reason, I would just use tar or cpio,
>> it works very well.
>
> With the caveat that the extracted system isn’t bootable - it seems he
> wants to clone the disk so he can boot from it and upgrade in-place,
> tar or cpio won’t leave him with a bootable system.

It does take a little more effort, that is true. I still find it to be
a lot better/easier than dd when we’re talking about entire systems.

> Might also create some issues in crossing filesystem boundaries - if
> he starts from /, for example, he’ll end up (by default) pulling in
> /proc and /dev, which wouldn’t be desirable.

Sure, I didn’t provide a ready-to-go-just-add-water recipe. Brains are
required.


Per Jessen, Zürich (17.9°C)
http://en.opensuse.org/User:Pjessen

working well for this purpose: fsarchiver

On Sat, 17 Jul 2010 17:05:33 +0000, Per Jessen wrote:

> Jim Henderson wrote:
>
>> On Sat, 17 Jul 2010 07:36:03 +0000, Per Jessen wrote:
>>
>>> ve3fd wrote:
>>>
>>>> Given the long preamble above, I am looking for some good soul to
>>>> describe the process as to what needs to be edited and with what
>>>> package (yast or otherwise) so that dd will achieve the desired
>>>> results.
>>>
>>> Unless you’re keen on dd for a reason, I would just use tar or cpio,
>>> it works very well.
>>
>> With the caveat that the extracted system isn’t bootable - it seems he
>> wants to clone the disk so he can boot from it and upgrade in-place,
>> tar or cpio won’t leave him with a bootable system.
>
> It does take a little more effort, that is true. I still find it to be
> a lot better/easier than dd when we’re talking about entire systems.

Certainly using dd depends on the target drive being at least the same
size as the original and not having any bad blocks to get in the way.

>> Might also create some issues in crossing filesystem boundaries - if he
>> starts from /, for example, he’ll end up (by default) pulling in /proc
>> and /dev, which wouldn’t be desirable.
>
> Sure, I didn’t provide a ready-to-go-just-add-water recipe. Brains are
> required.

:slight_smile:

Jim


Jim Henderson
openSUSE Forums Administrator

On 2010-07-17 13:26 GMT ve3fd wrote:

>
> This is similar to Jim Hendersons suggestion. Thank you very much for
> you reply. I will try the Yast route to edit fstab and wait Jim reply
> to my follow up question.

Careful: you have to edit the copy, not the original. YaST will offer
only the original, ie, the running copy. If you change the the original
11.2 it might become non bootable.

Assuming you have both disks on the same computer, run this:

ls -l /dev/disk/by-id/

This will list all the present disks ID’s, for the original and the
copy. (1)

Now you have to mount the copied disk main partition somwhere, and
manually edit its fstab file, replacing the old ID’s by the new ID’s,
by looking at the list above.

After this, you have to do something similar with /boot/grub/* files -
on the copy.

Notice that there are four valid method to address partitions:

by-id/ by-label/ by-path/ by-uuid/

Just do not use the traditional method, /dev/sda, sdb, sdc… these
names are dynamic, may change from one boot to another, on some systems.

Each of the methods above have their advantages and problems. You just
saw the problem of ID when cloning.

(1) If the list produces the same IDs on both original and clone, then
I made a mistake (I can confuse ID with UUID). One depends on the
hardware, the other is created with the mkfs tool. In that case you can
change the IDs, then proceed with the rest of the procedure. Or switch
to another of the four methods.

If in doubt, ask :wink:


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Minas Tirith))

Yes I do have this. Sorry, my mistake.
-hr

On Mon, 19 Jul 2010 18:16:02 +0000, ve3fd wrote:

> Yes I do have this. Sorry, my mistake. -hr

No problem - that’s the option I’d select. Then double-check the /etc/
fstab file afterwards and make sure the disk is being mounted by device
name rather than the ID.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

About an hour ago and before my buddy called me for coffee ( I am retired and meet regularly with like minded cronies) I wrote a lengthy message to inform you as to what I have done sofar. But after hanging up the phone I may have lost the message somhow. Here is a short synopsis.

  1. I went out to buy a new HD and installed 11.2 on it. I have two slide in HD racks in my PC so copying should be easy.
  2. I tried just about all fstab options, including Device Name and looked at the changes in the fstab file and made dd copies with the respective options. None worked, that is the copy did not want to boot. All copies displayed the same message as follows: /dev/disk/by-id/ata-ST35048AS_6VM0G4TI-part2. In addition the message queried (y/n) to fall back to this drive which incidentally is the source drive. y or n did not make a difference it wanted this drive. Essentially, I was presented with the $ shell symbol.

So , my observation is that changing fstab does not make a difference.

  1. I found the above message text in the boot script.
  2. Various replies in this tread - some quite witty - suggest to mount the copied drive (destination drive) and make changes there - somehow. My question is how. Yes I can physically run both drives concurrently and only the source drive, aka known as sda, will boot.

Actually, I could just upgrade 11.2 to 11.3 on my newly created O/S but this will be fairly non conclusive since all the files of my actual O/S are not present in the update. It actually irks me that I do not succeed. Some years ago I was able to successfully disk image with Acronis. However they currently do not recognize the the new file systems. For megabucks they have Linux capable software which is simply out of my reach.
Thus, I will spend a few mor hours on this. If there is no satisfactory solution I will drop it and eventually 11.3 from scratch.

-hr