Changes
Page history
more LVM/RAID adventures in home lab
authored
Feb 10, 2025
by
anarcat
Show whitespace changes
Inline
Side-by-side
howto/raid.md
View page @
daf5ef8d
...
...
@@ -33,6 +33,70 @@ drive models.
Note that Hetzner also has
[
pretty good documentation on how to deal
with SMART output
](
https://wiki.hetzner.de/index.php/Seriennummern_von_Festplatten_und_Hinweise_zu_defekten_Festplatten/en
)
.
## Building a new array
Assume our new drives are
`/dev/sdc`
and
`/dev/sdd`
, and the highest array we have is
`md1`
, so we're creating a new
`md2`
array:
1.
Partition the drive. Easiest is to reuse an existing drive, as
above:
sfdisk -d /dev/sda | sfdisk --no-reread /dev/sdc --force
sfdisk -d /dev/sda | sfdisk --no-reread /dev/sdd --force
Or, for a fresh new drive in a different configuration, partition
the whole drive by hand:
for disk in /dev/sde /dev/sdd ; do
parted -s $disk mklabel gpt &&
parted -s $disk -a optimal mkpart primary 0% 100%
done
2.
Create a RAID-1 array:
mdadm --create --verbose --level=1 --raid-devices=2 \
/dev/md2 \
/dev/sde1 /dev/sdd1
Create a RAID-10 array with 6 drives:
mdadm --create --verbose --level=10 --raid-devices=6 \
/dev/md2 \
/dev/sda1 \
/dev/sdb1 \
/dev/sdc1 \
/dev/sdd1 \
/dev/sde1 \
/dev/sdf1
3.
Setup full disk encryption:
cryptsetup luksFormat/dev/md2 &&
cryptsetup luksOpen /dev/md2 crypt_dev_md2 &&
echo crypt_dev_md2 UUID=$(lsblk -n -o UUID /dev/md2 | head -1) none luks,discard | tee -a /etc/crypttab &&
update-initramfs -u
With an on-disk secret key:
dd if=/dev/random bs=64 count=128 of=/etc/luks/crypt_dev_md2 &&
chmod 0 /etc/luks/crypt_dev_md2 &&
cryptsetup luksFormat --key-file=/etc/luks/crypt_dev_md2 /dev/md2 &&
cryptsetup luksOpen --key-file=/etc/luks/crypt_dev_md2 /dev/md2 crypt_dev_md2 &&
echo crypt_dev_md2 UUID=$(lsblk -n -o UUID /dev/md2 | head -1) /etc/luks/crypt_dev_md2 luks,discard | tee -a /etc/crypttab &&
update-initramfs -u
From here, the array is ready for use in
`/dev/mapper/crypt_dev_md2`
. It will be resyncing for a while, you can
see the status with:
watch -d cat /proc/mdstat
You can either use it as is with:
mkfs -t ext4 -j /dev/mapper/crypt_dev_md2
... or add it to LVM, see
[
LVM docs
](
howto/lvm
)
.
# Hardware RAID
Note: we do not have hardware RAID servers, nor do we want any in the
...
...
...
...