Why?

The standard dekstop installer doesn’t cover software RAID (any level) using mdadm or other tools, and the Server installer doesn’t always boot correctly on consumer hardware.
Furthermore, when newcomers ask about RAID0 in the server/admin community instead of answers, they get responses like:

  • “buT raID0 doESnt pROTECt YOuR DaTA”
  • “HaVE YoU REAd tHe MaNUaL?”
  • “WHY doN’T yoU uSE <…> iNstead? iTS BEtTeR!”

As a member of the linux community, those answers bug me as much as they bug you, so here (hopefully) i can document something that will help you get to your goal, without the inevitable discussion about “why raid0 is dangerous” or “why the other thing is better” or “why the OTHER raid level is what you should really be using.”

Cheers to you, reader - and best of luck.

Note - This guide can actually work for any level of software RAID, the only difference is in the mdadm --create syntax on how the RAID disks are assembled. You can read more about mdadm here at the man page.

Test Hardware Config

(Use what you have obviously)

  • 2 vCPU (kvm64)
  • 8192MB RAM
  • 3 disks [2, 16, 16GB]
    • 2GB disk is SCSI
    • 16GB disks are SATA and have SSD Emulation enabled
  • VirtIO bus and video card

Installation Process

  1. Attach 3 virtual disks (skip if your hardware is physical)
    1. 2GB regular disks
    2. 16GB flash emulated disk
    3. 16GB flash emulated disk
  2. Boot Installation DVD in UEFI mode
  3. English everything. (Or whatever language you speak)
  4. Select:
    • Normal installation
    • Download updates
    • Install 3rd party drivers (DONT CLICK CONTINUE YET!)
  5. Before partitioning drop to system shell (CRTL+ALT+F2) and clear all raid markers and remnants:
    1. login: ubuntu
    2. no password (auto-login)
    3. Change to root with sudo -i
  6. Install mdadm
    1. apt update
    2. apt install mdadm -y (ignore the errors, the services aren’t running)
  7. Clear out the old raid markers
    1. Look for RAID markers with cat /proc/mdstat
    2. Unmount the RAID if it exists with umoount /dev/md0 or whatever the device handle is (this guide will use /dev/md0)
    3. Stop the RAID array with mdadm --stop /dev/md0
    4. Destry all the RAID superblocks with mdadm --zero-superblock /dev/nvme0n1 (insert each drive here, run through ALL of them except the USB you booted from)
    5. If you want to be super extra sure they’re dead and off the old array you can zero them out manually:
    6. dd if=/dev/zero of=/dev/nvme0n1 bs=512 seek=$(( $(blockdev --getsz /dev/nvme0n1) - 1024 )) count=1024
    7. Now they should all be dead!
  8. Create the new RAID0 array
    1. mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/nvme0n1 /dev/nvme1n1
    2. Check with cat /proc/mdstat
  9. Go back to installer (CTRL+ALT+F1) and proceed to the partitioning screen.
  10. Partition “Something Else” (aka manual partitioning)
    1. Create new GPT partition tables on each device
    2. On boot media, create a new EFI System partition (500MB)
    3. On boot media, create a new ext4 partition and mount to /boot (use the rest of the disk)
    4. On /dev/md0 create new volume for encryption
      • (if you want to use encryption, otherwise use the /dev/md0 device directly by creating an ext4 partition)
    5. Change /dev/md0p1(_crypt) to ext4 and mount at root (/)
      • If you have specific partitioning requirements, feel free to partition /dev/md0p1_crypt to your liking. I used one partition only for simplicity, but normal partitioning schemes will work within the crypt disk.
    6. Ensure the correct boot device (/dev/sda?) is selected for boot loader installation.
  11. Click install now and continue on the popup confirmation.
  12. Complete the rest of the install screen per normal installation, But don’t reboot yet!!!
  13. Switch back to terminal (CTRL+ALT+F2)
  14. Mount all the things in the chroot directory (which is /target/ on the installer by default):
    1. mount -t proc /proc /target/proc
    2. mount --rbind /dev /target/dev
    3. mount --make-rslave /target/dev
    4. mount --rbind /sys /target/sys
    5. mount --make-rslave /target/sys
  15. chroot into the newly installed environment
    1. chroot /target /bin/bash
    2. source /etc/profile
    3. export PS1="(chroot) ${PS1}"

EVERYTHING BELOW HERE AFFECTS YOUR ACTUAL SYSTEM!

  1. Add a nameserver to /etc/resolv.config
    1. echo "nameserver 1.1.1.1" > /etc/resolv.conf
    2. Feel free to substitute your own nameserver here, but the chroot is going to need one and probably doesn’t have one yet. This change will persist to your production machine.
  2. Update apt:
    1. apt update
    2. You can do a full upgrade on your system here if you want to with apt upgrade -y but i’d suggest waiting until you’re booted into your final system.
  3. Install mdadm:
    1. apt install mdadm -y
  4. Edit /etc/default/grub
    1. add domdadm to GRUB_CMDLINE_LINUX
    2. GRUB_CMDLIN_LINUX="domdadm"
  5. Run grub-mkconfig > /boot/grub/grub.cfg
  6. Exit chroot by running exit
  7. Remove installation media
  8. Reboot as normal.
    1. My reboot hung (could have been the VM) so i needed to completely power off and run again from cold.
  9. Profit!

Ubuntu Success

Post-Install

I’d recommend running a full upgrade on the system at this point:

  • sudo apt update && sudo apt upgrade -y
  • update /boot to be read only, or don’t mount at boot. This just keeps the integrity of the system so things don’t accidentally get changed unless you want to change them.
  • Install any closed-source binary drivers you might need (nvidia, AMD, other GPU’s):
    • Go to “Software Update” and select the “Additional Drivers” Tab.