RAID 5 is an excellent choice for those looking to strike a balance between data redundancy and performance. In this tutorial, we’ll show you how to create RAID 5 array in Ubuntu 20.04. Before we dive in, make sure you’re familiar with the Ubuntu command line interface and how to manage software packages in Ubuntu.
Prerequisites
- At least three hard drives or SSDs.
- Ubuntu 20.04 is installed on your system.
Step 1: Install the Required Packages
First, we need to install the mdadm package, which provides the necessary tools for creating and managing RAID arrays:
sudo apt update
sudo apt install mdadm
Step 2: Create the RAID 5 Array
To create the RAID 5 array, run the following command, replacing /dev/sdX
, /dev/sdY
, and /dev/sdZ
with the device names of your hard drives:
sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdX /dev/sdY /dev/sdZ
You will be prompted to confirm the creation of the RAID array. Type ‘yes’ and press enter to proceed.
Step 3: Verify the RAID 5 Array Creation
In order to verify that the RAID 5 array has been created successfully, run the following command:
cat /proc/mdstat
You should see output similar to the following, indicating that your RAID 5 array is active and running:
Personalities : [raid6] [raid5] [raid10]
md0 : active raid5 sdZ[2] sdY[1] sdX[0]
2096128 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
Step 4: Create a Filesystem on the RAID Array
Now that the RAID 5 array has been created, we need to create a filesystem on it. We’ll use the ext4 filesystem in this example:
sudo mkfs.ext4 /dev/md0
Step 5: Mount the RAID Array
First, create a mount point for the RAID array:
sudo mkdir /mnt/raid5
Next, mount the RAID array to the newly created mount point:
sudo mount /dev/md0 /mnt/raid5
To make sure the RAID array is mounted automatically at boot, add an entry to the /etc/fstab
file. Open the file using a text editor like nano:
sudo nano /etc/fstab
Add the following line at the end of the file:
/dev/md0 /mnt/raid5 ext4 defaults 0 0
Save and exit the text editor.
Step 6: Test the RAID Array
To test the RAID array, create a test file in the /mnt/raid5
directory:
echo "Hello, RAID 5!" | sudo tee /mnt/raid5/test.txt
Now, unmount and remount the RAID array to ensure that the data persists:
sudo umount /mnt/raid5
sudo mount /mnt/raid5
Verify that the test file is still present and contains the correct data:
cat /mnt/raid5/test.txt
If everything is working correctly, you should see the text “Hello, RAID 5!” printed to the terminal.
Conclusion
Congratulations! You have successfully created a RAID 5 array in Ubuntu 20.04. If you want to learn more about managing your Ubuntu system, consider reading about how to set up a file server on Ubuntu using Samba or NFS or how to automate system administration tasks in Ubuntu with Ansible
Remember that RAID 5 is not a substitute for a proper backup strategy. To further protect your data, consider learning about how to create and manage backups and snapshots in Debian, as many of the concepts can be applied to Ubuntu as well.
For more advanced users, you can also explore setting up a web server on Ubuntu using Nginx or Apache. Additionally, you can learn about how to secure your Ubuntu system with firewall and AppArmor policies to further enhance the security of your system.