Hetzner Robot

Hetzner installimage: software RAID, LVM, custom partitions

installimage installs Linux exactly as its settings file describes: on which disks, with which RAID and which partitions. By editing the file, you build RAID 0, 1, 5, 6 or 10, turn on LVM or install the system without a separate /home partition.

  • Time: 25 minutes
  • Level: Advanced

In short

  • The disks are set by the DRIVE1, DRIVE2 and following lines: every disk listed will be wiped. Comment out a disk you need to keep with #.
  • RAID is turned on by the SWRAID 1 line, and SWRAIDLEVEL sets the level: 0, 1, 5, 6 or 10. RAID 0 does not survive the failure of even one disk.
  • Partitions are set by PART lines, LVM volumes by LV lines. For no separate /home, make the root PART / ext4 all the last partition.
  • If the installation fails with an error, save /root/debug.txt before rebooting and send it to us: we pass it on to Hetzner.
Contents
  1. When you need custom partitioning
  2. How to change the installimage settings
  3. Ready-made settings for common cases
  4. If the installation failed
  5. FAQ

You will need

  • The server in the Rescue System and an SSH login to it: the first steps are in the article on reinstalling Linux on a Hetzner server.
  • A copy of the data you need: every disk on the DRIVE lines will be wiped.
  • 20–30 minutes.

When you need custom partitioning

For a regular reinstall, the default settings that installimage suggests are enough. You need to change them if:

  • you need a different RAID level: a RAID 1 mirror, RAID 10 on four disks, or RAID 0 for the full capacity;
  • the system must go on specific disks, for example on NVMe, while the HDDs stay for data;
  • you do not need a separate /home partition and want all the space to go to the root;
  • you need LVM, for example for Proxmox VE.

You can also write these wishes in the Comment field of the order window when you order a server: then our team installs the system with the partitioning you need before delivering the server.

How to change the installimage settings

installimage completely wipes every disk on the DRIVE lines. Copy the data you need before you start. If the server has a disk that must not be touched, check once more before saving the settings that its line is commented out.

  1. Connect to Rescue via SSH

    Activate Rescue in Robot, reboot the server in the Reset tab and log in as root with the Rescue password. The steps are described in the article on reinstalling Linux.

  2. See which disks the server has

    lsblk -d -o NAME,SIZE,ROTA

    Sample output for a server with two HDDs and two NVMe disks:

    NAME      SIZE ROTA
    sda       3.6T    1
    sdb       3.6T    1
    nvme0n1 953.9G    0
    nvme1n1 953.9G    0

    NAME is the disk name, ROTA its type: 1 for HDD, 0 for SSD and NVMe. In the installimage settings, the name gets /dev/ in front: /dev/sda, /dev/nvme0n1. For RAID, use disks of the same size: the array uses the capacity of the smaller one.

  3. Stop the old RAID and wipe the partitioning

    If the disks already had a system, Hetzner recommends stopping the old arrays and wiping the partition signatures before the installation. In wipefs, list only the disks the system will go on:

    mdadm --stop /dev/md*
    wipefs -fa /dev/nvme0n1 /dev/nvme1n1

    If there is nothing to keep, you can wipe all disks of one type at once: wipefs -fa /dev/nvme*n1 or wipefs -fa /dev/sd*. Do not include a data disk you want to keep in this command.

  4. Run installimage and choose an image

    installimage

    Choose the distribution and version in the menu. The editor then opens with the settings file: from here on, you edit lines in it.

  5. Set the disks on the DRIVE lines

    The installer fills in every disk it finds: DRIVE1, DRIVE2 and so on. Each of them will be wiped. To leave a disk untouched, put # at the start of its line and renumber the remaining ones so that the numbers run in order from 1. For example, the system goes on two NVMe disks, and two HDDs stay as they are:

    DRIVE1 /dev/nvme0n1
    DRIVE2 /dev/nvme1n1
    #DRIVE3 /dev/sda
    #DRIVE4 /dev/sdb
    PuTTY window, the mcedit editor with the installimage settings on a server with two NVMe drives: the lines DRIVE1 /dev/nvme0n1 and DRIVE2 /dev/nvme1n1 with comments on the disk model (serial numbers hidden), below them SWRAID 1 and SWRAIDLEVEL 1. The DRIVE and SWRAID lines are highlighted.
    The start of the file on a server with two NVMe drives: both disks are on DRIVE lines, RAID 1 is on.
  6. Turn on RAID and choose the level

    SWRAID 1
    SWRAIDLEVEL 1

    SWRAID 1 builds software RAID across all disks on the DRIVE lines; SWRAID 0 installs the system without RAID. Set the level in SWRAIDLEVEL:

    LevelDisksUsable capacityIf a disk fails
    02 or morethe sum of all disksall data is lost
    12 or morethe capacity of one diskthe server keeps running as long as at least one disk is intact
    53 or moreall disks but onesurvives the failure of one disk
    64 or moreall disks but twosurvives the failure of two disks
    104 or morehalf of all diskssurvives the failure of one disk in each pair

    If the server has a hardware RAID controller, the array on it is created before you run installimage, and the installer sees it as a single disk.

  7. Describe the partitions with PART lines

    Each PART line is one partition: mount point, file system and size. The size is written with a unit: 1024M, 8G. The word all means “all remaining space”, and such a partition goes last. A simple layout without a separate /home:

    PART /boot ext3 1024M
    PART swap swap 8G
    PART / ext4 all

    Here /boot is the boot loader partition, swap is the swap partition in case memory runs short, and the root / takes everything else. If the file has a PART /boot/efi esp 256M line, do not delete it and keep it first among the PART lines: it is needed for UEFI boot. Partitions larger than 2 TiB are only possible with GPT partitioning, and so only with a system that boots via GRUB2.

    PuTTY window, the installimage editor, the PARTITIONS / FILESYSTEMS section: the PART line format, notes (/boot cannot be on xfs or LVM, software RAID 0 needs /boot, UEFI needs a /boot/efi partition of at least 256MB) and commented-out partitioning examples without and with LVM. Both examples are highlighted.
    The file itself has partitioning examples with and without LVM in its comments. The partition sized all comes last among the PART lines.
  8. Enter the server name

    HOSTNAME server.example.com

    It is best to give the name as name.domain. Proxmox VE, for example, requires exactly this kind of name.

  9. Save the settings and start the installation

    F2 saves the file, F10 closes the editor. If the F keys do not work (this happens on a Mac), press Fn+F2 and Fn+F10, or Esc, then 2, and Esc, then 0. installimage checks the syntax and takes you back to the editor if there is a mistake. If everything is correct, confirm the data deletion and wait for the INSTALLATION COMPLETE message.

  10. Reboot and check the RAID

    reboot

    Log in to the new system with the same password as Rescue and check the state of the arrays:

    cat /proc/mdstat
    lsblk

    Each array shows its level (raid1, raid10) and its disks. Each U is a working disk: [UU] for a two-disk array, [UUUU] for four disks; an underscore in place of a U means a disk is missing from the array. A resync line means the array is syncing the disks in the background: this is normal, and you do not have to wait for it to finish.

If something went wrong, start with the section “If the installation failed” below.

Ready-made settings for common cases

The blocks below replace the lines of the same name in the installimage file. Take the disk names from the lsblk output. If there is a PART /boot/efi line, keep it first among the PART lines.

RAID 1 on two disks, without /home

DRIVE1 /dev/nvme0n1
DRIVE2 /dev/nvme1n1
SWRAID 1
SWRAIDLEVEL 1
HOSTNAME server.example.com
PART /boot ext3 1024M
PART swap swap 8G
PART / ext4 all

If one disk fails, the server keeps running, and the disk can be replaced. How to check the disks and order a replacement.

RAID 10 on four disks

DRIVE1 /dev/sda
DRIVE2 /dev/sdb
DRIVE3 /dev/sdc
DRIVE4 /dev/sdd
SWRAID 1
SWRAIDLEVEL 10
HOSTNAME server.example.com
PART /boot ext3 1024M
PART swap swap 8G
PART / ext4 all

Half the capacity goes to copies, but the array survives a disk failure and is faster than RAID 1 on two disks.

RAID 0: full capacity, no protection

SWRAID 1
SWRAIDLEVEL 0

If any disk in a RAID 0 array fails, the data on all disks of the array is lost. Choose it only if you have copies elsewhere or can afford to lose the data.

System on NVMe, HDDs left untouched

DRIVE1 /dev/nvme0n1
DRIVE2 /dev/nvme1n1
#DRIVE3 /dev/sda
#DRIVE4 /dev/sdb
SWRAID 1
SWRAIDLEVEL 1

The HDDs keep their existing data. You can partition them for new tasks from the installed system.

LVM: 100 GB root, the rest left free

PART /boot ext3 1024M
PART swap swap 8G
PART lvm vg0 all
LV vg0 root / ext4 100G

PART lvm vg0 all gives all remaining space to an LVM volume group named vg0. LV vg0 root / ext4 100G creates a 100 GB volume root in it for the system root. The rest of vg0 stays free: you can give it to virtual machine disks or new volumes. This is the layout used in the article on Proxmox VE on Hetzner.

One disk without RAID

DRIVE1 /dev/nvme0n1
SWRAID 0

Comment out the other disks if you need to keep them, or leave them in the list if they can be wiped.

If the installation failed

What you seeWhat to do
After F10, installimage opens the editor againThe installer found a mistake in the settings. Check the lines you changed: disk names, DRIVE numbers in order from 1, the all partition last, size units.
The installation stopped with an errorRun installimage again. If the error repeats, save /root/debug.txt as described below and send it to us.
Ubuntu 18.04 or 20.04 will not install with XFSThese versions cannot create XFS in the current Rescue System. Choose ext4 or a newer Ubuntu version.
After the reboot the server does not respond for more than 10 minutesActivate Rescue, reboot the server and check the settings. If Rescue does not boot, ask for a KVM console to see the screen: how to get a KVM console.

When an error occurs, the installer writes a detailed log to the file /root/debug.txt. The Rescue System runs in memory, so the file is gone after a reboot. Save it beforehand. The easiest way is to download the file to your computer: run this command in a terminal on your computer, not on the server.

scp root@203.0.113.10:/root/debug.txt .

The file appears in the folder you ran the command from. You can also print the end of the log on the screen and copy the text:

tail -n 100 /root/debug.txt

Send the file or the text in a ticket together with the error the installer showed and your DRIVE, SWRAID and PART lines. The Robot login from ABCD cannot open a ticket with Hetzner, so we pass the log on to Hetzner.

FAQ

RAID 0 or RAID 1 on two disks?
RAID 1 keeps a copy on each disk: if one fails, the server keeps running and the disk gets replaced. RAID 0 gives you the capacity of both disks, but the failure of either one destroys all data. RAID 0 suits only data that has a copy elsewhere.
How do I install the system without a /home partition?
Keep the root as the last partition with the size all: PART / ext4 all, and delete the line with /home. Then all the space after /boot and swap goes to the root.
Can I reinstall the system and keep the data on one of the disks?
Yes, if that disk is not part of the array with the system. Comment out its DRIVE line, renumber the others and leave it out of the wipefs command.
I see resync in /proc/mdstat. Is that an error?
No. After the installation, the array syncs the disks in the background; on large disks this takes hours. You can use the server meanwhile.

Did this guide help?

Questions?