Recently, I ordered an EX41 server at Hetzner, which by default comes with two 4 TB HDDs in a software RAID1. I chose the minimal Debian Jessie Image. From Hetzner’s EX40, which has two 2 TB drives in a Software RAID1, I was used to find the whole drive formatted as one partition by Hetzner. But with the EX41, it turned out that the 4 TB were split: The root partition / was 2 TB of size and 1.7 TB were allocated to /home. As the application that should run on this server needs more than 2 TB space in one folder, I repartitioned the server. If somebody else has a similar issue, here is how it can be done:
- Edit /etc/fstab and remove or comment (by placing a # at the beginning) the line that mounts /home from /dev/md3
- Reboot into the Rescue system or some other system that is not on the same drive. (The Hetzner rescue system boots from network. On a local system, you would boot a linux from CD or USB.)
- Check the Raid status and setup:
cat /proc/mdstat md3 : active raid1 sda4[0] sdb4[1] 1777751872 blocks super 1.2 [2/2] [UU] bitmap: 0/14 pages [0KB], 65536KB chunk md2 : active raid1 sda3[0] sdb3[1] 2111700992 blocks super 1.2 [2/2] [UU] bitmap: 0/16 pages [0KB], 65536KB chunk md1 : active raid1 sda2[0] sdb2[1] 523712 blocks super 1.2 [2/2] [UU] md0 : active raid1 sda1[0] sdb1[1] 16760832 blocks super 1.2 [2/2] [UU]
So here md3 is the raid array that we want to get rid of together with its partitions sda4 and sdb4. md2 the raid array that we want to grow in size.
- First let’s get rid of the md3:
mdadm --stop /dev/md3 mdadm --zero-superblock /dev/sda4 mdadm --zero-superblock /dev/sdb4 parted /dev/sda rm 4 parted /dev/sdb rm 4
- Resize the partitions of md2 (sda3 and sdb3):
(Adjust the end if necessary)parted /dev/sda (parted) resize 3 (END?) 4000GB (parted) quit parted /dev/sdb (parted) resize 3 (END?) 4000GB (parted) quit
Note: Tomas pointed out in the comments that the resize-command was removed and replaced with resizepart in current versions of parted. So the command is now:
parted /dev/sda (parted) resizepart 3 4000GB (parted) quit
(then do the same for sdb)
- Let the raid array md2 grow:
mdadm --grow /dev/md2 --size=max
- Check the raid status:
cat /proc/mdstat Personalities : [raid1] md2 : active raid1 sda3[0] sdb3[1] 3888815376 blocks super 1.2 [2/2] [UU] [===================>.] resync = 97.8% (3807048128/3888815376) finish=13.3min speed=101952K/sec bitmap: 1/15 pages [4KB], 131072KB chunk
- Wait until the resync finished (took a few hours for 2 TB):
cat /proc/mdstat Personalities : [raid1] md2 : active raid1 sda3[0] sdb3[1] 3888815376 blocks super 1.2 [2/2] [UU] bitmap: 0/15 pages [0KB], 131072KB chunk
- Check the filesystem:
e2fsck -fv /dev/md2
- Resize the filesystem:
resize2fs /dev/md2
- Reboot into your normal system and you are done:
reboot
- Check the free disk space:
df -h
It should give the new size of / (3.6 TB) and a lot more free space 🙂
Hope this helps somebody with the same or similar issue.
Thank you, had the same problem and this worked well. Just a note, resize in current version requires a different syntax:
root@rescue ~ # parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) resize 3
Error: The resize command has been removed in parted 3.0
(parted) resizepart 3 4000GB
(parted) quit
Information: You may need to update /etc/fstab.
Comment by Tomas — 28. February 2017 @ 09:02
Do not forget to configure the backup on the RAID array in automatic mode. If you have problems with the data, you can use RAID Recovery https://www.diskinternals.com/raid-recovery/ This is a good decision.
Comment by Wallent — 6. November 2020 @ 14:09
Thank you much for sharing. Exactly what I needed.
Comment by Stephane — 21. March 2021 @ 00:30