fbpx

Creating RAID 1 mirror with additional server hard drives

Most Servers come with additional hard drives as a standard or addon feature. It can be a great opportunity to use these as an additional backup location (remember to store backups off site) and making it a raid array for redundancy.

Note: All of my backups are stored offsite and I use my backup array for quick access - its quicker than restoring from NAS.  So I find backing up to my array and then offloading that offsite works better.

The most popular raid level is raid one, which is mirroring hard drives for additional redundancy.

Here we will guide you through the standard process for creating a RAID 1 array, and then formatting and mounting the array so it can be accessed by the operating system. In this example we create an array as a backup drive, but you can use this for any purpose - just adjust the naming to suit.

This is completed on an Alma Linux box, which was converted to CloudLinux

Background

  • Issue the command lsblk to see your initial configuration. You Can Note down the names of the 2 (min) drives you want to use in the array.

The basic steps are:

  1. Create a partition on sda with 100 % full volume
  2. Create a partition on sdb with 100 % full volume
  3. Create a Raid1 array with the partitions from sda & sdb
  4. Set the file system (ext4) for the newly created array
  5. Mount the newly created raid array - so it can be used on the server.

NOTE: fdisk can create partitions with a maximum size of 2TB. As an alternative use parted to create your partitions

Our guide will assume your drives are /dev/sda and /dev/sdb

  1. Create a partition on sda with 100 % full volume:
    1. Issue the command parted /dev/sda
    2. Issue the command mklabel gpt
    3. Issue the command unit TB
    4. Issue the command mkpart primary 0 100%
    5. Issue the command print  - to see the result
    6. Issue the command mkfs.ext4 /dev/sda1
  2. Create a partition on sdb with 100 % full volume:
    1. Issue the command parted /dev/sdb
    2. Issue the command mklabel gpt
    3. Issue the command unit TB
    4. Issue the command mkpart primary 0 100%
    5. Issue the command print  - to see the result
    6. Issue the command mkfs.ext4 /dev/sdb1
    7.  Check the partitions of the drives by issuing the command fdisk -l
  3. Create a Raid1 array with the partitions from sda & sdb - The name of the new Raid1 array is “md3”.
    1. Issue the command mdadm --create /dev/md3 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
    2. Issue the command lsblk to see the status
    3. Issue the command cat /proc/mdstat  to see the raid sync status (it will take a number of hours to complete)
  4. Issue the command mkfs.ext4 /dev/md3 to set the file system on the raid array
  5. Mount the newly created raid array (as backup)
    1. mkdir /backup
    2. mount /dev/md3 /backup
    3. nano /etc/fstab
    4. add dev/md3 /backup ext4 defaults 0 0

Once you step through these steps you should have an array mounted and be good to go.

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *