You are not logged in.

#1 2020-12-26 00:06:53

KaibutsuX
Member
Registered: 2015-04-22
Posts: 20

Question on expanding a LUKS encrypted RAID5

I wanted to post this in sys admin but I don't think I have permission.

I currently have a 4 drive (4 x 10TB) RAID5 array (30TB usable) setup as a LUKS partition which then has a single ext4 filesystem on it.

I am looking to expand the usable space to 40TB with +1 10TB drive.

Can anyone point me to anything definitive for this process? I've found all kinds of forum posts and old blogs but nothing that appears relatively recent and they all have tons of opinions opinions, guesses and disclaimers about data loss.

Obviously I know there's always a chance of data loss, but I'd hope to hit that scenario with unlikely circumstance, not because I'm following some rando's blog who didn't know what they were doing.

My basic understanding of the process is:
1) Unmount, cryptclose aand essentially turn off the RAID
2) Expand the RAID with mdadm and rebuild (takes a long time)
3) Here's where I'm kind of lost, I know I need to expand the filesystem to fill the new size, but I'm unsure if I need to expand the luks or the ext4 or both and how either of those work.

Offline

#2 2020-12-26 03:25:38

frostschutz
Member
Registered: 2013-11-15
Posts: 1,409

Re: Question on expanding a LUKS encrypted RAID5

mdadm --grow, cryptsetup resize (or close, open, or reboot), resize2fs, ...

if there are other storage layers in the mix (lvm?) you have to resize those too

growing raid is an online process so, no particular need to "umount, turn off" anything. of course, that's only as long as things don't go terribly wrong. if you never tested your drives do that (smartctl -t long) before you rebuild... detecting drive failures during a reshape is not very nice

Offline

#3 2020-12-30 17:11:36

KaibutsuX
Member
Registered: 2015-04-22
Posts: 20

Re: Question on expanding a LUKS encrypted RAID5

Thanks, seems fairly straightforward. Before start the grow process do I need to do anything with crypt on the new drive? This is what a portion of my lsblk looks like now:

sdd                                                                                      
└─sdd1         linux_raid_member mediaServer:Media 74cd9e43-0c41-ffb1-5396-4ad439ccdf8c   
  └─md127      crypto_LUKS                                        afc83228-f4b0-4fec-a930-03e7362f03f2   
    └─media    ext4                               ca7d0aa6-f66d-4c1b-ba1c-9e499a5a3c56   /media
sde                                                                                      
└─sde1         linux_raid_member mediaServer:Media 74cd9e43-0c41-ffb1-5396-4ad439ccdf8c   
  └─md127      crypto_LUKS                        afc83228-f4b0-4fec-a930-03e7362f03f2   
    └─media    ext4                               ca7d0aa6-f66d-4c1b-ba1c-9e499a5a3c56   /media
sdf                                                                                      
└─sdf1         ntfs              Elements         4E40D5D240D5C13F

sdf is the new drive straight from the package.

Do I need to partition the new drive in any way? Normally I would assume I would need to partition and format to ext4 but with luks mixed in I'm not sure of the steps.

Offline

#4 2020-12-30 18:09:06

frostschutz
Member
Registered: 2013-11-15
Posts: 1,409

Re: Question on expanding a LUKS encrypted RAID5

Ideally, the new partition (sdf1?) should have the same size as the others (sde1, sdd1, ...) that are already part of your MD array.

You don't want to "format to ext4", that would create a new empty filesystem, but you want to grow your existing MD array, so mdadm --grow takes care of that.

Roughly, untested:

# umount new drive
umount /dev/sdx1 /dev/sdx
# clean the new drive
wipefs -a /dev/sdx1 /dev/sdx
# partition new drive
parted /dev/sdx mklabel gpt mkpart md127-04 1MiB 100%
# grow raid from 4 to 5 drives
mdadm --grow /dev/md127 --raid-devices=5 --add /dev/sdx1
# wait for grow to finish (watch /proc/mdstat for progress)
mdadm --wait /dev/md127
# grow luks (if currently active, otherwise optional)
cryptsetup resize luksname
# grow ext4
resize2fs /dev/mapper/luksname

Last edited by frostschutz (2020-12-30 18:10:42)

Offline

#5 2021-01-09 03:30:11

KaibutsuX
Member
Registered: 2015-04-22
Posts: 20

Re: Question on expanding a LUKS encrypted RAID5

Thank you! This worked great!

Offline

Board footer

Powered by FluxBB