Linux使用RST組RAID 1 with mdadm
8 min readJul 5, 2021
- 進入BIOS找到 Intel的RST(Rapid Storage Technology)設定RAID,每家主機板不太一樣,請參考主板說明書
選擇create RAID Volume
輸入你的RAID的name ,RAID的類型,我這裡是選擇了RAID 1,使用哪些磁碟,最後點create volume
重新回到peripherals的頁面查看是否已經創建好RAID
2. 將磁碟創建分區,因爲我的磁碟是10T,大於2T的磁碟需要使用parted操作,小於2T的可以使用fdisk(fdisk的操作會放在最後簡單介紹)
$ lsblk -f ###查看目前與計算機相連的磁碟狀況NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
loop0 squashfs 0 100% /snap/core18/2074
loop1 squashfs 0 100% /snap/gnome-3-34-1804/66
loop2 squashfs 0 100% /snap/core18/1988
loop3 squashfs 0 100% /snap/gnome-3-34-1804/72
loop4 squashfs 0 100% /snap/gtk-common-themes/1515
loop5 squashfs 0 100% /snap/gtk-common-themes/1514
loop6 squashfs 0 100% /snap/snapd/11036
loop7 squashfs 0 100% /snap/snap-store/547
loop8 squashfs 0 100% /snap/snapd/12398
loop9 squashfs 0 100% /snap/snap-store/518
sda isw_raid_member
\u2514\u2500isw_bebacfhdff_Volume
sdb isw_raid_member
\u2514\u2500isw_bebacfhdff_Volume
nvme0n1
\u251c\u2500nvme0n1p1 vfat 4CF9-E07C 503.1M 2% /boot/efi
\u2514\u2500nvme0n1p2 ext4 220cb558-377c-4785-88c8-e1ebd087cfaf 423.3G 2% /
可以看到 sda與sdb已經透過主板的RAID串接起來,名字是u2500isw_bebacfhdff_Volume
安裝mdadm,確認兩顆磁碟sda與sdb是否已經分區
$ sudo apt install mdadm$ sudo mdadm -E /dev/sd[a-b]mdadm: No md superblock detected on /dev/sda.
mdadm: No md superblock detected on /dev/sdb.
使用parted分別對兩個磁碟操作
$ sudo parted /dev/sdaGNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.(parted) mklabel GPT(parted) mkpart primary ext4 1 -1(parted) printModel: ATA ST10000NE0008-2J (scsi)
Disk /dev/sda: 10.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:Number Start End Size File system Name Flags
1 1049kB 10.0TB 10.0TB ext4 primary(parted) quit
sdb重複上面的操作
重新檢查兩顆磁碟
$ sudo mdadm -E /dev/sd[a-b]/dev/sda:
MBR Magic : aa55
Partition[0] : 4294967295 sectors at 1 (type ee)
/dev/sdb:
MBR Magic : aa55
Partition[0] : 4294967295 sectors at 1 (type ee)
如上顯示確認沒有問題後,使用mdadm組RAID
md0是新的裝置名稱,l是要組RAID幾,n是使用幾顆磁碟,後面跟磁碟的地址(分區後,原本的sda或sdb後面會多出分區號), 如果出現裝置忙碌中,可以先重啓或
sudo mdadm --stop /dev/md*
$ sudo mdadm -C /dev/md0 -l 1 -n 2 /dev/sd[a-b]1 mdadm: /dev/sda1 appears to be part of a raid array:
level=raid1 devices=2 ctime=Mon Jul 5 08:18:18 2021
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 be part of a raid array:
level=raid1 devices=2 ctime=Mon Jul 5 08:18:18 2021
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.$ cat /proc/mdstatPersonalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[1] sda1[0]
9766302720 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.0% (8028288/9766302720) finish=809.7min speed=200852K/sec
bitmap: 73/73 pages [292KB], 65536KB chunkunused devices: <none>
結下來對RAID好的md0格式化並設定開機自動mount
$ sudo mkfs -t ext4 /dev/md0$ lsblk -f ##記下md0裝置的UUID,其中1401c7ba-8e52-4a21-ac89-2b846aae4ca4就是UUID
$ sudo gedit /etc/fstab ###編輯文檔
按最後一行的格式,修改成自己的UUID與要mount的地址
重啓後就可以開機自動mount,大功告成
最後簡單講一下fdisk的分區創建
$ sudo fdisk /dev/sdaCommand (m for help): m
Help:
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
其實也沒什麼好講的,按照上面help的說明操作就好