14.04 - Replaced drive in Software RAID 1 - How to make bootable?

5,010

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.

Share:
5,010

Related videos on Youtube

Andrew Ensley
Author by

Andrew Ensley

With continuous experience beginning in 2004, I am a seasoned software developer, system administrator, database administrator, DevOps engineer, and team leader. My favorite areas of focus in development are performance, optimization, and security. I have experience with: Git, Java, C#, Python, TypeScript, Node.js, React.js, SQL, PHP, Linux, Windows, MacOS, Infrastructure-as-Code, Configuration-as-Code Azure, ADO, Jenkins, GitHub, Nexus RM/IQ, JFrog Artifactory, SonarQube, Docker, Kubernetes, Cloud Foundry, TAS, TKGi, DigitalOcean, Ansible, AWS Visual Studio Code, IntelliJ IDEA, Eclipse, PyCharm, Android Studio I love automation and open-source software.

Updated on September 18, 2022

Comments

  • Andrew Ensley
    Andrew Ensley over 1 year

    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?

    • MGodby
      MGodby over 9 years
      You could remove one drive at a time and seeing if they boot normally.
    • Andrew Ensley
      Andrew Ensley over 9 years
      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).
    • aSteve
      aSteve over 9 years
      [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.
    • αғsнιη
      αғsнιη over 9 years
      Your are Ok just now mount your /dev/sdb partition and run update-grub in it. this answer might help you askubuntu.com/a/88432/283843