2

As far as I am aware, it is not possible to install Debian 11 directly onto a software raid partition, because this is a "chicken-egg" problem.

To explain: the software raid requires some parts of the Linux Operating System in order to function. In particular, I am thinking about "mdadm", although there may be other software raid "things" which could be used in place of mdadm.

At risk of laboring the point, if mdadm is used to define and run a software raid, Linux must be running for madam to work. That means it is not possible to boot from a madam software raid partition, at least as far as I am aware.


Previous Systems

I am about to install a new Debian OS onto a new machine I have built. This question has arrisen because I want to know if there is a better way to setup Debian than what I have done previously.

Previously I have installed Debian onto a single drive, then created a raid 1 madam array, and then moved the /home/ folder to that software raid partition. This results in a system which has raid 1 resiliency only on the /home folder.

/home is an obvious candidate to move, because:

  • It can be moved (it might be the case that some mount points cannot be moved)
  • It is an obvious candidate for data which one would want to be resilient to failure, because it is the usual location for user data, eg documents. (In my case, source code files.)

Question

Is there a better way to setup a Linux system with raid redundancy?

For example, is it possible to install some kind of minimal bootloader onto the first (non-redundant) drive, and then put the majority of the Operating System files, including the users home folder(s) onto the raid partition?

Further to this, is there a "standard" way of setting up a Linux OS with raid ? Would moving just the /home partition be considered to be a "normal" approach by professional system admins? Or would this be an "unsual" setup and typically something else would be done?


Update / Edit

Since asking this question I have since learned that it is possible to setup raid as part of the installation procedure. This can be done as part of the partitioning setup step.

I don't yet understand exactly how to do it and haven't yet been able to make this work, so I will ask a separate question about it.

However, this seems like a better approach than installing a system without raid and then moving some of the mount points retrospectively.

2 Answers 2

3

As far as I am aware, it is not possible to install Debian 11 directly onto a software raid partition, because this is a "chicken-egg" problem.

To explain: the software raid requires some parts of the Linux Operating System in order to function. In particular, I am thinking about "mdadm", although there may be other software raid "things" which could be used in place of mdadm.

At risk of laboring the point, if mdadm is used to define and run a software raid, Linux must be running for madam to work. That means it is not possible to boot from a madam software raid partition, at least as far as I am aware.

It has been possible for a long time. The software needed to access the root filesystem is included in the initramfs archive, which is loaded into memory by the bootloader and is the first "Linux OS" booted (i.e. the initramfs acts as the initial in-memory /, with its own init and daemons and everything), before it mounts and swaps / to your real root filesystem.

Debian already uses an initramfs even for the regular ext4 and SATA drivers, but you can just as easily have an initramfs that includes mdadm, or LUKS/cryptsetup, or ZFS, or LVM, or any combination thereof – most of which Debian's update-initramfs automatically includes when needed.

(While the Debian installer doesn't seem to offer mdadm, it does have the option to use LVM, which has the same requirements – the initramfs needs to include the software to assemble the LVM devices.)

The only limitation is that the kernel and initramfs files (two in total) – and the bootloader's own config file, of course – need to be somewhere that the bootloader knows how to access, usually meaning that /boot may need to use a simpler setup than the root filesystem (e.g. ext4 instead of ZFS). Currently GRUB2 has support for reading files out of various kinds of LVM and mdadm volumes, although it is probably better to stick with a basic RAID1 for /boot.


Anything that Debian Installer doesn't offer can be set up by installing manually (e.g. roughly following Arch Linux installation guide):

  1. Partition the disk with fdisk or parted.
  2. Create filesystems and mdadm arrays as needed.
  3. Mount everything on (for example) /new.
  4. debootstrap a minimal Debian installation on /new.
  5. chroot and install the rest.
1
  • Thanks for this detailed answer. Do you happen to be familiar with the Debian installer and do you know if, for the case of a raid 1 setup, any additional "special" steps are required? You noted some additional steps at the end of your answer here. Commented Sep 2, 2023 at 9:25
1

A "Workaround" Solution

I managed to get Debian 12 to install on my system. Here's how I did it.

Step 1: Disable Secure Boot (?)

This may not be an essential step, but it is something that I did. I tried to do this thinking that it might allow me to boot the installer in legacy BIOS mode.

I do not think this step had the intended consequences. I think the installer still booted in UEFI mode.

I cleared the Secure Boot keys in my motherboard BIOS. Whether or not this had any effect I am unsure, but thought it just as well to document that I had done this anyway.

Step 2: Install "as Normal" with Recommended Partitioning Scheme

During the install there is an option to proceed with a suggested partitioning scheme, or a manual one.

In my system I had a pair of NVME drives which I will eventually use for RAID, but not yet. I also have another (SATA) SSD which I intended to use as swap space.

  • Choose Guided Partitioning Scheme
  • Select SATA SSD (drive where swap space will eventually reside)
  • 3 partitions will be automatically created:
  • An EFI partition (~ 500 MB)
  • A root partition (~ 2 TB in this case)
  • A swap space (~ few GB)
  • Proceed as normal, the install should succeed

Step 3: Re-run the install, replacing the / and swap space partitions

  • Proceed with installation, but this time select Manual partitioning
  • Create 2x new partitioning schemes on each (NVME) disk
  • Setup a Software RAID, using the two disks (use /dev/sda etc not /dev/sda1 etc)
  • Setup LVM on the /dev/md0 RAID device, add a volume group
  • Create 1 partition on LVM
  • Use partition as ext4, for /
  • Use previously existing swap space and EFI partitions
  • Do not use the remaining ext4 partition which was created previously.

Caveats:

Here's a list of considerations:

  • Since the EFI partition is on a seperate disk, not backed by RAID, if this disk fails it might be hard to recover the system, since the data lives on a disk which has RAID and LVM layers
  • The previous OS still exists on the non-RAID drive. It could probably be deleted, and then GRUB could probably be updated so that this OS is no longer shown as an option at boot time
  • 3 disks are used rather than a pair. This might be considered wasteful, or not possible in some systems where there are not more than 2 NVME drive spaces, or some other limitation which restricts the number of disks to 2 (quite common in some modern micro form factor chassis, as well as laptops)
2
  • I re-attempted this on another system recently, and opted to use Ubuntu Server, although I believe the required steps should be similar. I don't know how to setup the non-raid boot partitions exactly, yet. Ubuntu Server does some special setup for this by itself. It's not clear to me how those boot partitions should be setup. See this guide: youtube.com/watch?v=rJzHpc1kQW4 Commented Nov 24, 2023 at 11:48
  • The linked guide for Ubuntu 20.04 desktop uses cloned EFI partitions. Perhaps it might be modified to suit your needs? askubuntu.com/questions/1299978/…. Commented Mar 10 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .