01
RAID levels, simply
RAID groups several disks into a single volume. Depending on the level, it gains capacity and throughput, fault tolerance, or a bit of both. With disks of the same size:
- RAID 0 (striping): data is spread across all the disks. Full capacity and the best throughput, but no redundancy: lose one disk and the whole volume is lost.
- RAID 1 (mirror): each disk holds exactly the same data. The capacity of a single disk; the volume survives as long as one disk is still healthy.
- RAID 5: data and parity (check information used to rebuild a missing disk) are spread across all the disks. In practice at least 3 disks; the capacity of all disks minus one; it survives the loss of one disk.
- RAID 6: like RAID 5, with double parity. At least 4 disks; the capacity of all disks minus two; it survives the loss of two disks.
- RAID 10: mirrored pairs, striped together. Usually at least 4 disks; half the capacity; it survives the loss of one disk per pair, but not of both disks in the same pair.
Which level should you choose? With two disks, RAID 1. For virtual machines or databases on four disks or more, RAID 10, which avoids computing parity on every write. For a lot of capacity, RAID 6 rather than RAID 5: after one disk fails, a RAID 5 has no protection left for the whole rebuild, whereas a RAID 6 still has one level. RAID 0 only makes sense for data you can lose without regret, such as a cache.
ZFS, offered by the Proxmox installer, has its own equivalents: mirror for RAID 1, RAID10, and RAIDZ-1, RAIDZ-2 or RAIDZ-3 for one, two or three parities.
02
RAID is not a backup
RAID protects against one thing only: the failure of a disk (or two, depending on the level). It keeps the server running while the disk is replaced. It does not protect against:
- a file deleted or overwritten by mistake: the deletion is copied to every disk instantly;
- ransomware, an application that corrupts its data, a failed update;
- a failure of the server itself, a wrong move during a rebuild, or an incident that affects the whole machine.
A backup is a copy stored somewhere else, with several versions over time. On Linux, restic or borg send it to another server (see first steps on a dedicated server); on Proxmox, a Proxmox Backup Server installed on another machine; on Windows, the method in Windows Server on a dedicated server. RAID and backups work together: the first avoids downtime, the second avoids data loss.
03
Linux software RAID: monitoring with mdadm and smartctl
On Linux, software RAID is handled by the kernel (the volumes /dev/md0, /dev/md1…) and by the mdadm tool. The state of every volume fits in one file:
cat /proc/mdstat
For a healthy mirror, the volume's line ends with [2/2] [UU]: two disks expected, two in service. [2/1] [U_] means a degraded volume, missing one disk. During a rebuild, a recovery line shows the progress as a percentage. For the details of one volume:
sudo mdadm --detail /dev/md0
The State line reads clean when all is well and contains degraded when a disk is missing; the list at the bottom shows each disk as active sync, faulty or removed.
Getting alerts. A degraded volume keeps working silently: without an alert, you only discover the failure when the second disk goes. On Debian and Ubuntu, set your address in /etc/mdadm/mdadm.conf:
MAILADDR admin@exemple.fr
mdadm's monitoring then sends an email when a disk is marked as failed or a volume becomes degraded. The server must be able to send email (a configured mail transfer program). Test it with sudo mdadm --monitor --scan --oneshot --test, which sends a test message for each volume. A full check, which reads every block and compares the copies, starts with echo check | sudo tee /sys/block/md0/md/sync_action; its progress appears in /proc/mdstat.
Disk health. RAID reacts when a disk drops out; the disks' SMART data often announces the failure earlier:
sudo apt install smartmontools
sudo smartctl -H /dev/nvme0
sudo smartctl -a /dev/nvme0
-H gives the health status, -a all the information (for a SATA disk, the name looks like /dev/sda). For automatic alerts, the smartd service reads /etc/smartd.conf: a line DEVICESCAN -a -m admin@exemple.fr -M test monitors every disk and sends a test email when the service starts. Then restart it (sudo systemctl restart smartmontools on Debian and Ubuntu). These checks complement the monitoring described in monitoring a server's resources.
04
Replacing a disk in an mdadm RAID
Take a mirror /dev/md0 made of /dev/sda1 and /dev/sdb1, where /dev/sdb has failed. The names are examples: read yours in mdadm --detail.
- Note the serial numbers of the failed disk and of the healthy ones:
lsblk -o NAME,SIZE,MODEL,SERIAL. Names like /dev/sdb can change from one boot to the next; the serial number does not. That is what you give for the swap.
- Remove the disk from the volume. If it is not already marked as failed, mark it, then remove it:
sudo mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1. Do the same for every volume that uses a partition on that disk.
- Have the disk replaced. On a dedicated server, report the failure by ticket, giving the serial number of the disk to replace.
- Copy the partition table from the healthy disk to the new one, then give it new identifiers:
sudo sgdisk /dev/sda -R /dev/sdb
sudo sgdisk -G /dev/sdb
Check the direction three times: the healthy disk comes first. Reversed, the command wipes the table of the only disk that still holds your data.
- Add the new partition to the volume and watch the rebuild:
sudo mdadm /dev/md0 --add /dev/sdb1
watch cat /proc/mdstat
- Booting: if the replaced disk carried boot files, reinstall the boot loader on the new disk, for example
sudo grub-install /dev/sdb on a system that boots with GRUB in BIOS mode. The method depends on the installation: if in doubt, ask by ticket before rebooting.
During the rebuild, every remaining disk is read in full: it is a time of heavy load and risk. Do not reboot, and make sure your latest backup is recent.
05
ZFS on Proxmox: zpool status
The Proxmox installer offers ZFS as RAID0, RAID1 (at least 2 disks), RAID10 (at least 4), RAIDZ-1 (at least 3), RAIDZ-2 (at least 4) and RAIDZ-3 (at least 5). The Proxmox documentation advises against putting ZFS on a hardware RAID controller that manages its own cache: ZFS must see the disks themselves. If you plan to use ZFS, say so when ordering. Installation is covered in Proxmox on a dedicated server.
zpool status -x
zpool status -v
zpool status -x only shows pools that have a problem: all pools are healthy means all is well. zpool status -v gives the details, disk by disk: ONLINE when all is well, DEGRADED when a disk is missing. A zpool scrub rpool reads all the data and verifies its checksums; run one from time to time, at a quiet hour.
Alerts. The ZED daemon, installed by default on Proxmox, watches ZFS events. It sends its emails to the address in ZED_EMAIL_ADDR, in /etc/zfs/zed.d/zed.rc, which is root by default: make sure root's emails actually reach you.
Replacing a boot disk, following the Proxmox documentation, with /dev/sda healthy and /dev/sdb new:
sgdisk /dev/sda -R /dev/sdb
sgdisk -G /dev/sdb
zpool replace -f rpool ANCIEN-DISQUE NOUVELLE-PARTITION-ZFS
proxmox-boot-tool format /dev/sdb2
proxmox-boot-tool init /dev/sdb2
ANCIEN-DISQUE is the name shown by zpool status for the missing disk, and NOUVELLE-PARTITION-ZFS the partition of the new disk with the same number as the ZFS partition on the healthy disk (lsblk shows them). Partition 2 is the boot partition (ESP) created by the Proxmox installer since version 5.4; if proxmox-boot-tool status shows that the system boots with GRUB, replace the last line with proxmox-boot-tool init /dev/sdb2 grub. For a pool that is not used for booting, zpool replace -f is enough. Then follow the rebuild (the "resilver") with zpool status -v.
06
RAID on a CloudFive dedicated server
On our dedicated servers, from €75 per month, RAID is available: specify the level you want when ordering, or request it by ticket. On delivery, check its state with the tool that matches your installation, and ask by ticket if in doubt.
- Storage: 2 TB NVMe included on the Ryzen servers. For a mirror or more capacity, disks can be added: NVMe at €15 per TB per month, SSD at €10. The page storage dedicated server presents these options.
- Disk failure: report it by ticket, with the serial number of the disk concerned.
- Console: no remote console access, except the iDRAC on the 2x Xeon Gold 6254. If the server no longer boots after a disk swap, only support can step in: hence the importance of the boot loader on every disk.
- Backups: they remain your responsibility, outside the server, as explained above. The guide securing a dedicated server completes the setup.
The servers are in France, with no commitment and no setup fee, delivered in 24 to 72 hours with Debian, Ubuntu, Proxmox, Virtualizor or Windows. Options are requested by ticket from the customer area, manager.cloudfive.fr, and support answers in French 7 days a week, by ticket, on Discord and by phone.
07
Frequently asked questions
Does RAID replace a backup?
No. RAID keeps the server running when a disk fails, but it also copies deletions, corruption and files encrypted by ransomware. A backup is a copy stored on another machine, with several versions over time.
Which RAID level should I choose for a dedicated server?
RAID 1 with two disks, RAID 10 with four disks or more for virtual machines or databases, RAID 6 for a lot of capacity. RAID 5 no longer protects anything during the rebuild after a failure, and RAID 0 has no redundancy at all.
How do I know if an mdadm RAID is degraded?
Read /proc/mdstat: a healthy mirror shows [2/2] [UU], a degraded one [2/1] [U_]. The command mdadm --detail /dev/md0 shows degraded on the State line. Set MAILADDR in mdadm.conf to receive an email at the next failure.
How do I replace a disk in a Linux software RAID?
Remove the disk with mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1, have it replaced by giving its serial number, copy the partition table from the healthy disk with sgdisk, then add the partition with mdadm /dev/md0 --add /dev/sdb1. Reinstall the boot loader if the disk carried one.
Is RAID available on CloudFive dedicated servers?
Yes. Specify the RAID level you want when ordering or request it by ticket. The Ryzen servers include 2 TB NVMe, and disks can be added: NVMe at €15 per TB per month, SSD at €10 per TB per month.