how to add a disk array raid 0 in linux


Build a disk array in Linux, this time use 2 4T mechanical hard disks to build a raid0 disk array
  • 4T * 2
Install mdadm tool
yum install mdadm -y
View the disk name
 fdisk -l
Disk 1 partition(/dev/sdb)
parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) mkpart
Partition name?  []? sdb1
File system type?  [ext2]? ext4
Start? 0GB
End? 4000GB
(parted) p
Model: ATA WDC WD40EJRX-89T (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number  Start   End     Size    File system  Name  Flags
 1      1049kB  4000GB  4000GB  ext4         sdb1
(parted) q
Information: You may need to update /etc/fstab.

Disk 2 partition(/dev/sdc)
parted /dev/sdc
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) mkpart
Partition name?  []? sdc1
File system type?  [ext2]? ext4
Start? 0GB
End? 4000GB
(parted) p
Model: ATA WDC WD40EJRX-89T (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:


Number  Start   End     Size    File system  Name  Flags
 1      1049kB  4000GB  4000GB  ext4         sdc1


(parted) q
Information: You may need to update /etc/fstab.

View partition
parted -l
Create raid0 disk array
mdadm -C /dev/md0 -l 0 -n 2 /dev/sdc1 /dev/sdb1
Create a file system
mkfs.ext4 -T largefile /dev/md0           
Create mount directory
mkdir /mnt/md0     
Mount the disk
mount /dev/md0 /mnt/md0/  
Check if the mount is successful🍺🍺🍺
df -h    
Add automatic mount at boot
echo '/dev/md0 /mnt/md0 ext4 defaults 0 0' | sudo tee -a /etc/fstab


Was this helpful?

I hope to help every developer quickly find the commands they need. Of course, you can also add your own commonly used commands for easy searching.