Linux搭建磁盘阵列详细教程


Linux中搭建磁盘阵列,本次使用2块4T机械硬盘,搭建raid0磁盘阵列
  • 4T * 2
安装mdadm工具
yum install mdadm -y
查看磁盘名称
 fdisk -l
磁盘1分区(/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.

磁盘2分区(/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.

查看分区
parted -l
创建raid0磁盘阵列
mdadm -C /dev/md0 -l 0 -n 2 /dev/sdc1 /dev/sdb1
创建文件系统
mkfs.ext4 -T largefile /dev/md0           

创建挂载目录
mkdir /mnt/md0     
挂载磁盘
mount /dev/md0 /mnt/md0/  
查看是否挂载成功🍺🍺🍺
df -h    
添加开机自动挂载
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.