[CentOS] A puzzle with grub-install

Tue Feb 11 01:50:09 UTC 2014
Timothy Murphy <gayleard at eircom.net>

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?


-- 
Timothy Murphy  
e-mail: gayleard /at/ eircom.net
School of Mathematics, Trinity College, Dublin 2, Ireland