Skip to content

Instantly share code, notes, and snippets.

@rhizome
Last active February 13, 2021 05:38
Show Gist options
  • Save rhizome/4ae9c9aeaa9b054860fa5d639f250416 to your computer and use it in GitHub Desktop.
Save rhizome/4ae9c9aeaa9b054860fa5d639f250416 to your computer and use it in GitHub Desktop.
Resizing a RAID 1 mirror on Debian with mdadm, fdisk, and resize2fs
# Logical Structure:
# +-----------------------------------+
# | +--------------------------+ |
# | | +------------+ | |
# | RAID | Partition | Filesystem | | |
# | | +------------+ | |
# | +--------------------------+ |
# +-----------------------------------+
# unmount RAID
umount /media/All
# remove the drive to be enlarged or swapped out
# be sure to specify only the partition device, not the entire drive device
mdadm /dev/md1 --fail /dev/sdb1 --remove /dev/sdb1
# delete partition and recreate larger one on top of existing data. data will survive.
# steps: https://unix.stackexchange.com/posts/320454/revisions
fdisk /dev/sdb
# partitions are now the same size. enlarge the RAID config
mdadm --grow /dev/md1 -z max
# check the RAID for errors
e2fsck -f /dev/md1 -y
# enlarge the RAID filesystem
resize2fs /dev/md1
# mount the RAID
mount -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment