Nuts and Bolts Software RAID Lead image: Photo by Mirko Blicke on Unsplash
Photo by Mirko Blicke on Unsplash
 

Software RAID in Windows, macOS, and Linux

Solid Foundation

If RAID hardware is missing on your server, Windows, Linux, and macOS offer various options for building software RAID. By Thomas Joos

Windows, Linux, and macOS offer a wide range of alternatives for creating software RAID data storage. However, RAID as a software solution does not make sense in some cases because the performance is less than optimal and parity information is not calculated by a dedicated processor. Additionally, it does not support hot swap – that is, the ability to replace hard drives on the fly. Hardware solutions are generally recommended for RAID (redundant array of independent disks) systems, but sometimes admins might find software RAID on their servers useful.

Software RAID in Windows

In addition to storage pools, legacy disks, spanned volumes, and striped volumes, Windows Server allows you to create a software-based RAID5 system, as well as a mirrored volume that requires two hard drives to which all information is written and from which you can boot. If you are creating a disk that spans more than one physical drive, you need to select the disks that you want to include when defining the drive type. For the configuration, use the Disk Management tool, which you launch by calling diskmgmt.msc. For software RAID in Windows Server 2019, you can also use the resilient filesystem (ReFS). Creating and managing software RAID will be similar to using NTFS, with the benefit of the higher stability of ReFS.

Setting Up Disks

After initializing, you can view and set up the volumes in Disk Manager. If you are configuring a specific storage system, such as software RAID or a storage pool, and you need to convert a hard drive, you are automatically prompted. Once the disks are established, you can set them up with logical drives. The drives, simply referred to as "Disk 0," "Disk 1," and so on, in Windows Server, can be created with the New Simple Volume option in the context menu of the free space you will be using.

If you right-click directly on the data carrier in the left pane instead of on the free space to the right, you will also see the options for a New Spanned Volume and a New Striped Volume in addition to New Mirrored Volume and New RAID-5 Volume (Figure 1).

You can create new volumes, including software RAID, in the Disk Management system utility.
Figure 1: You can create new volumes, including software RAID, in the Disk Management system utility.

Repairing Software RAID

If you create a volume that spans multiple drives, you can repair it from the context menu should the need arise (e.g., if one of the disks fails or you replace a disk). Windows points out in the Disk Management system utility that some follow-up work is needed for spanned volumes. In this case, the context menu for the disk displays more settings options at the bottom.

If an extended volume fails because a physical hard drive can no longer be accessed, the Repair Volume option appears, assuming that Windows finds an empty volume that can be used to repair the extended volume. If you select this menu item, Windows automatically suggests the physical drive that will be used to recover the spanned volume. If a physical hard drive of a RAID5 volume is defective, you need to replace the disk, restart Windows, and select Repair Volume from the context menu. You do not have to initialize the data carrier, but you can switch it to the online state.

If you just temporarily disconnect a physical hard drive from the system and then reconnect it, you do not need to repair the volume; rather, you "reactivate" it from the disk's context menu. However, if a physical disk in a spanned volume fails, Windows disables it in Explorer if access is no longer technically possible. Choosing Reactivate Volume (Figure 2) lets you reactivate the disk in this case (e.g., to back up the data).

Volumes that have been disabled by the system can be put back into operation in the Disk Management overview of disks.
Figure 2: Volumes that have been disabled by the system can be put back into operation in the Disk Management overview of disks.

Software RAID in macOS

The option of merging hard disks to form RAID groups is also available in macOS: RAID0 for better performance, RAID1 for higher availability, and JBOD (just a bunch of disks) for concatenating smaller drives. The File | RAID Assistant menu in Disk Utility (Figure 3) lets you select which RAID system you want to configure. As mentioned, you have three options from which to choose:

macOS can handle three different RAID configurations.
Figure 3: macOS can handle three different RAID configurations.

After selecting the hard drives you want to include in the new RAID array, name and choose the filesystem to be used. You also need to specify the Chunk size. If you enable the Automatically rebuild (RAID1) option, the RAID drive can repair itself if a disk fails and you install a new disk to the system. You can also recover manually when reconnecting a hard disk in Disk Utility.

The RAID system is available as a traditional drive in the Finder. If you click on the RAID system in Disk Utility, information about the disk appears on the right side in the application window. At the top is listed the free and occupied storage space, with the total capacity and hard drives involved, and the status of the RAID and disk. The Status should always be Online; anything else means a hard drive has failed. You can add additional disks by pressing the plus button under the RAID set window.

If a hard disk in the macOS RAID fails and you install a new drive, you can start a recovery process by pressing the Restore button at the top. You also need to follow this procedure if you remove a disk from the computer that was part of a RAID setup.

Linux RAID Choices

In Linux, RAID is often referred to as MDRAID or MD/RAID. The implementation of software RAID is mostly handled by the mdadm driver, which is available in many Linux distributions. Linux supports more software RAID configurations than Windows or macOS:

Which RAID system you use depends mostly on the number of hard disks available on the system.

Preparations for Linux RAID

If mdadm is not available on your Linux system, install the driver with:

sudo apt install mdadm

The mdadm --help command takes you to the help feature for the command (Figure 4). To create a RAID1 system in Ubuntu, use the command:

sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb
The mdadm command lets you create software RAID on Linux systems.
Figure 4: The mdadm command lets you create software RAID on Linux systems.

When you are installing Linux RAID, you need to make a note of drive serial numbers. If a drive fails, it is easier to recover if the serial number can be used to identify exactly which drive failed. To do this, install the Smartmontools and use either of two the commands that follow:

apt-get install smartmontools
hdparm -i /dev/sd<Drive> | grep Serial
smartctl -i /dev/sd<Drive>

Before setting up a RAID system on Linux, you need to create a new partition table with the general command:

parted /dev/sd<Drive> mklabel gpt

For example, to create a partition on 100 percent of the disk space of a drive, use the command:

parted -a optimal -- /dev/sd<Drive> mkpart primary 2048s 100%

You can configure a partition as RAID-capable with:

parted /dev/sd<Drive> set 1 raid on

A RAID6 system is created with:

mdadm --create /dev/md0 --level=6 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde

Next, save the RAID configuration by creating a configuration file:

mdadm --examine --scan --verbose > /etc/mdadm/mdadm.conf

You can format a RAID5 system with the ext4 filesystem, for example, with the command:

mkfs.ext4 -v -m 1 -b 4096 -E stride=128,stripe-width=256 /dev/md0

To mount the RAID, enter:

mkdir /mnt/raid
mount /dev/md0 /mnt/raid

Finally, to mount the RAID automatically when you boot your Linux computer, add the line

/dev/md0 /mnt/raid ext4 defaults 0 0

to the /etc/fstab file.

RAID with the ZFS Filesystem

In addition to software RAID created with the mdadm driver, highly available data carriers can also be set up with the ZFS filesystem, which is often used on Linux-based network-attached storage (NAS) systems. ZFS supports all the features of a modern filesystem, and you can create software RAID just as easily as setting quotas, enabling compression, and taking snapshots. ZFS can provide highly available data storage without the additional tools and drivers that connect the existing physical drives in a highly available manner.

Thanks to its structure, an advantage of ZFS is no risk of data loss in the event of a power failure. When the system restarts, the filesystem is automatically available and consistent. ZFS also has an integrated snapshot function. Although it does not replace full data backup, it does provide some protection. If individual files are deleted, they can be restored with the snapshot function. Of course, a data backup must be available to provide protection against the potential failure of entire disk arrays.

To use RAID with the ZFS filesystem, ZFS needs to be installed retroactively in most distributions. The commands are

sudo apt-get install zfsutils-linux
sudo apt-get install zfs-dkms

for Ubuntu 18.04 LTS (top line) and Debian (bottom line).

Conclusions

Windows, Linux, and macOS offer a wide range of alternatives that establish hardware solutions for safeguarding data with software RAID data storage. In particular, Linux offers choices among various filesystems and tools. Finding out which is best for your individual case will involve some experimenting. On some Linux systems, RAID can be created with the assistance of wizard-based setups, especially if you are using ZFS.