Clonezilla clone won't boot without reinstalling grub2
Solution 1
In the end, I resolved this by taking a partition clone of the original machine's boot partition and installing this on the other machines with "-j1" selected from the advanced options.
Slightly annoying to have the extra step, but at least restoring a clone of the boot partition only takes seconds.
Solution 2
The working procedure to fix this we have to manually install GRUB(2) after a failed installation/cloning, or disk corruption of the MBR.
Now, after restarting, let's fix the grub boot:
sh:grub>set pager=1 # for paging long command outputs; There must be no spaces on either side of the equals sign.
grub> set root=(hd0,XY)
'grub> insmod /boot/grub/linux.mod # AFAIK, optional step
grub> linux /boot/vmlinuz-4.4.92-36-default root=/dev/sdaXY
grub> initrd /boot/initrd.img-4.4.92-36-default
grub> boot
After successfully booting into your Linux, let's make the repair permanent:
# update-grub
# grub-install /dev/sda #or what ever your system disk is
if you get the error update-grub command not found
don't worry, it's simply a shell script that was created to make things easier. Acutally, it does:
set -e
exec grub2-mkconfig -o /boot/grub/grub.cfg "$@"
After running grub-install ... your system should be back to normal. I did this with a cloned OpenSuse Leap 42.2 using Clonezilla 2016-02-10 (migrated primary laptop disk to a bigger SSD).
Refs: How to Rescue a Non-booting GRUB 2 on Linux
Repairing a Broken GRUB 2 Boot-Loader on Ubuntu
Here is an alternative approach that works without booting into Linux:
$ sudo fdisk -l (From this you need to find the device name of your physical drive that won't boot, something like “/dev/sdxy″ - where x is the drive and y is the root partition. Since I was using a software RAID, root (/) was on md1)
$ sudo mount /dev/sdxy /mnt (Mount the root partition)
$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys
$ sudo chroot /mnt (This will change the root of executables to your your drive that won't boot)
$ grub-mkconfig -o /boot/grub/grub.cfg (insure that there are NO error messages)
$ grub-install /dev/sdx (NOTE that this is the drive and not the partition. try grub-install --recheck /dev/sdxy if it fails)
Ctrl+D (to exit out of chroot)
$ sudo umount /mnt/dev
$ sudo umount /mnt/proc
$ sudo umount /mnt/sys
$ sudo umount /mnt
Ref: http://redsunsoft.com/2016/06/how-to-repair-a-server-stuck-at-the-grub-prompt/
Related videos on Youtube
Comments
-
jam over 1 year
I've taken a clone of a machine with the following partitions:
Device Type Label /dev/sda /dev/sda1 Ext4 boot /dev/sda2 Linux LVM /dev/system/ LV system /dev/system/home LV home /dev/system/root LV root /dev/system/swap LV swap
These are referenced by label in
/etc/fstab:
LABEL=root / ext4 LABEL=boot /boot ext4 LABEL=home /home ext4 LABEL=swap /swap swap
and grub.cfg:
menuentry 'openSUSE, with linux <version>' --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-<version>-simple-<UUID>' { insmod ext2 set root='hd0,msdos1' linux /vmlinuz-<version> root=/dev/mapper/system-root resume=/dev/disk/by-label/swap <other options> initrd /initrd-<version> }
I am trying to install this clone on another identical machine. The install succeeds, but I can't boot into the machine without doing the following in the grub prompt it dumps me into:
grub> set root=(hd0,1) grub> linux /boot/vmlinuz-<version> root=/dev/sda1 grub> initrd /boot/initrd.img-<version> grub> boot
I'd much prefer to get an image which does not require these steps, but I'm not sure where the problem lies (grub config, other system files, clonezilla). Things I have tried so far:
- Edited /etc/defaults/grub and uncommented '
GRUB_DISABLE_LINUX_UUID=true
' - Edited grub-mkconfig_lib to comment out the lines like
search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}
to prevent them being added when grub.cfg is generated - (and re-generated
grub.cfg
) - Selected advanced clonezilla install and told it to re-install the MBR afterwards (option -j1. option -g auto "Reinstall grub in client disk MBR" was already selected by default)
Any other things I can try?
I did notice that
/boot/grub2/device.map
lists "sda1" for hd0, but the HD of the other machine is being detected as sda1 when I install the clone so I don't think this is likely to be the culprit.(I wasn't sure if here or Superuser was the better fit for the question, I am happy for it to be migrated as appropriate.)
-
jc__ almost 7 yearsIn my experience (limited to BIOS not LVM and partition clone not disk clone) when restoring image Clonezilla runs grub-install automatically fixing UUID and other. A little more info may help: What version of Clonezilla? Did you clone the disk or just the partition? Were there any errors on the restore, particularly in the grub-install part?
-
jam almost 7 yearsVersion of clonezilla: 20170220-yakkety. Cloned the entire disk, also tried both with the partimage and dd options when making the clone. Re-running the install now I did see a "couldn't find device uuid" mesage scroll past briefly before the partclone screen appeared, but couldn't get all the details in time. No errors were listed in the output once install had finished.
-
jc__ almost 7 yearsI am working with a much older version, but this is the selections Ive used to get the grub-install called automatically: (device-image) (local_dev or where ever) (Beginner) (saveparts) (...). Then the reverse for restoring the image. (device-image) (local_dev or where ever) (Beginner) (restoreparts).
-
jc__ almost 7 yearsLook at my answer here for a quick how to clone using Clonezilla in the Parted Magic live ISO.
- Edited /etc/defaults/grub and uncommented '