Install Ubuntu MATE 16.04 on RAID 1

Task:  Install Ubuntu MATE 16.04 (or any similar Debian Linux O/S) on RAID 1 disks

Reference:

  • http://askubuntu.com/questions/505446/how-to-install-ubuntu-14-04-with-raid-1-using-desktop-installer
  • http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi

Given: Two disks, /dev/sda and /dev/sdb; using MBR tables. (GPT is similar but you’ll need to set the bios_grub flag).

Simple single RAID set (/dev/md0) created from the two disks.

Boot into the Ubuntu live-installation; open a terminal window.

Partition the disks

# parted -a optimal
unit MiB
# Do first drive
select /dev/sda
mktable msdos
mkpart primary ext4 1 -1 # uses all the space excet 1MiB at front for boot area
set 1 raid on
# Repeat on second drive
select /dev/sdb
mktable msdos
mkpart primary ext4 1 -1 # uses all the space excet 1MiB at front for boot area
set 1 raid on
# Done
quit

Stop the auto-detected RAID: Sometimes (if you already have mdadm installed) the live-instance of Ubuntu that you’re running will autodetect the just-created RAID partitions and build the array. You don’t want this yet, so stop it:

# cat /proc/mdstat

If you see any, like /dev/md127 or whatever, stop it:

# sudo mdadm --stop /dev/md127

Create file systems in here, really not needed but I do this to start “clean” on the disks before RAID overwrites this. It leaves some identity info out there anyway; for example, a ‘print’ in parted shows the filesystem type.

# sudo mkfs.ext4 /dev/sda1
# sudo mkfs.ext4 /dev/sdb1

Build the RAID array.

Install mdadm (onto the Live distro, not the final system)

# sudo apt-get -y install mdadm
# sudo mdadm --create /dev/md0 --bitmap=internal --level=1 --raid-disks=2 /dev/sda1 /dev/sdb1

Partition the RAID array

# sudo parted -a optimal /dev/md0
unit MiB
mktable msdos
mkpart primary 1 16GB # Swap partition, use whatever size you need
mkpart primary 16GB -1 # The rest for / (root partition)

Now install Ubunto onto the new RAID array – but NOT the bootloader yet (-b); you must handle that special.

# ubiquity -b

During the install, select “Something else” for the disk layout.
Choose the swap and root partitions on the /dev/md0 device for the install.
Check the “format” box to format the root partition as ext4.
Let the install run, this uses much time…

Do NOT reboot yet – it will fail. You must manually install the bootloader onto each disk.

sudo -s
mount /dev/md0p2 /mnt
mount -o bind /dev /mnt/dev
mount -o bind /dev/pts /mnt/dev/pts
mount -o bind /sys /mnt/sys
mount -o bind /proc /mnt/proc
cat /etc/resolv.conf >> /mnt/etc/resolv.conf
chroot /mnt
apt-get install mdadm
vi /etc/grub.d/10_linux  # change quick_boot and quiet_boot both to 0
grub-install /dev/sda
grub-install /dev/sdb
update-grub
exit