Configure Hetzner RAID storage

Rescue mode

To enter rescue mode, do it via the Hetzner dashboard. The username is root, and the password will be autogenerated. Copy-paste the password since it will be used for login after the rescue is done.

In rescue mode you need to delete all software RAID created already.

Read more at the Hetzner docs.

When in rescue mode list all raid disks.

ls /dev | grep "md"

# Delete all mdX from the 
mdadm --remove /dev/md0
...

# Stop all mdX from the 
mdadm --stop /dev/md0
...

# Make filesystem for all disks that were in RAID
mkfs.ext3 /dev/sda
...

The commands above should be executed for all the mdX found in the ls /dev | grep "md".

💡
For large disks use mkfs.ext4 /dev/sdX!

Configuring RAID1 for OS with installimage

After running commands for all RAID groups and making the filesystem for the disk start installimage.

installimage

It will open up interactive installer. Choose OS and proceed till you get text editor which is installation configuration.

# nvmeXX
DRIVE1 /dev/nvmen01
# nvmeXX
DRIVE2 /dev/nvmen02

# SSDXXXX
#DRIVE3 /dev/sda
# SSDXXX
#DRIVE4 /dev/sdb

Configure RAID1 in this installer only for the disk where OS will be installed. Comment out all drives in that file which are not to be in RAID1.

In the example above 4 disks and only DRIVE1 and DRIVE2 will be part of the RAID1. Doing it this way we hand over to Hetzner to configure correct OS booting if one drive fails.

DRIVE3 and DRIVE4 will not be part of the RAID1 in the initial step. We will do it later.

After installation ssh into the machine and proceed with configuring RAID1 for the DRIVE3 and DRIVE4.

Format disks

If disk size is <2TB

fdisk /dev/sdX
-> n
-> You will get size sector range (X,Y)
-> Start: X
-> End: Y
-> Hex code: enter
-> p
-> w

If disk size is >2TB

-> n
-> You will get size sector range (X,Y)
-> Start: X
-> End: Y
-> Hex code: enter
-> p
-> w

Configure RAID for disks

This example has two disks and will configure RAID1 also for these disks. Disks will have two partitions: sda1 and sdb1.

# Name here is choosen as /dev/md3 you will choose the one which is not existing already
# You can check it as ~ ls /dev and inspect the contents
mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
mkfs.ext4 -F /dev/md3

Naming for the RAID is chosen as /dev/md3 since it was next available because of the balance in the universe.

Mount surviving reboots

Find disk UUID.

ls -l /dev/disk/by-uuid

Find UUID for the /dev/md3 (in this example, since it was used as a name for RAID).

Run the nano on the fstab (as root or sudo).

nano /etc/fstab

Append the line at the bottom.

UUID={{ UUID FOR THE SPECIFIC RAID}} /mnt/data ext4 auto 0 0

Save the file and test /etc/fstab before rebooting!

mkdir /mnt/data
mount -a

If no errors occured you will have disks mounted at the /mnt/data. On the every start of the system /etc/fstab will take care of mounting it again.

RAID can be inspected with the lsblk.