How to Setup a Raid1/Mirror using mdadm on Linux System
This guide describes how to set up mdadm with a raid1 or also known as mirror. Then the filesystem is added and monitored.
This guide describes how to set up mdadm with a raid1 or also known as mirror. Then the filesystem is added and monitored.
Make sure you have mdadm installed on your system. You can do this by running the following command:
sudo apt-get install mdadm
Use the lsblk
command to identify the disks you want to include in the Mirror array. Make a note of their device names (e.g., /dev/sda, /dev/sdb, etc.).
Run the following command to create the RAID 1 array:
sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda /dev/sdb
Replace /dev/sda
and /dev/sdb
with the actual device names of your disks. You can also adjust the RAID device name (/dev/md0
) if desired.
You can monitor the progress of the RAID array creation by running the following command:
watch cat /proc/mdstat
This will display the current status of the array creation process. Once it shows that the array is "active" and in a "clean" state, you can proceed to the next step.
Now, you need to create a file system on the RAID array. For example, to create an ext4 file system, run the following command:
sudo mkfs.ext4 /dev/md0
Replace /dev/md0
with the device name of your RAID array.
Create a directory where you want to mount the RAID array and then mount it using the following command:
sudo mkdir /mnt/raid
sudo mount /dev/md0 /mnt/raid
Adjust the mount point (/mnt/raid
) as per your preference.
You can optionally update the mdadm configuration file to ensure the RAID array is automatically assembled during system boot. Run the following command to update the file:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
That's it! You have successfully set up a RAID 1 array using mdadm. The array will now provide data redundancy by mirroring the contents of the two disks. Remember to update the device names and mount points according to your specific configuration.
The DynDNS service of IPv64.net is free of charge and usable in all common routers and systems.
You have the choice between many different domain names.
The IPv64.net Healthchecks monitor your services, servers and endpoints. Receive notifications when your services fail.
This monitoring service is free with all features.
Registration with IPv64 is free of charge and immediately available for you.