[opensuse] booting from a duplicated hard disk
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-b... 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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Sampsa Riikonen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Things which must be accounted for: Is the drive in the same interface? If you are still in the SATA box trying to boot to USB the initrd will probably not have the drivers needed. 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. Have you corrected the disk ID in /boot/grub/device.map, /etc/fstab, and /boot/grub/menu.lst, if any are specified using /dev/disk/by-id/ instead of devices like /dev/sda1 etc? -----Original Message----- From: Per Jessen [mailto:per@opensuse.org] Sent: Thursday, December 30, 2010 10:11 AM To: opensuse@opensuse.org Subject: Re: [opensuse] booting from a duplicated hard disk Sampsa Riikonen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thu, Dec 30, 2010 at 1:21 PM, Norm Mackey <norm@enterprisewizard.com> wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 12/30/2010 12:11 PM, Per Jessen wrote:
Sampsa Riikonen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
David C. Rankin wrote:
On 12/30/2010 12:11 PM, Per Jessen wrote:
Sampsa Riikonen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 2010/12/31 09:59 (GMT+0100) Per Jessen composed:
Sampsa Riikonen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Felix Miata wrote:
On 2010/12/31 09:59 (GMT+0100) Per Jessen composed:
Sampsa Riikonen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
2010. december 30. 18:06 napon Sampsa Riikonen <sampsa.riikonen@iki.fi> írta:
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-b... 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
Hello: Earlier I also cloned hard disks and also had problems with booting the clones. I don't see what can be the problem in your case but it still may help how I made it finally: 1. Use a live system like knoppix os similar for cloning the image. 2. After the cloning boot your original OS (not the cloned one), mount the cloned partition somewhere and edit the files on it: /boot/grub/menu.lst, /etc/fstab (on the cloned partition!) I found easier to manage hard disk partitions by their device IDs. You can find it out by $ ls -l /dev/disk/by-id I replaced the hard disk partition names (eg /dev/hda, sda) by device ID names. 3. You also might have to make a new initrd image, as boot partitions are hard coded in it. see: http://lists.opensuse.org/opensuse/2010-01/msg00588.html extract from the above message: mount /target_partition. mount --bind /proc /target_partition/proc mount --bind /sys /target_partition/sys mount --bind /dev /target_partition/dev chroot /target_partition (Those directories (proc, sys, dev) in the target should be empty before the binding.) Run mkinitrd. 4. Probably you have to install grub again onto the newly cloned root partiton, I guess still in the chroot-ed enviroment: # grub
root (hd0,0) setup --force-lba (hd0,0) (hd0,0) quit
Assumed you don't have a separate /boot partiton. Maybe this helps. Cheers, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
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. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Sunday, January 02, 2011 06:04:51 am Andrew Joakimsen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
C. Brouerius van Nidek wrote:
On Sunday, January 02, 2011 06:04:51 am Andrew Joakimsen wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Monday, January 03, 2011 03:00:04 pm Per Jessen wrote:
C. Brouerius van Nidek wrote:
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+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (9)
-
Andrew Joakimsen
-
C. Brouerius van Nidek
-
David C. Rankin
-
Felix Miata
-
Istvan Gabor
-
John Lange
-
Norm Mackey
-
Per Jessen
-
Sampsa Riikonen