Setup LVM on Hetzner and use all drives

I have been using Hetzner for a while and the Rescue System can be confusing, so I’m going to help you setup LVM to use all drives if you’ve got a multi-drive server.

First I’m going to configure the installimage and disable software RAID, because I don’t need it.

Then I will configure the partitions and LVM. So the installimage should look like this:

SWRAID 0
PART /boot ext3 512M
PART lvm vg0 all
LV vg0 root / ext4 50G
LV vg0 swap swap 4G
LV vg0 tmp /tmp reiserfs 5G
LV vg0 home /home ext4 50G

Make sure to comment their default drive configuration and then you’re ready to go.

After you boot in your newly installed operating system, there isn’t much left to do.

First you have to add a physical volume to LVM (one for each drive):

pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1

Then we’ll extend the volume group with the newly added physical volumes:

lvextend vg0 /dev/sdb1 /dev/sdc1 /dev/sdd1

Now we add all the free space we have left to the logical volume:

lvextend -l +100%FREE /dev/vg0/root

And finally we extend the file system:

resize2fs /dev/mapper/vg0-home

Now you can mount it:

mkdir /storage
mount /dev/mapper/vg0-home /storage

Please note that resize2fs only works with ext4. If you want to use XFS you will have to use xfs_growfs.

Leave a Reply

Your email address will not be published. Required fields are marked *