I have a machine with UEFI BIOS. I want to install Ubuntu 18.04, desktop version with RAID 1 (and LVM) so my system will continue to work even if one of the drives fail. I haven't found a HOWTO of how to do that.
The desktop installer does not support RAID. The answer to this question almost works but requires some GRUB shell/rescue USB disk and UEFI settings magic. Is anyone aware of a procedure that works without the magic parts?
Ubuntu – Install Ubuntu 18.04 desktop with RAID 1 and LVM on machine with UEFI BIOS
18.04lvmraidsystem-installationuefi
Best Answer
With some help from How to install Ubuntu server with UEFI and RAID1 + LVM, RAID set up in Ubuntu 18.04, and RAID support in Ubuntu 18.04 Desktop installer? and How to get rid of the "scanning for btrfs file systems" at start-up?, I managed to put together a working HOWTO using linux commands only.
In short
btrfs
boot scripts.In detail
1. Download the installer
Install Ubuntu Server
.2. Install with manual partitioning
Partition disks
step, selectManual
.Configure the Logical Volume Manager
.Delete logical volume
until all volumes have been deleted.Delete volume group
until all volume groups have been deleted.Configure software RAID
.Delete MD device
until all MD devices have been deleted.Delete the partition
.EFI System Partition
.Physical Volume for RAID
.Configure software RAID
.Create MD device
, typeRAID1
, 2 active disks, 0 spare disks, and select the/dev/sda2
and/dev/sdb2
devices.Configure the Logical Volume Manager
.vg
on the/dev/md0
device.swap
at 16Groot
at 35Gtmp
at 10Gvar
at 5Ghome
at 200Gswap
partition, selectUse as: swap
.Use as: ext4
with the proper mount points (/
,/tmp
,/var
,/home
, respectively).Finish partitioning and write changes to disk
.If you are re-installing on a drive that earlier had a RAID configuration, the RAID creation step above might fail and you never get an
md
device. In that case, you may have to create a Ubuntu Live USB stick, boot into that, rungparted
to clear all your partition tables, before you re-start this HOWTO.3. Inspect system
Check which EFI partition has been mounted. Most likely
/dev/sda1
.mount | grep boot
Check RAID status. Most likely it is synchronizing.
cat /proc/mdstat
4. Clone EFI partition
The EFI bootloaded should have been installed on
/dev/sda1
. As that partition is not mirrored via the RAID system, we need to clone it.5. Insert second drive into boot chain
This step may not be necessary, since if either drive dies, the system should boot from the (identical) EFI partitions. However, it seems prudent to ensure that we can boot from either disk.
efibootmgr -v
and notice the file name for theubuntu
boot entry. On my install it was\EFI\ubuntu\shimx64.efi
.sudo efibootmgr -c -d /dev/sdb -p 1 -L "ubuntu2" -l \EFI\ubuntu\shimx64.efi
. Depending on your shell, you might have to escape the backslashes.efibootmgr -v
that you have the same file name for theubuntu
andubuntu2
boot items and that they are the first two in the boot order.7. Wait
If you want to try to physically remove or disable any drive to test your installation, you must first wait until the RAID synchronization has finished! Monitor the progress with
cat /proc/mdstat
However, you may perform step 8 below while waiting.8. Remove BTRFS
If one drive fails (after the synchronization is complete), the system will still boot. However, the boot sequence will spend a lot of time looking for btrfs file systems. To remove that unnecessary wait, run
This should remove
btrfs-progs
,btrfs-tools
andubuntu-server
. The last package is just a meta package, so if no more packages are listed for removal, you should be ok.9. Install the desktop version
Run
sudo apt install ubuntu-desktop
to install the desktop version. After that, the synchronization is probably done and your system is configured and should survive a disk failure!10. Update EFI partition after grub-efi-amd64 update
When the package
grub-efi-amd64
is updated, the files on the EFI partition (mounted at/boot/efi
) may change. In that case, the update must be cloned manually to the mirror partition. Luckily, you should get a warning from the update manager thatgrub-efi-amd64
is about to be updated, so you don't have to check after every update.10.1 Find out clone source, quick way
If you haven't rebooted after the update, use
to find out what EFI partition is mounted. That partition, typically
/dev/sdb1
, should be used as the clone source.10.2 Find out clone source, paranoid way
Create mount points and mount both partitions:
Find timestamp of newest file in each tree
Compare timestamps
Should print
/dev/sdb1 is newest
(most likely) or/dev/sda1 is newest
. That partition should be used as the clone source.Unmount the partitions before the cloning to avoid cache/partition inconsistency.
10.3 Clone
If
/dev/sdb1
was the clone source:If
/dev/sda1
was the clone source:Done!
11. Virtual machine gotchas
If you want to try this out in a virtual machine first, there are some caveats: Apparently, the NVRAM that holds the UEFI information is remembered between reboots, but not between shutdown-restart cycles. In that case, you may end up at the UEFI Shell console. The following commands should boot you into your machine from
/dev/sda1
(useFS1:
for/dev/sdb1
):The first solution in the top answer of UEFI boot in virtualbox - Ubuntu 12.04 might also be helpful.