Can’t Get Grub Work On Clone Of Machine

Home » CentOS » Can’t Get Grub Work On Clone Of Machine
CentOS 10 Comments

Hi. I have cloned a RHEL 5.6 physical server over to a ESXi 5.0 Virtual Machine.

Using a live CD on the new Virtual Machine I created 3 partition /boot (/dev/sda1), / (/dev/sda2) and swap (/dev/sda3), I then mounted the / (sda2) partition and created the /boot directory and mount the boot partition partition /dev/sda1 into /boot. I then used rsync to copy the source machine over to the Virtual Machine.

I have not been able to get Grub to go further than :

GRUB Loading stage1.5. GRUB Loading, please wait… Error 2

I have tried :
the Super Grub

# chroot /mnt/sysimage
# grub-install /dev/sda
/dev/sda does not have any corresponding BIOS drive.

# grub-install --root-directory=/mnt/sysimage /dev/sda
/dev/sda does not have any corresponding BIOS drive.

I have also tried a number using the grub console with a number of different configurations all failed .

fdisk output :

Disk /dev/sda: 549.7 GB, 549755813888 bytes
255 heads, 63 sectors/track, 66837 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 131 1048576 83 Linux Partition 1 does not end on cylinder boundary.
/dev/sda2 131 60968 488669184 83 Linux
/dev/sda3 60968 66838 47152128 82 Linux swap / Solaris


[root@nzhmlwks113 vm]# cat fstab
/dev/sda2 / ext3 defaults 1 1
/dev/sda1 /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5modeb0 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sda3 swap swap defaults 0 0


# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol01
# initrd /initrd-version.img
splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-308.11.1.el5)
root (hd0,1)
kernel /vmlinuz-2.6.18-308.11.1.el5 ro root=LABEL=/ ramdisk_size

10 thoughts on - Can’t Get Grub Work On Clone Of Machine

  • Try this:

    mount /dev/sda1 /mnt/sysimage/boot mount -t none /dev /mnt/sysimage/dev -o bind chroot /mnt/sysimage/boot mount /proc mount /sys

  • Yves Bellefeuille wrote:

    What *is* mounted as /? If you’ve booted off, say, a USB key, or CD, that might be seen as sda, and the real h/d is sdb.


  • First, if your source layout is typical, you might have been able to use the free VMware Converter tool to clone to ESXi (or an image)
    directly. Most of my linux boxes have a custom raid layout and don’t work so I don’t have much linux experience with it, but it works great with windows.

    Another approach is to do a minimal install, upgrade the kernel to match the source machine, then blow away everything but the /boot partition and copy over from the source. This gets grub installed and the right kernel modules in the ramdisk to match the new hardware –
    and you can look at /etc/modprobe.conf to see what those modules are if you don’t know as much as anaconda does about hardware and modules.

    But, starting from what you have, stage 1.5 is still in the MBR so it seems odd that you have enough to boot at all but are missing that part. I’d try booting in rescue mode, running grub and:
    root (hd0,1)
    setup (hd0)

  • Hi Mark.

    Thanks for your input. When I chroot to /mnt/sysimage the only hard drive listed is sda. Both from “linux rescue”
    and chroot mount reflects the same drive / partition mapping :
    Rescue :
    /dev/sda2 on /mnt/sysimage type ext3 (rw,data=ordered)
    /dev/sda1 on /mnt/sysimage/boot type ext3 (rw,data=ordered)

    Chroot :
    /dev/sda2 on / type ext3 (rw,defaults)
    /dev/sda1 on /boot type ext3 (rw,defaults)



  • Hi Les.

    I started with VMware standalone converter 4.3 and the 5.0 and couldn’t get it to work, but it worked fine when converting another machine to the same ESXi host.

    Following these instructions :
    mount /dev/sda1 /mnt/sysimage/boot mount -t none /dev /mnt/sysimage/dev -o bind chroot /mnt/sysimage/boot mount /proc mount /sys


    root (hd0,1)
    setup (hd0)

    I get the following:
    root (hd0,1)
    Filesystem type is ext2fs, partition type 0x83
    setup (hd0)
    Checking if “/boot/grub/stage1” exists… no
    Checking if “/grub/stage1” exists… no

    Error 2: Bad file or directory quit

    I have checked that the stage1 file is in /boot/grub/ So Im confused.

    Thanks Greg

  • My previous advice was nonsense; sorry. :-(

    This, however, should work:

    (as root)

    mount –bind /dev /mnt/sysimage/dev mount –bind /proc /mnt/sysimage/proc mount –bind /sys /mnt/sysimage/sys chroot /mnt/sysimage grub-install /dev/sda

  • Not sure you need any of that if your boot/rescue environment has grub.

    Either your rsync copy of the boot filesystem was not complete, or what grub thinks is (hd0,1) is not the filesystem where you put it.

  • Hi Les.

    Just to clarify my understanding of grub’s syntax for hard disk partitions
    /dev/sda = hd0
    /dev/sda1 = hd0,0
    /dev/sda2 = hd0,1

    Thanks Greg

  • Normally yes, but grub may have its own idea about what bios will consider to be hd0. You can force it with:
    device (hd0) /dev/sda

    Yes, you probably really need root (hd0,0) instead the (hd0,1) I said earlier.

  • Typically that error means that “sda” does not appear in
    /boot/grub/ Your previous system probably used hda instead.
    Update that file, replacing hda with sda, then reinstall grub.