In this article, we will enable boot from RAID 1 on a brand new Odroid HC4 with 2 hard drives, without a need for an SD card.
Let’s power the thing up for the first time. We are greeted by the Petitboot environment, but obviously, there is no OS to boot from yet.
Step 1: prepare the RAID partitions
We will use fdisk
to create the partitions. There are tons of tutorials on using fdisk
all over the web, so let’s skip this step and see the final partitioning scheme. I’m using two old 250 GB Western Digital HDDs here (/dev/sda
and /dev/sdb
), partitioned in the following way:
- 250 MB for the boot partition
- 8 GB for swap
- the rest for the root partition
Important:
Both drives have to be partitioned identically. All partitions need to have their type set to Linux raid autodetect (option fd in the type selection list in fdisk
)
Step 2: let Petitboot know about the RAID configuration
Now we can run
# mdadm --examine --scan
to make sure that the RAID partitions can be detected. The output should look similar to this:
# mdadm --examine --scan
ARRAY /dev/md/0 metadata=1.2 UUID=6360c229:7c8b6afc:e8fb345d:a099416f name=odroid:0
ARRAY /dev/md/1 metadata=1.2 UUID=eee8d55f:fa309c30:ae8b4cd9:7302e4e7 name=odroid:1
ARRAY /dev/md/2 metadata=1.2 UUID=75ae9255:aa34593c:45f13bb1:9d0b5c82 name=odroid:2
We could store the RAID configuration by redirecting the output of the previous command to /etc/mdadm/mdadm.conf
, but this would not persist after a reboot. Instead, we need to tell Petitboot to store the settings in a non-volatile part of the memory and have them available even after a power cycle or reboot. This can be done using
# fw_setenv petitboot,mdadm $(mdadm --examine --scan)
We can check that the settings have been saved by running
# fw_printenv
Step 3: Reboot and check the RAID configuration file
Our Odroid can now be rebooted. After a reboot, we can verify that Petitboot knows about our RAID setup:
# cat /etc/mdadm/mdadm.conf
This should give us the same output as mdadm --examine --scan
from Step 2. If this is the case, we can proceed to booting from the network:
# netboot
This may take a while, but then we will be able to select the OS and start the installation. The installer will know about the RAID partitions and will use them to install the OS.