參考網頁:
Setup RAID Level 6 (Striping with Double Distributed Parity) in Linux – Part 5
OS:Debian Linux 5.8.0
HDD:
10G*1 Debian Linux System
20G *4 (/dev/sdb,sdc,sdd,sde)
1. 安裝 mdadm 套件
# apt-get install mdadm
[@more@]2. 查看目前磁碟狀態
# fdisk -l | grep ‘^Disk /dev’
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdd: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk /dev/sde: 20 GiB, 21474836480 bytes, 41943040 sectors
不一定要更改成 fd
重複上面的動作,完成所有的磁碟
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
4. 建立 /dev/md0 磁碟陣列分割區
# mdadm –create /dev/md0 –level=6 –raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
5. 查看建置結果
# fdisk -l | grep /dev/md0
Disk /dev/md0: 40 GiB, 42914021376 bytes, 83816448 sectors
# mdadm –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Jun 28 10:25:06 2016
Raid Level : raid6
Array Size : 41908224 (39.97 GiB 42.91 GB)
Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Tue Jun 28 10:25:52 2016
State : clean, resyncing
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Resync Status : 32% complete
Name : debian:0 (local to host debian)
UUID : 8f039d29:9179c09a:17a76417:e54c9dfa
Events : 5
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
2 8 49 2 active sync /dev/sdd1
3 8 65 3 active sync /dev/sde1
6. 格式化分割區
# mkfs -t ext4 /dev/md0
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 10477056 4k blocks and 2621440 inodes
Filesystem UUID: 25c4c294-0b13-4e71-928e-47e1b69f1219
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
7. 建立掛載目錄並掛載
# mkdir /mnt/raid6
# mount /dev/md0 /mnt/raid6
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.3G 968M 7.9G 11% /
udev 10M 0 10M 0% /dev
tmpfs 400M 5.7M 394M 2% /run
tmpfs 999M 0 999M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 999M 0 999M 0% /sys/fs/cgroup
/dev/md0 40G 48M 38G 1% /mnt/raid6
8. 查看硬碟的 UUID
# blkid | grep /dev/md0
/dev/md0: UUID=”25c4c294-0b13-4e71-928e-47e1b69f1219″ TYPE=”ext4″
9. 修改 /etc/fstab
# vim /etc/fstab
加入下面一行
UUID=25c4c294-0b13-4e71-928e-47e1b69f1219 /mnt/raid5 ext4 errors=remount-ro 0 0
10. 編輯 /etc/mdadm/mdadm.conf 設定檔
# mdadm –detail –scan –verbose >> /etc/mdadm/mdadm.conf
ARRAY /dev/md0 level=raid6 num-devices=4 metadata=1.2 name=debian:0 UUID=8f039d29:9179c09a:17a76417:e54c9dfa
devices=/dev/sdb1,/dev/sdc1,/dev/sdd1,/dev/sde1
11. 磁碟分割資訊
# fdisk -l | grep /dev/sd
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
/dev/sdb1 2048 41943039 41940992 20G fd Linux raid autodetect
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
/dev/sda1 * 2048 20013055 20011008 9.6G 83 Linux
/dev/sda2 20015102 20969471 954370 466M 5 Extended
/dev/sda5 20015104 20969471 954368 466M 82 Linux swap / Solaris
Disk /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 sectors
/dev/sdc1 2048 41943039 41940992 20G fd Linux raid autodetect
Disk /dev/sdd: 20 GiB, 21474836480 bytes, 41943040 sectors
/dev/sdd1 2048 41943039 41940992 20G fd Linux raid autodetect
Disk /dev/sde: 20 GiB, 21474836480 bytes, 41943040 sectors
/dev/sde1 2048 41943039 41940992 20G fd Linux raid autodetect
12. 檢查是否有正確掛載
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.3G 1.1G 7.8G 12% /
udev 10M 0 10M 0% /dev
tmpfs 400M 5.9M 394M 2% /run
tmpfs 999M 0 999M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 999M 0 999M 0% /sys/fs/cgroup
/dev/md0 40G 48M 38G 1% /mnt/raid6