Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
problem restoring clonned image, other options?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sat May 25, 2013 6:08 pm    Post subject: problem restoring clonned image, other options? Reply with quote

hi,

I've cloned a disk but the partitions are messy. It's possible to make it better with ntfsclone. However this way the mbr is missing.

When I try to dd the mbr into the lvm 'drive' either offline or booted into a VM the volume brakes. I don't understand how windows installs itself without breaking lvm volume. Manually dd'ing the mbr brakes lvm somehow.

I am talking about this:

Code:
dd if=/dev/sdd of=/dev/lvm/windoze bs=512 count=1


I need the two original partitions of m$$.

I was doing this way since ntfsclone is mightly efficient. I can ntfsclone -r -O both partitions but without the mbr this is an excersise in vain.

Anyone have clues for a workaround?

Does LVM have any type of built-in tools to clone a disk directly into an LVM partition? Since this doesn't work either:

Code:
dd if=/dev/sdc of=/dev/lvm/windoze


By the way dd'ing into a hard drive works fine. The problem lies within LVM. Possibly it overwrites some metadata. Would be nice if LVM could store it's info outside the volume's device so as to treat an LVM device name, '/dev/lvm/volume', as a hard drive exclusively.

An alternative option is whether m$$ got tools with the repair disk to retreate the bootloader and partition layout.

If not, could grub boot into an m$$ partition directly?
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Sun May 26, 2013 4:32 am    Post subject: Reply with quote

As far as I know, LVM isn't designed to store entire disk images, but rather individual partitions. There's no reason you *can't* use LVM like that, but I think you will have to use loop devices in order to make linux see partitions inside.

My advice, use ntfsclone for backup/restore of ntfs filesystems (it will faithfully preserve a filesystem at least!), dd the mbr manually (and include the whole area before the first partition, some copy protections and extra bootloaders need this), and keep in mind the partition table is only part of the MBR, so you can backup/restore it separately if you need to.

partprobe (part of parted package I think?) can tell the kernel to rescan partitions after you load a new mbr, useful for scripting.

LVM doesn't store metadata inside volumes, that would be insane. It's stored inside the host device.
Back to top
View user's profile Send private message
vaxbrat
l33t
l33t


Joined: 05 Oct 2005
Posts: 731
Location: DC Burbs

PostPosted: Sun May 26, 2013 5:06 am    Post subject: You are clobbering the partition table using 512 Reply with quote

The mbr actually has both the boot code and the partition table in it. See the following to get dd to just do the boot code:


http://www.cyberciti.biz/faq/howto-copy-mbr/
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54096
Location: 56N 3W

PostPosted: Sun May 26, 2013 10:22 am    Post subject: Reply with quote

_______0,

Its not just the MBR you are missing, thats only LBA 0. Its all the other blocks outside of the filesystems and before the first partition, where parts of the bootloader live. These need to be restored too.

e.g. the grub stage1.5 goes into LBA 1..22 (approx) The windows boot loader does something similar, so you need that space too, if you want it to boot.

To recover the data, you can mount the partitions inside the image, once you know where they start. That can be recovered from the partition table which you are dding to sector 0.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Sun May 26, 2013 6:14 pm    Post subject: Reply with quote

Oh wow I didn't realize the windows bootloaders did stuff like that, maybe that explains why one system I tried to clone wouldn't boot...
Back to top
View user's profile Send private message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sun May 26, 2013 7:23 pm    Post subject: Reply with quote

if metadata is stored outside the volume device file why dd'ing into it brakes it?

I didn't get a clear answer. Anyone curious try the experiment.

By lvm utility I meant that lvm could have a utility to clone a physical disk onto a volume adjusting whatever it needs automagically.

In certain scenarios it's useful to use an LVM as raw disk for VM's, mainly for speed.

There's also the problem that there isn't an easy way to make a one-to-one copy of a partition. It'd be nice this:

cp /dev/sda1 /dev/sdb1

Without having to worry about manually creating a partition on sdb in advance to fit the copy.

thanks
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54096
Location: 56N 3W

PostPosted: Mon May 27, 2013 5:47 pm    Post subject: Reply with quote

_______0,

In what way does the logical volume break?

When you dd to logical block 0, you overwrite any partition table that might have been there, unless you take special care not to.
If you have a disk image, then restoring it to a logical volume should work as long as you treat that volume as a disk.

If you have partition images but missing the space outside of the partitions, it gets harder.
You need a suitable partition table to allocate the space to dd the partition images. You also need the boot loader that goes in the space before the first partition if you hope to boot the restored image.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sat Jun 08, 2013 5:19 pm    Post subject: Reply with quote

NeddySeagoon wrote:
In what way does the logical volume break?


kpartx is unable to map the lvm volume this way.

why?
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Sat Jun 08, 2013 8:01 pm    Post subject: Reply with quote

You're not by chance trying to present two copies of the same LVM physical volume to linux at the same time? I don't think it would like that.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54096
Location: 56N 3W

PostPosted: Sun Jun 09, 2013 9:02 am    Post subject: Reply with quote

using dd to make a whole disk image works for me.

I've made an image of my work laptop, which is about to get 'upgraded' from XP to Win7.
I was surprised to find that XP boots as it was intstalled on an Intel CPU and now its on an AMD.
I guess WinXP was made for i586.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum