查看已挂载硬盘
lsblk
sda 8:0 0 10.9T 0 disk
sdb 8:16 0 10.9T 0 disk
大于2T硬盘需使用parted分区
硬盘/dev/sda分区
parted /dev/sda
mklabel gpt # 转gpt
unit TB
mkpart primary 0 12
print
quit
硬盘/dev/sdb分区
parted /dev/sdb
mklabel gpt # 转gpt
unit TB
mkpart primary 0 12
print
quit
错误:
Warning: The resulting partition is not properly aligned for best performance: 34s % 2048s != 0s
解决:
mkpart primary 2048s 100%
再次查看分区
sda 8:0 0 10.9T 0 disk
└─sda1 8:1 0 10.9T 0 part
sdb 8:16 0 10.9T 0 disk
└─sdb1 8:17 0 10.9T 0 part
分区格式化(可选,后面组建raid1后再做分区格式化)
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sdb1
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 2929720832 4k blocks and 366215168 inodes
Filesystem UUID: 9ec5acd0-8edc-4e3c-b653-049eb0230a9f
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544, 1934917632,
2560000000
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks):
done
Writing superblocks and filesystem accounting information: done
组建raid1
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: /dev/sda1 appears to contain an ext2fs file system
size=18446744068248565760K mtime=Thu Jan 1 08:00:00 1970
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: /dev/sdb1 appears to contain an ext2fs file system
size=18446744068248565760K mtime=Thu Jan 1 08:00:00 1970
mdadm: size set to 11718751232K
mdadm: automatically enabling write-intent bitmap on large array
Continue creating array? (y/n) y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
查看设备
ls -al /dev/md*
brw-rw---- 1 root disk 9, 0 Dec 5 16:28 /dev/md0
lsblk
sda 8:0 0 10.9T 0 disk
└─sda1 8:1 0 10.9T 0 part
└─md0 9:0 0 10.9T 0 raid1 /data_raid
sdb 8:16 0 10.9T 0 disk
└─sdb1 8:17 0 10.9T 0 part
└─md0 9:0 0 10.9T 0 raid1 /data_raid
分区格式化
mkfs.ext4 -F /dev/md0
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 2929687808 4k blocks and 366211072 inodes
Filesystem UUID: 3359ea23-4d7b-4614-a532-447ecab734a2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544, 1934917632,
2560000000
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
挂载设备
mkdir /data_raid && mount /dev/md0 /data_raid
扫描阵列并保存阵列配置
mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
ARRAY /dev/md0 metadata=1.2 name=localserver:0 UUID=ad259a0a:c36e70d0:2f22873b:288243b6
更新初始RAM文件系统(initramfs)
update-initramfs -u
修改系统挂载配置
vim /etc/fstab
/dev/md0 /data_raid ext4 defaults 0 0
重启
reboot