I had made a partition backup of a machine using Clonezilla and wanted to restore it. The restore was successful but because I had only restored the partitions rather than the full disk Grub was not installed in the MBR. Without Grub in the MBR the system failed to boot.
I mounted the new filesystem to /mnt while still using the live Clonezilla disk that I had used for the backup. Then I chrooted using the following command
chroot /mnt
then while in the chroot I attempted to reinstall grub, and since this was a Cloudlinux/Centos install I performed
grub-install /dev/sda
But grub-install complained that it couldn’t find /dev/sda or that /dev/sda was not a valid block device. So then hunting around on the internet for a little bit I came across this article which showed basically how to ensure that your current live
- /dev
- /sys
- /proc
filesystems are accessible inside of your current chroot.
So I ran the following commands outside of the chroot before entering it again.
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
Then I chrooted to /mnt again and ran my grub-install command and all was well. The machine booted perfectly after that.
Shameless Plug
If you need to repartition or reformat a drive. Or resize partitions and check the health of your drive for Linux or Windows based machines give Parted Magic a try. It takes your favorite open source tools and puts them in an easy to use bootable linux CD. It has become my goto tool for all hard drive management tasks.