Discussion:
booting from a duplicated hard disk
(too old to reply)
Sampsa Riikonen
2010-12-30 17:06:54 UTC
Permalink
Dear List,

I have duplicated my hard disk using "dd", including the boot partition to
another hard disk (a sata drive in a usb box). Now I am trying to boot from
this duplicated disk, but nothing happens.. grub does not start at all.

I googled around and found these two posts:

http://www.idlecool.net/how-to-clone-the-linux-root-file-system-and-set-up-boot-loader/
http://stackoverflow.com/questions/247030/

Based on those, I tried the following:

1) My current (original) root partition is "/dev/sda4" (mounted at "/")

2) The root partition at the (duplicated) usb drive is "/dev/sdb4",
mounted at "/media/disk-17"

3) I login as the root and give the commands

mount --bind /dev /media/disk-17/dev
mount --bind /proc /media/disk-17/proc

4) Then I give the command

chroot /media/disk-17

If I have understood correctly, now "/" will be "/media/disk-17" = "/dev/sdb4"
But the system sees "/" as "/dev/sda4"

Next I type:

grub-install /dev/sda

And get the following output:

--------------------------------
Probing devices to guess BIOS drives. This may take a long time.


GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> setup --stage2=/boot/grub/stage2 --force-lba (hd0,3) (hd0,3)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0,3)"... failed (this is not
fatal)
Running "embed /boot/grub/e2fs_stage1_5 (hd0,3)"... failed (this is not
fatal)
Running "install --force-lba --stage2=/boot/grub/stage2 /boot/grub/stage1
(hd0,3) /boot/grub/stage2 p /boot/grub/menu.lst "... failed

Error 15: File not found
grub> quit
------------------------------------------

What might be the problem here..?

Regards,

Sampsa

"Growth for the sake of growth is the ideology of a cancer cell."
-- Edward Abbey
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Felix Miata
2010-12-31 12:51:32 UTC
Permalink
Post by Sampsa Riikonen
I have duplicated my hard disk using "dd", including the boot
partition to another hard disk (a sata drive in a usb box). Now I
am trying to boot from this duplicated disk, but nothing happens..
grub does not start at all.
True - personally I don't use dd for copying drives unless I have a
specific need for that. Copying filesystems with tar or rsync is
easier and less hassle - I do it fairly frequently to clone systems
(that almost never have the same drives).
Apparently your definition of "clone" doesn't match the true meaning of the
word. Sampsa used dd, which makes a true clone of the whole device, Grub,
device label, UUID & all. Copying filesystems with rsync or tar is never true
cloning, as they are file-based copy programs, not bit/sector by bit/sector
copiers.

OTOH, a true clone from one device type (HD) to another (USB stick, or HD
attached via USB) would only in a very unusual case be expected to actually
boot without first accounting for device type differences and implementing
required customizations/reinstallation in/of initrd, fstab &/or Grub, or
removing the HD from its USB enclosure and attaching it natively.

Only yesterday I was vexed for quite some time by an apparent partition to
partition clone failure, until I realized I had only adapted UUID, label,
menu.lst and fstab, while Grub on the clone was still pointing to the source
partition. Two lines typed from a Grub prompt, and all was well with the
former clone.

To expect a true clone (e.g. via dd) of a HD to work without any
modifications to the target, the usual case requires that the original be
entirely deinstalled, and the clone installed in its place.
--
"The wise are known for their understanding, and pleasant
words are persuasive." Proverbs 16:21 (New Living Translation)

Team OS/2 ** Reg. Linux User #211409

Felix Miata *** http://fm.no-ip.com/
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Per Jessen
2010-12-30 18:11:04 UTC
Permalink
Post by Sampsa Riikonen
Dear List,
I have duplicated my hard disk using "dd", including the boot
partition to another hard disk (a sata drive in a usb box). Now I am
trying to boot from this duplicated disk, but nothing happens.. grub
does not start at all.
Hi Sampsa

using dd for copying a harddisk assumes source and target are the same,
which I am guessing yours are not. You might fare better by copying
across the contents of the filesystem(s), e.g. using rsync, and
(re-)preparing the target drive for booting.
--
Per Jessen, Zürich (0.0°C)
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Per Jessen
2010-12-31 08:59:30 UTC
Permalink
Post by Per Jessen
Post by Sampsa Riikonen
Dear List,
I have duplicated my hard disk using "dd", including the boot
partition to another hard disk (a sata drive in a usb box). Now I
am trying to boot from this duplicated disk, but nothing happens..
grub does not start at all.
Hi Sampsa
using dd for copying a harddisk assumes source and target are the
same,
which I am guessing yours are not. You might fare better by copying
across the contents of the filesystem(s), e.g. using rsync, and
(re-)preparing the target drive for booting.
Well that depends...
Using dd will copy the filesystems/partitions from one device to
another. dd should work without an issue as long as the target drive
is greater or equal to the size of the source.
True - personally I don't use dd for copying drives unless I have a
specific need for that. Copying filesystems with tar or rsync is
easier and less hassle - I do it fairly frequently to clone systems
(that almost never have the same drives).
--
Per Jessen, Zürich (1.9°C)
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
John Lange
2010-12-30 21:24:41 UTC
Permalink
Is the drive as large or larger than the old drive (you can clone the
whole old drive to a larger one, you end up losing the remaining
space unless you add a partition. Cloning first 512 bytes copies boot
sector and partition table.  Often I delete and recreate the last
partition afterwards to fill the remaining storage space, then copy
the contents using "cp -a /{olddiskmountpoint}/* /{newdiskmountpoint}/"
in rescue mode.
Alternatively, just make the partition larger and then grow the file
system using resize2fs. If you are expanding the file system you can
even do it on mounted partitions including "/" and this is *way*
faster than a complete re-copy (like 10 seconds).

For anyone reading this who hasn't done much with partitions, in
"fdisk" you can actually delete then recreate the partition to enlarge
it and this is perfectly data safe (as long as the starting point for
the partition remains the same which it will unless you do something
stupid). Tools like cfdisk allow you to "edit" the partition to make
it bigger but in reality it does the same thing.
--
John Lange
www.johnlange.ca
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
David C. Rankin
2010-12-30 20:51:37 UTC
Permalink
Post by Per Jessen
Post by Sampsa Riikonen
Dear List,
I have duplicated my hard disk using "dd", including the boot
partition to another hard disk (a sata drive in a usb box). Now I am
trying to boot from this duplicated disk, but nothing happens.. grub
does not start at all.
Hi Sampsa
using dd for copying a harddisk assumes source and target are the same,
which I am guessing yours are not. You might fare better by copying
across the contents of the filesystem(s), e.g. using rsync, and
(re-)preparing the target drive for booting.
Well that depends...

Using dd will copy the filesystems/partitions from one device to another. dd
should work without an issue as long as the target drive is greater or equal to
the size of the source. If you want to grow the file system after the dd copy,
the copy a partition, then use gparted (or the like) to grow the partition
before copying the next one.

I have successfully moved Linux installs, windows installs and virtualbox VDI's
that way. After you move the partitions to a new disk, you still may need to
boot with the install disk because the grub device designations will surely have
changed. (/dev/disk/by-id, etc..)

Here are my notes for 'dd copy MBR and/or Partition Table'

MBR is divided into 3 sections:

1. Bootstrap . 446 bytes
2. Partition table. 64 bytes
3. Signature. 2 bytes

Copy MBR & Partition Table: (only for same sized partitions)

dd if=/dev/sda of=/dev/sdb bs=512 count=1

Copy MBR only:

dd if=/dev/sda of=/dev/sdb bs=446 count=1

Make a backup first:

Here’s what I do to copy just the MBR from a hdd:

dd if=/dev/sda of=mbrbackup bs=512 count=1

Now to restore the image to any hdd:

dd if=mbrbackup of=/dev/sdb bs=446 count=1

Backing up and restoring the MBR and boot sector(s):

It is very easy to back up these essential parts of your disk. You will need
to copy (part of) the MBR, and boot sectors in order to have your new system
boot like the old one.

To save the MBR to a file (this contains the partition table too):

dd if=/dev/hda of=hda-mbr-full bs=512 count=1

To save the MBR, without the partition table, to a file:

dd if=/dev/hda of=hda-mbr-nopart bs=446 count=1

To save a boot sector (e.g. partition 3) to a file:

dd if=/dev/hda3 of=hda3-bootsect bs=512 count=1

Good luck :p
--
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Per Jessen
2010-12-31 13:47:42 UTC
Permalink
Post by Felix Miata
Post by Sampsa Riikonen
I have duplicated my hard disk using "dd", including the boot
partition to another hard disk (a sata drive in a usb box). Now
I am trying to boot from this duplicated disk, but nothing
happens.. grub does not start at all.
True - personally I don't use dd for copying drives unless I have a
specific need for that. Copying filesystems with tar or rsync is
easier and less hassle - I do it fairly frequently to clone systems
(that almost never have the same drives).
Apparently your definition of "clone" doesn't match the true meaning
of the word. Sampsa used dd, which makes a true clone of the whole
device, Grub, device label, UUID & all. Copying filesystems with rsync
or tar is never true cloning, as they are file-based copy programs,
not bit/sector by bit/sector copiers.
Thanks for explaining that, Felix, I really didn't know.
--
Per Jessen, Zürich (3.2°C)
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
C. Brouerius van Nidek
2011-01-03 05:27:54 UTC
Permalink
I didn't read any of the responses...
Assuming you had a default openSUSE installation and assuming that you
did clone the disk properly, all you need to do is edit
/boot/grub/menu.lst and /etc/fstab to reflect your new hard drive.
openSUSE for a while uses /dev/disk/by-id/ instead of e.g. /dev/sda.
This is good and bad, you can move your disk to any other computer and
it will boot but because /dev/disk/by-id/ contains your hard drive
model and serial number if you clone the drive it will not boot until
you update these two files.
Found this an interesting topic. Was already planning to clone my workhorse Suse
11.3 to another hd. Have a small additional question.
I have several mounted partitions on this 11.3 and found out that if I start
copying these mount points seem to be copied in total to the clone. E.g., I have
my /home on a separate partition and would like to let point /home from the
clone to this same /home. How could this be done with dd or midnight commander
(my favorite) or rsync?
--
Linux User 183145 using LXDE on a Pentium IV ,
powered by openSUSE 11.3 (i586) Kernel: 2.6.37-rc8-desktop
LXDE WM & KDE Development Platform: 4.5.4 (KDE 4.5.4) "release 9"
12:20pm up 20:56, 4 users, load average: 0.81, 0.97, 1.07
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Per Jessen
2011-01-03 08:00:04 UTC
Permalink
Post by C. Brouerius van Nidek
I didn't read any of the responses...
Assuming you had a default openSUSE installation and assuming that
you did clone the disk properly, all you need to do is edit
/boot/grub/menu.lst and /etc/fstab to reflect your new hard drive.
openSUSE for a while uses /dev/disk/by-id/ instead of e.g. /dev/sda.
This is good and bad, you can move your disk to any other computer
and it will boot but because /dev/disk/by-id/ contains your hard
drive model and serial number if you clone the drive it will not boot
until you update these two files.
Found this an interesting topic. Was already planning to clone my
workhorse Suse 11.3 to another hd. Have a small additional question.
I have several mounted partitions on this 11.3 and found out that if I
start copying these mount points seem to be copied in total to the
clone. E.g., I have my /home on a separate partition and would like to
let point /home from the clone to this same /home. How could this be
done with dd or midnight commander (my favorite) or rsync?
dd - not a problem.
rsync - use the -x switch.
--
Per Jessen, Zürich (0.8°C)
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
C. Brouerius van Nidek
2011-01-03 09:11:42 UTC
Permalink
Post by Per Jessen
Post by C. Brouerius van Nidek
clone. E.g., I have my /home on a separate partition and would like to
let point /home from the clone to this same /home. How could this be
done with dd or midnight commander (my favorite) or rsync?
dd - not a problem.
rsync - use the -x switch.
Thanks, dd works as a charm.
--
Linux User 183145 using LXDE on a Pentium IV ,
powered by openSUSE 11.3 (i586) Kernel: 2.6.37-rc8-desktop
LXDE WM & KDE Development Platform: 4.5.4 (KDE 4.5.4) "release 9"
16:10pm up 1 day 0:46, 6 users, load average: 3.04, 1.40, 1.08
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Loading...