4

I have an Ubuntu 14.04 x64 server with 2 500GB drives (sda and sdb) in a software RAID 1.

I just had to replace sdb. Adding it back to the array with mdadm and resyncing was a snap. The problem I'm running into is making sure it can boot if sda happens to fail in the future.

Note: all commands below were run as root


1st try

Most walkthroughs I've found told me to run:

grub-install /dev/sda /dev/sdb

Which is the exact same command I've seen the Ubuntu installer run a hundred times. However, when I ran that, I got:

grub-install: error: More than one install device?.

This has always worked for me. Maybe something changed with 14.04?


2nd try

Some walkthroughs recommended setting up grub for the new hard drive manually. The grub prompt scares me, but I was willing to try these steps:

# grub --device-map=/boot/grub/device.map
grub> root (hd0,0)
grub> setup (hd0)
grub> root (hd1,0)
grub> setup (hd1)
grub> quit

Only problem? After the first command, I get:

The program 'grub' is currently not installed. You can install it by typing:
apt-get install grub

???

So I tried installing grub.

# apt-get install grub
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  grub-legacy-doc
The following packages will be REMOVED:
  grub-gfxpayload-lists grub-pc grub2-common
The following NEW packages will be installed:
  grub
0 upgraded, 1 newly installed, 3 to remove and 0 not upgraded.
Need to get 913 kB of archives.
After this operation, 438 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

Needless to say, I answered no.


3rd try

Getting desparate, I tried something I was pretty sure was wrong. The official server guide recommends (at the bottom of the "Raid Maintenance" section):

grub-install /dev/md0

This was the output:

# grub-install /dev/md0
Installing for i386-pc platform.
grub-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
grub-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.

Scary.


It looks like grub has been superceded somehow in 14.04, but I can't find any information about how things have changed. I do have a /boot/grub/ directory, so I know some form of grub is installed.


Update:

I was able to run the following commands independently:

grub-install /dev/sda
grub-install /dev/sdb

However, I'm unsure if sda will boot after installing grub on sdb and vice versa. Am I ok?

  • You could remove one drive at a time and seeing if they boot normally. – MGodby Aug 28 '14 at 13:11
  • At the moment, I'm not sure either drive will boot (see my last update). I can't just take this server down to test it and (potentially) reload it if it is hosed. There has to be a proper way to do this. I know I'm not the first person who has replaced a bootable RAID1 drive in Ubuntu 14.04 (maybe just the most ignorant). – Andrew Ensley Aug 29 '14 at 18:01
  • [Apologies if this doesn't help] When I configured my Ubuntu raid-1 server I found I couldn't put my boot partitions on on the raid volume. I assumed this was because I couldn't access software raid until the kernel is loaded - i.e. post boot. I created two small boot partitions - one on each drive - and duplicated the boot partition between the physical disks using dd. I can now boot from either drive... as they have identical boot partitions. – aSteve Aug 31 '14 at 16:49
  • Your are Ok just now mount your /dev/sdb partition and run update-grub in it. this answer might help you http://askubuntu.com/a/88432/283843 – αғsнιη Sep 03 '14 at 10:52

2 Answers2

2

I found the answer. The way to make sure GRUB is properly installed on and recognizes both drives from each is to run:

sudo dpkg-reconfigure grub-pc

When prompted which drives to install on, make sure all boot drives are selected. In my case, this was /dev/sda and /dev/sdb. Do not select /dev/md0 or any of the other md devices.

0

For what it's worth: I needed to add a delay script to my boot configuration to allow a degraded RAID array enough time to assemble. Otherwise everything worked fine when booting with 2 working drives, but as soon as I disconnected one drive to test the redundancy I ended up in busybox (without keyboard for good measure)! For details, see the end of step 6 in How to install Ubuntu 14.04 64-bit with a dual-boot RAID 1 partition on an UEFI/GPT system? (the part about /usr/share/initramfs-tools/scripts/local-premount/sleepAwhile).