10

I would like to install Ubuntu 20.04 Focal Fossa on a machine with two hard disks using RAID 1.

Unfortunately it seems this doesn't work. If I use the "Create Software RAID (md)" option and select both my disks the installer tells me:

If you put all disks into RAIDS or LVM VGs, there will be nowhere to put the boot partition.

I found this detailed answer about 18.04 but the problem with this and similar findings on the subject is that Focal dropped the alternative installer so the required partitioning options are gone.

What options do I have to accomplish this?

2
  • This one is hard to write an answer for because of many different directions you can go. However, I have found that the best way to do this is to install the OS like you would normally to one drive. Then you can create the array with missing disks, which would be your second drive. If you want, go ahead and install it to your first drive then give the partition table layout and I will help you get it all setup after and write it into an answer. I will also need to know if you are doing GPT or MSDOS type partitioning for your system.
    – Terrance
    May 3 '20 at 22:38
  • Thank you for your kind offer @Terrance. fevangelous answer solves my problem without requiring additional steps after installation. It's a bit jumping through hoops but now I can automate this.
    – wedi
    Jun 15 '20 at 12:17
21

As I stumbled on the same issue and found out that the actual docs haven't yet been updated for the new storage configurator (still true as of March 2021 and now possibly with a bug on the bios_grub configurator of the installer), here's what I did to get a working softRAID 1 setup with 2 disks on the Ubuntu Server edition (for version 20.04 or newer):

  • Select "Custom storage layout" when you reach the storage configuration step of the installer.
  • If the disks have existing partitions, click on each disk under AVAILABLE DEVICES and then select REFORMAT. This will (temporarily) wipe out the partitions.
  • Now select the 1st disk to add as "boot" disk (same menu that had REFORMAT in).
  • Do the same with the 2nd disk. [Note on March 2021: If this does not work for you in the newest installer of 20.04.2, just skip that part. In the end the 1st disk will have 4 partitions (bios, /boot, swap and /) and the 2nd just 3 (/boot, swap and /), which doesn't really matter. If you want to have the same number of partitions on each disk, go ahead and create a 1 MB partition on the 2nd disk, before doing the 3 others. This way, blocks will be sync'ed between the 2 disks. It's possible that there's a bug in how the bios_grub partitions are created in the installer when using multiple disks as this behaviour is not consistent with version 20.04.1 or the current Ubuntu Server docs as referenced here.]
  • You should now see two 1.000M bios_grub partitions created under USED DEVICES. These small partitions will be used by GRUB for booting the server. [Note on March 2021: the setup works with one bios_grub partition as well].
  • The trick to setup a softRAID array is to create partitions for /boot, swap and / on each disk, but WITHOUT formatting them (and as such, there won't be a mount point for now).
  • So go ahead and "Add GPT Partition" on the 1st disk, give it a 1G size and choose to leave it unformatted. Do the same for the 2nd disk. These will be the /boot partitions for the softRAID array. Under each disk on AVAILABLE DEVICES you will now see "partition 2".
  • Now we'll prepare the swap partitions. "Add GPT Partition" on the 1st disk, give it the same or half the size of your RAM (e.g. let's say 16G cause we have 16G of actual RAM - but it's really up to you to decide that) and choose to leave it unformatted. Do the same for the 2nd disk. Under each disk on AVAILABLE DEVICES you will now see "partition 3".
  • Now we'll prepare the / partitions. "Add GPT Partition" on the 1st disk, do not set a size (so it uses all available) and choose to leave it unformatted as with all the other partitions you created so far. Do the same for the 2nd disk. Under each disk on AVAILABLE DEVICES you will now see "partition 4".
  • Now click on "Create software RAID (md)" under AVAILABLE DEVICES. We'll create the first softRAID partition (md0) by selecting the two "partition 2" entries (one from each disk). Click "Save".
  • Repeat the process for md1 and select the two "partition 3" entries. Hit "Save".
  • Repeat the process for md2 and select the two "partition 4" entries. Hit "Save".
  • We now have 3 pairs of AVAILABLE DEVICES which will now format as the actual softRAID partitions. So select md0 and then "Add GPT Partition", format as EXT4 and mount on /boot.
  • Select md1 and then "Add GPT Partition", format as SWAP.
  • Select md2 and then "Add GPT Partition", format as EXT4 and mount on /.
  • All these mdX softRAID partitions will now appear under USED DEVICES and you are ready to proceed with Ubuntu's installation.
  • At the very bottom, you should now see "Done" enabled so hit it and proceed.

Enjoy :)

(Also referenced on: https://gist.io/@fevangelou/2f7aa0d9b5cb42d783302727665bf80a)

6
  • 1
    fevangelou: Thanks, man! Canonical: REALLY?!
    – F.D.Castel
    Nov 9 '20 at 5:36
  • 1
    You're my hero dude! This is the ONLY guide I've found to getting RAID1 working for Ubuntu 20.10. I used this + LVM encryption to set up RAID1 + encryption for my laptop, this literally took me an entire 24 hours and then I finally found this post! Jan 6 at 22:47
  • 1
    Thank you SO MUCH man
    – vicase98
    Feb 5 at 19:49
  • Oh I get it now, this is how you do it on 20.04 Server. I went through so many reinstalls looking for these options (and trying to do it manually). +1 Mar 7 at 0:12
  • and yes you said that, I just skipped over it. Mar 7 at 0:16
6

I fixed it in this way.

Solution 1: Install RAID 1 without encrypt your disks

First, I have prepared both the hard drives (SSD in my case) using "GParted Live" (I created a bootable USB with the GParted ISO):

  1. 512 MB partition, named "/bios/efi", fat32, flagged as "boot, esp";
  2. 10 GB partition, named "/", ext4, flagged as "raid";
  3. (Entire remaining space) /home partition, named "/home", ext4, flagged as "raid";

I decided to omit a "/swap" partition because I have 16 GB of RAM installed, and I use SSD drives, and this server will be just a little home NAS, so I don't need high performance.

Then, using the "Custom storage layout" during the Ubuntu Server 20.04 installation:

  1. I checked both disks to be "added as a boot disk";

  2. Using the "Create software RAID (md)" option, I selected the "/" - root - disk one partition, and the "/" partition of disk two, to create a new "md0" volume (always active);

  3. I created another "RAID md" volume, but this time with "/home" partition (always active), selecting both "/home" partitions to create a new "md1" partition;

  4. I selected the "md0" partition (the root partition created before) and choose "Add GPT Partition", and than I selected format as "Ext4" and mount on "/";

  5. Similarly with "md1" partition (the /home partition), I choose "Add GPT Partition", and than I selected format as "Ext4" and mount on "/home";

  6. After that I choose "done" and I completed the installation.

Solution 2: Install RAID 1 with disks encryption

Here I wrote a quick guide about how I solved. The main problem is related to the "/boot" partition, that can't be inside the encrypted partition, because the grub's encryption it isn't supported yet.

I hope that this guide will be useful for other Ubuntu users.

3
  • This sounds like it's solving the problem -- if you have a system you can use to format the disks prior to running the installer.
    – wedi
    Jun 15 '20 at 12:20
  • @wedi, you can easily use GParted live, you can start it from an usb on the same system where you are working on.
    – MarGraz
    Jul 12 '20 at 17:17
  • It's absolutely possible to plug a usb thumb drive into my machine and boot a bare metal machine in a remote data center from it but personally I think it's just not convenient enough. :) Using the other answer as template I setup a completely unattended automatic installation using subiquity. But of course your answer might be the best solution for someone else!
    – wedi
    Jul 13 '20 at 15:08
0

The solution from fevangelou is generally excellent but there is a detail missing about the swap partition if you have more than one RAID (or leftover disks which are formatted as Linux RAID). The tl;dr is if you have any other RAID disks, leave them unplugged until after the install is over.

In my case, I have 4 disks (2 in RAID1 for the OS as md0/md1/md2), 2 in RAID1 for storage (md3). If I create md3 during install (or do nothing and leave these disks formatted as Linux RAID from a previous install), after the first boot I run swapon -s and I see that only the swap.img file is used, not my swap partition. I run cat /proc/mdstat and I can see that my storage drives (should have been md3 or not assigned) have been assigned to md1 (which was swap in fevangelou's example). The swap partition is nowhere to be found.

If I unplugged the extra disks before install, things worked perfectly. I waited until after the first full boot to poweroff and plug the extra disks in. I have a couple of other drives (ntfs and ext4) which I left plugged in and never had a hassles, just the RAID drives.

1
  • Ubuntu 20.04 uses swap files instead of partitions by default
    – wedi
    Aug 18 '20 at 9:11
0

RAID needs both disks have the same partition layout, and Ubuntu needs at least 1 active boot partition for bios (grub). What I am doing:

  • Select 1st disk, "Use as boot device"

  • Select 2nd disk, "Add as another boot device"

  • Select 1st disk, Add GPT partition, left the size blank, and leave unformatted

  • Select 2nd disk, Add GPT partition, left the size blank, and leave unformatted

  • Select "Create software RAID (md)", select partition 2 from both disks

Now, you have NEW AVAILABLE DEVICES /md/xxx. Just do the partitioning as usual to add / (root), /boot, etc. You can also create it as LVM partition.

For reference, please watch this Youtube videos Manually Create RAID1 Mirrored 2 Disks during Ubuntu 21.04 Server Installation

1
  • Sounds like they have improved the installer in this regard now. Great. Apart from that: my question was specifically about version 20.04 which is the current LTS.
    – wedi
    Aug 5 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.