Sample Header Ad - 728x90

How to install GRUB on a new drive?

9 votes
2 answers
50048 views
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?
Asked by Renjith (241 rep)
Mar 19, 2015, 01:43 PM
Last activity: Nov 12, 2022, 09:47 PM