參考文章:
FreeBSD 9.1 Программный RAID5 | Seclab
OS:FreeBSD 10.3
HDD:
20G*1:FreeBSDSystem(/dev/da0)
20G *3 :RAID (/dev/da1,da2,da3)
1. 磁碟機代號
# sysctl kern.disks
kern.disks: da3 da2 da1 da0 cd0
2. 取得磁碟機相關資訊
# fdisk da1
******* Working on device /dev/da1 *******
parameters extracted from in-core disklabel are:
cylinders=2610 heads=255 sectors/track=63 (16065 blks/cyl)
Figures below won’t work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=2610 heads=255 sectors/track=63 (16065 blks/cyl)
fdisk: invalid fdisk partition table found
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 63, size 41929587 (20473 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 561/ head 254/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>[@more@]3. 建立掛載目錄
# mkdir /storage
4. 建立 /etc/gvinum.conf 設定檔
# vim /etc/gvinum.conf
drive raid51 device /dev/da1
drive raid52 device /dev/da2
drive raid53 device /dev/da3
volume raid5
plex org raid5 256k
sd len 20473m drive raid51
sd len 20473m drive raid52
sd len 20473m drive raid53
5. 建立 RAID5
# gvinum create /etc/gvinum.conf
6. 格式化
# newfs -U /dev/gvinum/raid5
/dev/gvinum/raid5: 40946.0MB (83857408 sectors) block size 32768, fragment size 4096
using 66 cylinder groups of 626.09MB, 20035 blks, 80256 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 1282432, 2564672, 3846912, 5129152, 6411392, 7693632, 8975872, 10258112, 11540352,
12822592, 14104832, 15387072, 16669312, 17951552, 19233792, 20516032, 21798272, 23080512,
24362752, 25644992, 26927232, 28209472, 29491712, 30773952, 32056192, 33338432, 34620672,
35902912, 37185152, 38467392, 39749632, 41031872, 42314112, 43596352, 44878592, 46160832,
47443072, 48725312, 50007552, 51289792, 52572032, 53854272, 55136512, 56418752, 57700992,
58983232, 60265472, 61547712, 62829952, 64112192, 65394432, 66676672, 67958912, 69241152,
70523392, 71805632, 73087872, 74370112, 75652352, 76934592, 78216832, 79499072, 80781312,
82063552, 83345792
7. 掛載
# mount /dev/gvinum/raid5 /storage
# df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/da0p2 18G 2.8G 14G 17% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/gvinum/raid5 39G 8.0K 36G 0% /storage
8. 修改 /etc/fstab
# echo /dev/gvinum/raid5 /storage ufs rw 2 2 >> /etc/fstab
9. 開機便啟動 GVinum 服務
修改 /boot/loader.conf 設定檔
# vim /boot/loader.conf
加入下面一行
geom_vinum_load=”YES”
或
# echo geom_vinum_load=”YES” >> /boot/loader.conf
10. 重新啟動電腦
# reboot
11. RAID5 系統狀態
# gvinum l
3 drives:
D raid51 State: up /dev/da1 A: 6/20479 MB (0%)
D raid52 State: up /dev/da2 A: 6/20479 MB (0%)
D raid53 State: up /dev/da3 A: 6/20479 MB (0%)
1 volume:
V raid5 State: up Plexes: 1 Size: 39 GB
1 plex:
P raid5.p0 R5 State: up Subdisks: 3 Size: 39 GB
3 subdisks:
S raid5.p0.s0 State: up D: raid51 Size: 19 GB
S raid5.p0.s1 State: up D: raid52 Size: 19 GB
S raid5.p0.s2 State: up D: raid53 Size: 19 GB