*--scan或-s:扫描配置文件或/proc/mdstat文件来搜索软RAID的配置信息,该参数不能单独使用,只能配置其它参数才能使用。
下面将通过一个实例来讲述通过mdadm如何实现软RAID的功能。
4.1.1 创建分区;
【实例1】
某台机器上有4块空闲的硬盘,分别是/dev/sdb、/dev/sdc、/dev/sdd和/dev/sde,并用这四块硬盘来创建来创建一个RAID 5,具体操作步骤如下:
首先使用“fdisk”命令在每块硬盘上创建一个分区,操作如下:
root@xiaop-laptop:/# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n #按n创建新分区
Command action
e extended
p primary partition (1-4) #输入p 选择创建主分区
p
Partition number (1-4): 1 #输入 1 创建第一个主分区
First cylinder (1-102, default 1): #直接回车,选择分区开始柱面这里就从 1 开始
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-102, default 102):
Using default value 102
Command (m for help): w #然后输入w写盘
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
针对其余几块硬盘也做相同操作,按照此步骤在另外的两块磁盘上做同样的操作;
全部做完后,运行 fdisk -l 应该可以看到如下信息:
Disk /dev/sdb: 214 MB, 214748160 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 204 208880 fd Linux raid autodetect
Disk /dev/sdc: 214 MB, 214748160 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 204 208880 fd Linux raid autodetect
Disk /dev/sdd: 214 MB, 214748160 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 204 208880 fd Linux raid autodetect
看到上面三个磁盘上分别建了一个分区,分区大小都一样;
4.1.2 创建RAID 5;
创建完/dev/sdb1、/dev/sdc1、/dev/sdd1、/dev/sde1四个分区后,下面就可以来创建RAID 5了,其中设定/dev/sde1作为备用设备,其余为活动设备,备用设备的作用是一旦某一设备损坏可以立即使用备用设备替换。操作命令如下:










