I have a virtual box running with CentOS.
I have attached a new virtual disk to the existing CentOS VM and I'm now trying to install GRUB on this newly attached disk.
Later, I will bring up a second VM with a newly prepared bootable hard disk with a custom root filesystem and kernel.
I have tried the following steps:
- Attached a new virtual disk to the existing working CentOS machine.
- Created a new partition with
fdisk /dev/sdb. While partitioning, I chose the options primary partition, partition number 1 and other default options. - Formatted the disk with
mkfs.ext3 /dev/sdb1. - Mounted the disk to
/media/new_drive. - Installed GRUB
grub-install /dev/sdb1 --root-directory=/media/new_drive/.
After this, the second VM with the newly prepared hard disk didn't boot; I got the error: could not read from the boot medium. It seems the MBR is not updated after grub-install, but I can see GRUB installed under /boot/grub on the new drive.
But the worst thing is, it has corrupted my existing CentOS GRUB: The CentOS VM hangs showing a black screen with the only text being GRUB.
Why does grub-install /dev/sdb1 not modify the MBR of sdb1? Is this not the right way to install GRUB on new drive?
/dev/sdb1is not where the BIOS looks for MBR, it's in/dev/sdbi.e. the very first sector of the disk.grub-install /dev/sdb --root-directory=/media/new_drive/instead sdb1