💾 Software RAID-1 setup guide
Nowadays the huge capacity HDD prices are gone quite affordable, that basically everybody can have many gigabytes of storage space in a personal computer or even in a laptop. This means tons of precious images and recordings or bookkeeping of a small bussines.
"Data is a precious thing and will last longer than the systems themselves." Tim Berners-Lee (Inventor of the World Wide Web)
There is an affordable way of protecting it against data loss with properly configured software raid level 1. This way both HDDs will store the same data automatically and in case of failure the computer can stay up and running without any loss of data. It is not a performance hog at all, runs smooth and silent in the background.
Let’s see how I set up on my home computer/server with two 1 terabyte hard-disks:
Assuming 2 identical/similar and empty HDDs which are both empty and unpartitioned in a (U)EFI compatible system. Make sure to have a backup all of the important data before begin.
- Boot up a simple live distro like a Xubuntu, or anything else preferably with
- Create new GPT partition table on each hard-disk.
parted /dev/sda mklabel gpt parted /dev/sdb mklabel gpt
- Create the same partitions on both disk:
EFI, boot, root, home, swap.
parted /dev/sda mkpart primary fat32 1MB 513MB parted /dev/sda set 1 boot on parted /dev/sda set 1 esp on parted /dev/sda mkpart primary ext4 513MB 1025MB parted /dev/sda mkpart primary ext4 1025MB 33GB parted /dev/sda mkpart primary ext4 33GB 927GB parted /dev/sda mkpart primary linux-swap 927GB 931GB
parted /dev/sdb mkpart primary fat32 1MB 513MB parted /dev/sdb set 1 boot on parted /dev/sdb set 1 esp on parted /dev/sdb mkpart primary ext4 513MB 1025MB parted /dev/sdb mkpart primary ext4 1025MB 33GB parted /dev/sdb mkpart primary ext4 33GB 927GB parted /dev/sdb mkpart primary linux-swap 927GB 931GB
- Build filesystems on the fresh partitions.
mkfs.vfat /dev/sda1 mkfs.ext4 /dev/sda2 mkfs.ext4 /dev/sda3 mkfs.ext4 /dev/sda4
mkfs.vfat /dev/sdb1 mkfs.ext4 /dev/sdb2 mkfs.ext4 /dev/sdb3 mkfs.ext4 /dev/sdb4
- Install Linux Software Raid package.
apt-get install mdadm
- Create the RAID level 1 arrays.
mdadm --create /dev/md0 --level 1 --raid-devices 2 /dev/sd[ab]2 mdadm --create /dev/md1 --level 1 --raid-devices 2 /dev/sd[ab]3 mdadm --create /dev/md2 --level 1 --raid-devices 2 /dev/sd[ab]4
- Wait until it's done syncing.
watch cat /proc/mdstat
- Install the OS on the newly created
md0 - /boot md1 - / md2 - /homeAt least it works like this on Debian and Ubuntu, but not on Linux Mint. The following steps was necessary, assuming the graphical installer is launched from the live desktop:
- After the installation is finished, do not select reboot yet. Instead open a terminal!
mount --bind /dev /target/dev mount -t proc proc /target/proc mount -t sysfs sys /target/sys chroot target apt-get install mdadm apt-get install --reinstall grub2 exit
- Reboot the computer now and enjoy RAID level 1.