AS5.4上做软RAID
[root@16nn.com ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 83 Linux
/dev/sda3 275 405 1052257+ 83 Linux
/dev/sda4 406 1044 5132767+ 5 Extended
/dev/sda5 406 536 1052226 83 Linux
/dev/sda6 537 667 1052226 83 Linux
/dev/sda7 668 798 1052226 82 Linux swap / Solaris
/dev/sda8 799 1044 1975963+ 83 Linux
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
创建分区并改变分区类型为Linux raid autodetect
[root@16nn.com ~]# 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.
The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): +100M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-1044, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-1044, default 1044): +200M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 3
First cylinder (39-1044, default 39):
Using default value 39
Last cylinder or +size or +sizeM or +sizeK (39-1044, default 1044):
Using default value 1044
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 13 104391 83 Linux
/dev/sdb2 14 38 200812+ 83 Linux
/dev/sdb3 39 1044 8080695 5 Extended
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (39-1044, default 39):
Using default value 39
Last cylinder or +size or +sizeM or +sizeK (39-1044, default 1044): +500M
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (101-1044, default 101):
Using default value 101
Last cylinder or +size or +sizeM or +sizeK (101-1044, default 1044): +600M
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 13 104391 83 Linux
/dev/sdb2 14 38 200812+ 83 Linux
/dev/sdb3 39 1044 8080695 5 Extended
/dev/sdb5 39 100 497983+ 83 Linux
/dev/sdb6 101 174 594373+ 83 Linux
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (175-1044, default 175):
Using default value 175
Last cylinder or +size or +sizeM or +sizeK (175-1044, default 1044): +700M
Command (m for help):
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 13 104391 83 Linux
/dev/sdb2 14 38 200812+ 83 Linux
/dev/sdb3 39 1044 8080695 5 Extended
/dev/sdb5 39 100 497983+ 83 Linux
/dev/sdb6 101 174 594373+ 83 Linux
/dev/sdb7 175 260 690763+ 83 Linux
Command (m for help): t
Partition number (1-7): 5
Hex code (type L to list codes): fd
Changed system type of partition 5 to fd (Linux raid autodetect)
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 13 104391 83 Linux
/dev/sdb2 14 38 200812+ 83 Linux
/dev/sdb3 39 1044 8080695 5 Extended
/dev/sdb5 39 100 497983+ fd Linux raid autodetect
/dev/sdb6 101 174 594373+ 83 Linux
/dev/sdb7 175 260 690763+ 83 Linux
Command (m for help): t
Partition number (1-7): 6
Hex code (type L to list codes): fd
Changed system type of partition 6 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): fd
Changed system type of partition 7 to fd (Linux raid autodetect)
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 13 104391 83 Linux
/dev/sdb2 14 38 200812+ 83 Linux
/dev/sdb3 39 1044 8080695 5 Extended
/dev/sdb5 39 100 497983+ fd Linux raid autodetect
/dev/sdb6 101 174 594373+ fd Linux raid autodetect
/dev/sdb7 175 260 690763+ fd Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
输入下面的命令不重启直接使用分区后的硬盘
[root@16nn.com ~]# partprobe
Warning: Unable to open /dev/hdc read-write (Read-only file system). /dev/hdc has been opened read-only.
创建RAID
[root@16nn.com ~]# mdadm -C /dev/md11 -l1 -n2 /dev/sdb{5,6}
mdadm: largest drive (/dev/sdb6) exceed size (497856K) by more than 1%
Continue creating array? y
mdadm: array /dev/md11 started.
后面的-l是说明RAID的类型,这里是RAID1,如果你要做RAID5就把后面的1改为5
-n是分区的数量,这里是两块,注意做RAID5至少需要3个分区
如果系统是RHEL5.1之前的版本需要先输入下面的命令创建对应的md设备
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2
mknod /dev/md3 b 9 3
查看RAID情况
[root@16nn.com ~]# cat /proc/mdstat
Personalities : [raid1]
md11 : active raid1 sdb6[1] sdb5[0]
497856 blocks [2/2] [UU]
unused devices: <none>
如果其中一块硬盘块掉的话,先标记再删除
[root@16nn.com ~]# mdadm /dev/md11 -f /dev/sdb5 标记坏的硬盘
[root@16nn.com ~]# mdadm /dev/md11 -r /dev/sdb5 删除坏的硬盘
[root@16nn.com ~]# mdadm /dev/md11 -a /dev/sdb5 添加新的硬盘
[root@16nn.com ~]# mdadm /dev/md11 -A /dev//dev/sdb{5,6} 启动被停止的阵列