一, 使用mdadm创建RAID
参考:https://wiki.archlinux.org/index.php/RAID
1. 安装 mdadm
/home/tong [tong@TStation] [17:47]> pacman -Ss mdadm
core/mdadm 4.0-1 (base) [installed]
A toolfor 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 100 MB of unallocated space at the end of the disk.
(parted) print free
Model: ATA WDC WD3000FYYZ-0(scsi)
Disk/dev/sdc: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags17.4kB 1049kB 1031kB Free Space11049kB 3000GB 3000GB xfs
3000GB 3001GB 105MB Free Space
(parted) print
Model: ATA WDC WD3000FYYZ-0(scsi)
Disk/dev/sdd: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags1 1049kB 3000GB 3000GB
3. 使用mdadm制作RAID
/home/tong [tong@TStation] [19:53]> sudo mdadm --create --verbose --level=1 --metadata=1.2 --raid-devices=2 /dev/md0 /dev/sdc1 /dev/sdd1
mdadm: sizesetto 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] [12:26]> sudo parted /dev/sdc print
Model: ATA WDC WD3000FYYZ-0(scsi)
Disk/dev/sdc: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags12097kB 3000GB 3000GB/home/tong [tong@TStation] [12:26]> sudo parted /dev/sdd print
Model: ATA WDC WD3000FYYZ-0(scsi)
Disk/dev/sdd: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags1 2097kB 3000GB 3000GB
1. 创建物理卷
/home/tong [tong@TStation] [12:28]> sudo pvcreate /dev/sdc1 /dev/sdd1
Physical volume"/dev/sdc1"successfully created.
Physical volume"/dev/sdd1" successfully created.
2. 创建卷组
/home/tong [tong@TStation] [12:28]> 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] [12:59]> sudo lvcreate --type raid1 -l 100%FREE -n storage_raid1 VG_storage /dev/sdc1 /dev/sdd1
Logical volume"storage_raid1" created.
/home/tong [tong@TStation] [13:00]> sudo lvs -o name,segtype,size
LV Type LSize
storage_raid1 raid1<2.73t
4. 创建文件系统
/home/tong [tong@TStation] [13:04]> sudo mkfs.xfs /dev/VG_storage/storage_raid1
meta-data=/dev/VG_storage/storage_raid1 isize=512 agcount=4, agsize=183105024blks= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0, reflink=0data= bsize=4096 blocks=732420096, imaxpct=5
= sunit=0 swidth=0blks
naming=version 2 bsize=4096 ascii-ci=0 ftype=1log=internal log bsize=4096 blocks=357627, version=2
= sectsz=512 sunit=0 blks, lazy-count=1realtime=none extsz=4096 blocks=0, rtextents=0
5。 挂载
/home/tong [tong@TStation] [13:10]> tail -n 3 /etc/fstab
#/dev/mapper/VG_storage-storage_raid1
UUID=c5b048a0-b376-4a00-9a6f-9a9e418d982b /home/tong/Storage xfs rw,relatime,attr2,inode64,noquota 0 2