Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Creating and Managing a RAID Array in SUSE Linux Enterprise

In this hands-on lab, we will create partitions on additional drives so we can build a software RAID. Once we have a mirror configured and operating, we will fail a drive and remove it from the array, add a new drive to the array, and rebuild the mirror. This is a common set of tasks in the enterprise, as RAID mirrors are used for fault tolerance to prevent data loss due to drive failure.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 45m
Published
Clock icon Jan 10, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Provision the Disks with a Primary Partition So They Can Be Added to the RAID rray

    1. Get the names of the drives with no partitions

      lsblk
      
    2. Your output should match the below (the drives you'll be using later are nvme0n1, nvme1n1, and nvme2n1):

      NAME        MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
      nvme0n1     259:0    0   2G  0 disk
      nvme1n1     259:1    0   2G  0 disk
      nvme2n1     259:2    0   2G  0 disk
      nvme3n1     259:3    0  10G  0 disk
      ├─nvme3n1p1 259:4    0   2M  0 part
      ├─nvme3n1p2 259:5    0  20M  0 part /boot/efi
      └─nvme3n1p3 259:6    0  10G  0 part /
      
    3. Create partitions on the drives, performing the following for each drive:

      sudo fdisk /dev/nvme0n1
      Then press n for new
      Then press p for primary
      Then press 1 for the partition number
      Then enter for starting/first sector
      Then enter for ending/last sector
      Then w to write the changes
      
    4. Prompt the kernel to reread the partition table for the drive:

      sudo partprobe /dev/nvme0n1
      
    5. Repeat the steps for all three drives.

  2. Challenge

    Verify mdadm Is Installed and Create a RAID 1 (`/dev/md0`) from Two of the Drives

    1. Verify that mdadm is installed:

      rpm -q mdadm
      
    2. Create the RAID 1 using two of the drives:

      sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/nvme0n1p1 /dev/nvme1n1p1
      
    3. Watch it being created:

      sudo watch cat /proc/mdstat
      
    4. Hit Ctrl+C to quit.

    5. Now the array is complete, check the status:

      sudo mdadm --detail /dev/md0
      
  3. Challenge

    Create an XFS Filesystem on the Array and Mount It to `/mnt/raid1`

    1. Create the filesystem:

      sudo mkfs.xfs /dev/md0
      
    2. Create a directory and then mount the RAID volume into the directory:

      sudo mkdir /mnt/raid1
      sudo mount /dev/md0 /mnt/raid1
      
    3. Verify the RAID size is correct and the mount displays:

      lsblk
      
    4. Note that your array is shown in the output, including the mount point:

      nvme0n1     259:0    0   2G  0 disk
      └─nvme0n1p1 259:9    0   2G  0 part
        └─md0       9:0    0   2G  0 raid1 /mnt/raid1
      nvme1n1     259:1    0   2G  0 disk
      └─nvme1n1p1 259:10   0   2G  0 part
        └─md0       9:0    0   2G  0 raid1 /mnt/raid1
      nvme2n1     259:2    0   2G  0 disk
      └─nvme2n1p1 259:7    0   2G  0 part
      nvme3n1     259:3    0  10G  0 disk
      ├─nvme3n1p1 259:4    0   2M  0 part
      ├─nvme3n1p2 259:5    0  20M  0 part  /boot/efi
      └─nvme3n1p3 259:6    0  10G  0 part  /
      
  4. Challenge

    Compress `/var/log/messages` Using `tar` and Place It in the `/mnt/raid1` Directory

    1. Compress the messages file, and place it in the newly created raid1 directory:

      sudo tar -czvf /mnt/raid1/messages.tar.gz /var/log/messages
      
    2. Verify the data is in place and the file is not empty:

      ls -l /mnt/raid1
      
  5. Challenge

    Simulate a Failure of One of the Drives and Then Remove It from the Array

    1. Set one drive to faulty:

      sudo mdadm --manage --set-faulty /dev/md0 /dev/nvme1n1p1
      
    2. Confirm that the drive is in a faulty state:

      sudo mdadm --detail /dev/md0
      
    3. Remove the faulty drive from the array:

      sudo mdadm --manage --remove /dev/md0 /dev/nvme1n1p1
      
    4. Confirm that the drive has been removed:

      sudo mdadm --detail /dev/md0
      
  6. Challenge

    Add the Third Drive to the Array, Let It Rebuild, and Verify the Data Is in Place

    1. Add the drive to the array:

      sudo mdadm --manage --add /dev/md0 /dev/nvme2n1p1
      
    2. Watch the rebuild:

      sudo watch cat /proc/mdstat
      
    3. Hit Ctrl+C to quit.

    4. Once the rebuild is complete, confirm that the array shows all drives synced:

      sudo mdadm --detail /dev/md0
      
    5. Confirm that the data is still present:

      ls -l /mnt/raid1
      
  7. Challenge

    Add the Unused Disk Back to the Array as a Spare in Case of Another Failure

    1. Re-add the failed drive back to the array as a spare:

      lsblk
      
    2. Note the nvme1n1p1 partition is not currently linked to the array — that's the one to add back in:

      NAME        MAJ:MIN RM SIZE RO TYPE  MOUNTPOINT
      nvme0n1     259:0    0   2G  0 disk
      └─nvme0n1p1 259:9    0   2G  0 part
        └─md0       9:0    0   2G  0 raid1 /mnt/raid1
      nvme1n1     259:1    0   2G  0 disk
      └─nvme1n1p1 259:10   0   2G  0 part
      nvme2n1     259:2    0   2G  0 disk
      └─nvme2n1p1 259:7    0   2G  0 part
        └─md0       9:0    0   2G  0 raid1 /mnt/raid1
      nvme3n1     259:3    0  10G  0 disk
      ├─nvme3n1p1 259:4    0   2M  0 part
      ├─nvme3n1p2 259:5    0  20M  0 part  /boot/efi
      └─nvme3n1p3 259:6    0  10G  0 part  /
      
    3. Add the drive to the array as a spare:

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

      The resulting output should be:

      mdadm: added /dev/nvme1n1p1
      
    4. Verify that the drive is added to the array as a spare:

      sudo mdadm --detail /dev/md0
      

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans