Search This Blog

Sunday, April 14, 2013

Keeping software RAID while reinstalling Ubuntu

A quick note on how to maintain your carefully constructed software RAID if you are wiping and reinstalling Ubuntu:

  • copy the mdadm.conf file in /etc/mdadm to somewhere safe (ie the cloud/Ubuntu One)
  • copy /etc/fstab to the same
  • Boot with your USB or CD and perform a normal Ubuntu installation*
  • Install mdadm from the repositories
  • Restore the above files and reboot+

*Be careful when running the installation setup that you do not touch your disks that contain the raid. For me, I wanted to keep /dev/sda-d untouched (my RAID 5 disks), wipe /dev/sde1 and sde2, and install on /dev/sdf1,2.  To do this you must select the "Do Something Else" option when presented with the options of how to install Ubuntu.  Ensure you format the destination of your /.

+If you changed the location of /, ensure you only copy the portion of fstab that is relevant to your RAID, otherwise you will end up with an unbootable partition because it will be looking at /dev/sd?? for your files instead of where you installed them.

Once you have added these files back, perform
sudo mount -a
To remount your filesystems.  As a note, my files are as follows:
# mdadm.conf
# Please refer to mdadm.conf(5) for information about this file.

# by default, scan all partitions (/proc/partitions) for MD superblocks.
# alternatively, specify devices to scan, using wildcards if desired.
DEVICE partitions

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts

# definitions of existing MD arrays
ARRAY /dev/md0 UUID=9e7ab348:9594fe28:0308d362:1f0077d8

# This file was auto-generated on Thu, 12 May 2011 11:17:06 -1000
# by mkconf $Id$

# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sde2 during installation
UUID=c8428ebf-d359-41af-91b5-abaec4867d38 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sde1 during installation
UUID=f271aec8-6337-4d13-b296-ed30d0e56da0 none            swap    sw              0       0
# Mount the RAID drives as Media
/dev/md0    /mnt/Media    ext4    defaults    0    0

Ensure you press Enter at the end of that last line, otherwise you'll get an error when performing mount -a due to there being no new line at the end of the file.