Skip to content
Log In Sign Up info@muvcloud.com

How Mirroring Works

In RAID 1, every write goes to all members of the mirror. The array appears to the operating system as one device, for example /dev/md0, and the file system on it does not know that there are two disks underneath. Reads can come from any member, because each one holds the same blocks.

A mirror usually has two disks. Linux software RAID also accepts three or more, which keeps one more copy of the same data for each disk you add.

Capacity and Failures

DisksUsable capacityDisks that may fail
2 × 4 TB4 TB1
3 × 4 TB4 TB2
4 TB + 8 TB4 TB1

Usable capacity is always the size of one disk, the smallest one when the sizes differ. The mirror stays readable as long as one member works.

Read and Write Speed

  • Reads: the Linux md driver spreads reads across the members, so several programs reading at once can get more than one disk's worth of speed. A single sequential read usually runs at the speed of one disk.
  • Writes: every block is written to each disk, so writes run at about the speed of the slowest member.
  • Degraded: with one disk gone, a two-disk mirror works at the speed of the remaining disk.

Create a RAID 1 Array with mdadm

Warning: creating an array overwrites the disks you name. Back up anything on them first, and confirm the device names with lsblk before you type the command, because device names can change between boots:

lsblk -o NAME,SIZE,TYPE,MOUNTPOINT

The two disks should show no partitions in use and no mount point. Then two commands build the mirror and put a file system on it:

sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
sudo mkfs.ext4 /dev/md0

Save the array in the configuration so it is assembled at boot. On Ubuntu and Debian:

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u

On AlmaLinux and Rocky Linux the file is /etc/mdadm.conf and the second command is sudo dracut -f. Mounting, fstab, and the other levels are covered in mdadm RAID: set up software RAID on Linux.

Watch the Array

cat /proc/mdstat
sudo mdadm --detail /dev/md0

In /proc/mdstat, a healthy two-disk mirror shows [UU]; an underscore in place of a U means a member is missing. The mdadm monitoring service can send a mail when an array degrades: set the MAILADDR line in mdadm.conf, and make sure the server can send mail. A mirror only tells you that a disk has already failed, so also read each disk's SMART data with smartctl to see wear and errors earlier.

Replace a Failed Disk

Warning: failing the wrong member takes away the only good copy. First run sudo mdadm --detail /dev/md0 and confirm which device is marked faulty; the example assumes it is /dev/sdc. Then mark it as failed and remove it from the array:

sudo mdadm --manage /dev/md0 --fail /dev/sdc --remove /dev/sdc

After the new disk is in place, check its name with lsblk again and add it:

sudo mdadm --manage /dev/md0 --add /dev/sdd

The rebuild copies the whole surviving disk to the new one, and /proc/mdstat shows its progress. If the mirror holds the system, the new disk also needs the same partitions and a boot loader.

Where RAID 1 Fits

  • System disks: the operating system keeps running when one disk dies.
  • Small servers: two disks give redundancy with no parity math and simple rebuilds.
  • Boot disks beside a larger array: a pair of small disks for the system, another level for the data.

RAID 1 Is Not a Backup

A mirror copies every change at once, including a deleted folder, a damaged file system, or files encrypted by an attacker. It protects against a failed disk and nothing else. Keep separate copies as described in snapshot vs backup.

Other RAID Levels

  • RAID 0: stripes data across disks for speed, with no redundancy at all.
  • RAID 5: one disk of parity across three or more disks.
  • RAID 6: two disks of parity, so two disks may fail.
  • RAID 10: a stripe of mirrors for speed and redundancy.

To compare capacity for any number of disks, use the RAID calculator and levels overview.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations