Learn how to mount Centos7 soft raid5

  • 2020-06-23 02:38:50
  • OfStack

Note: raid5 must be at least 3 hard disks with the same capacity. raid5 has a hard disk usage of n-1

Add 3 hard disks to the virtual machine for 0.2G

After adding, open the virtual machine to view the added hard disk


fdisk -l

Each partition is created in raid format


fdisk /dev/sdb
fdisk /dev/sdc 
fdisk /dev/sdd

n // Create partitions  
p // Create primary partition  
1 // Create partitions 1 
 Enter the default  // Initial sector and Last Sector selection default   Just press enter  
t // Convert partition format  
fd // convert raid 
p // View the partition results created  
w // Save the exit 

View the results


fdisk -l | grep fd

Start creating disk arrays


mdadm -C /dev/md0 -a yes -l 5 -n 3 /dev/sd{b,c,d} // parameter l for raid level  n Is number of disks 

Create a file system of type xfs for the new /dev/md0


mkfs.xfs /dev/md0

View the created results


mdadm -D /dev/md0

To create a folder, mount raid5 to this folder


vim /etc/fstab

At the end of the add


/dev/md0        /mnt/raid5       xfs   defaults    0 0

mdadm.conf was created to enable soft raid automatically after a reboot


mdadm -D -s > /etc/mdadm.conf // This is an important step   Failure to do so will cause the mount to fail 

Restart the validation


fdisk /dev/sdb
fdisk /dev/sdc 
fdisk /dev/sdd
0


Related articles: