A Puzzle With Grub-install

Home » CentOS » A Puzzle With Grub-install
CentOS 1 Comment

I ran into a problem when using grub-install experimentally in what is obviously a foolish way, since I was unable to boot the machine afterwards. I got round the problem, as I shall explain, but I’m still interested to know why the problem arose.

Having added a second hard disk to my CentOS-6.5 server, as an experiment I gave the command
grub-install /dev/sdb after checking (with fdisk) that the new disk was indeed sdb, while the disk on which CentOS is running remains sda.

I assumed that this would leave the MBR on sda unchanged, so that I would be able to boot to the current system as before. But I found that this was not the case;
on rebooting the machine hung, with a repeating “-” on the screen.

The only way I was able to recover the current system was to use a CentOS Live USB stick I had to install CentOS on a spare partition (sda12).

With that system running I was able to mount the old system (on sdb10)
as /mnt, and the boot partition (sdb2) as /mnt/boot, and then give the command
grub-install –root-directory=/mnt /dev/sda On re-booting the old system came up.

(I may say I also tried to run grub-install from the USB stick, but was completely unable to do this so as to re-install the old system. Basically, the old disk had become sdb, while the USB stick was sda. So I mounted /dev/sdb10 as /mnt and /dev/sdb2 as /mnt/boot, and gave the command
grub-install –root-directory=/mnt /dev/sdb I then removed the USB stick, and tried – unsuccessfully –
to re-start the machine.)

But I’m puzzled by my experience, which seems to suggest that running grub-install /dev/sdb actually affects the MBR on sda. Or have I misunderstood in some way?

One thought on - A Puzzle With Grub-install

  • <>

    a usb install does not properly set up an install. at least now in times i have done them and why i install as explained below.

    <>

    if the installer allows the ability to select where the boot loader will be installed, i have found i am better off installing loader to the partition where new systems is going.

    there are too many ‘gotchas’ waiting to get you and grub is a fine example.

    grub and maybe grub2 is/are not designed to be able to distinguish between a cd/dvd install and a usb install. if it/they did, a usb install would not assign the usb stick as hda/sda. or so has been my experience with usb installs.

    from early times of grub installs, i have continuously installed boot loader to install partition. after install is completed and reboots, i boot into previous hda/sda boot partition.

    i then rewrite fstab to show new installed partition and setup a mount directory. ie, /hdd/d/06, mount the newly installed partition, open grub.conf for new install and copy & paste it to grub.conf of hda/sda boot partition. reboot and select new install, then finish second stage of install. if there is one.

    a little involved, i agree. i could set old install to chain boot new install, but i am a little set in my ways. ie, i had problems first time i tried chain booting. ;-)

    ymmv.