一, 使用mdadm创建RAID
参考:https://wiki.archlinux.org/index.php/RAID
1. 安装 mdadm
/home/tong [tong@TStation] [:]
> pacman -Ss mdadm
core/mdadm 4.0- (base) [installed]
A tool for managing/monitoring Linux md device arrays, also known as Software RAID
2. 给单盘分区
2.1 GPT分区。
2.2 做好有分区,虽然裸盘也可以。
2.3 分区尾部预留100M的空余,因为:
Even hard drives of the same manufacturer and model can have small size differences. By leaving a little space at the end of the disk unallocated one can
compensate for the size differences between drives, which makes choosing a replacement drive model easier. Therefore, it is good practice to leave
about MB of unallocated space at the end of the disk.
(parted) print free
Model: ATA WDC WD3000FYYZ- (scsi)
Disk /dev/sdc: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags
.4kB 1049kB 1031kB Free Space
1049kB 3000GB 3000GB xfs
3000GB 3001GB 105MB Free Space
(parted) print
Model: ATA WDC WD3000FYYZ- (scsi)
Disk /dev/sdd: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags
1049kB 3000GB 3000GB
3. 使用mdadm制作RAID
/home/tong [tong@TStation] [:]
> sudo mdadm --create --verbose --level= --metadata=1.2 --raid-devices= /dev/md0 /dev/sdc1 /dev/sdd1
mdadm: size set to 2930030976K
mdadm: automatically enabling write-intent bitmap on large array
mdadm: array /dev/md0 started.
4. 后续详细设置参考:
https://wiki.archlinux.org/index.php/RAID#Installation
二, 使用lvm创建RAID
https://wiki.archlinux.org/index.php/LVM#RAID
0. 使用parted分区。
/home/tong [tong@TStation] [:]
> sudo parted /dev/sdc print
Model: ATA WDC WD3000FYYZ- (scsi)
Disk /dev/sdc: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags
2097kB 3000GB 3000GB /home/tong [tong@TStation] [:]
> sudo parted /dev/sdd print
Model: ATA WDC WD3000FYYZ- (scsi)
Disk /dev/sdd: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags
2097kB 3000GB 3000GB
1. 创建物理卷
/home/tong [tong@TStation] [:]
> sudo pvcreate /dev/sdc1 /dev/sdd1
Physical volume "/dev/sdc1" successfully created.
Physical volume "/dev/sdd1" successfully created.
2. 创建卷组
/home/tong [tong@TStation] [:]
> sudo vgcreate VG_storage /dev/sdc1 /dev/sdd1
Volume group "VG_storage" successfully created
3. 创建逻辑卷
more information: https://jlk.fjfi.cvut.cz/arch/manpages/man/lvmraid.7
How LV data blocks are placed onto PVs is determined by the RAID level.
RAID levels are commonly referred to as 'raid' followed by a number, e.g. raid1, raid5 or raid6.
/home/tong [tong@TStation] [:]
> sudo lvcreate --type raid1 -l %FREE -n storage_raid1 VG_storage /dev/sdc1 /dev/sdd1
Logical volume "storage_raid1" created.
/home/tong [tong@TStation] [:]
> sudo lvs -o name,segtype,size
LV Type LSize
storage_raid1 raid1 <.73t
4. 创建文件系统
/home/tong [tong@TStation] [:]
> sudo mkfs.xfs /dev/VG_storage/storage_raid1
meta-data=/dev/VG_storage/storage_raid1 isize= agcount=, agsize= blks
= sectsz= attr=, projid32bit=
= crc= finobt=, sparse=, rmapbt=, reflink=
data = bsize= blocks=, imaxpct=
= sunit= swidth= blks
naming =version bsize= ascii-ci= ftype=
log =internal log bsize= blocks=, version=
= sectsz= sunit= blks, lazy-count=
realtime =none extsz= blocks=, rtextents=
5。 挂载
/home/tong [tong@TStation] [:]
> tail -n /etc/fstab
# /dev/mapper/VG_storage-storage_raid1
UUID=c5b048a0-b376-4a00-9a6f-9a9e418d982b /home/tong/Storage xfs rw,relatime,attr2,inode64,noquota