linux centos8硬盘组合为raid0挂载教程

查看硬盘信息

# fdisk -l

Disk /dev/nvme1n1: 7.28 TiB, 8001563222016 bytes, 15628053168 sectors
Disk model: INTEL SSDPE2KX080T8                     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/nvme2n1: 7.28 TiB, 8001563222016 bytes, 15628053168 sectors
Disk model: INTEL SSDPE2KX080T8                     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/nvme3n1: 7.28 TiB, 8001563222016 bytes, 15628053168 sectors
Disk model: INTEL SSDPE2KX080T8                     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

组raido

mdadm -Cv /dev/md0 -a yes -n {num} -l 0 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1

//{num}是磁盘数量,所以这里是
mdadm -Cv /dev/md0 -a yes -n 3 -l 0 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1

写入配置

mdadm -Ds >> /etc/mdadm/mdadm.conf

查看组合后的磁盘信息

# fdisk -l

Disk /dev/md0: 21.85 TiB, 24004282810368 bytes, 46883364864 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1572864 bytes

直接格式化分区

mkfs.xfs -f /dev/md0

查看分区ID

# blkid /dev/md0

/dev/md0: UUID="0251496e-8af2-405d-af03-fe72a1891d32" TYPE="xfs"

修改/etc/fstab文件

vim /etc/fstab

在文件最后用过uuid加上下面这一行


UUID="0251496e-8af2-405d-af03-fe72a1891d32" /ssd xfs defaults 0 0

创建挂载文件夹,mount -a是挂载/etc/fstab下未挂载的分区,查看磁盘情况

mkdir /ssd
mount -a
df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            504G     0  504G   0% /dev
tmpfs           101G   31M  101G   1% /run
/dev/nvme0n1p2  468G   13G  432G   3% /
tmpfs           504G     0  504G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           504G     0  504G   0% /sys/fs/cgroup
/dev/loop0       56M   56M     0 100% /snap/core18/2128
/dev/loop1       71M   71M     0 100% /snap/lxd/21029
/dev/loop2       33M   33M     0 100% /snap/snapd/12704
/dev/nvme0n1p1  511M  5.3M  506M   2% /boot/efi
tmpfs           101G     0  101G   0% /run/user/0
/dev/md0p1       22T   24K   21T   1% /ssd

可以看到三块ssd已经融合挂载成功,由于写入了/etc/fstab,重启依然生效

By 行政