1.查看新挂载磁盘是否以被设备识别出来(如下)
[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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        2610    20860402+  8e  Linux LVM
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1        2000    16064968+  83  Linux
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/dev/sdc1              1        2610    20964793+  83  Linux
Disk /dev/sdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/
dev/sdd1              1        2610    20964793+  83  Linux
Disk /dev/sde: 21.4 GB, 21474836480 bytes              新加磁盘未分区
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
2.将新挂载的磁盘分区(分区如下)
[root@localhost ~]# fdisk /dev/sdd
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 2610.
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): n
Command action
e  extended
p  primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): 2610
Command (m for help): p
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/dev/sdc1              1        2610    20964793+  83  Linux
Command (m for help): t             
更改分区类型
Selected partition 1
Hex code (type L to list codes): df
Changed system type of partition 1 to df (BootIt)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3.查看新加入磁盘是否分区完成(如下)
[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
invalid system diskUnits = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1        2000    16064968+  83  Linux      新分区
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/dev/sdc1              1        2610    20964793+  83  Linux      新分区
Disk /dev/sdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start        End      Blocks  Id  System
/
dev/sdd1              1        2610    20964793+  83  Linux      新分区
4.创建raid设备(如下)
系统默认有个md0可以给我们用,如果我要多个raid的话,就需要自己创建设备了,所以在这里我教大家怎么创建raid设备
[root@localhost ~]#mknod /dev/md1 b 9 1
创建md1这个raid设备
mknod是命令
/dev/md1 是设备名字,设备必须是/dev/md开始的
后面的b代表创建的是块设备
9是主设备号,1代表从设备号
主设备好不能改,从设备号在系统内唯一
5.创建raid阵列(如下)
[root@localhost ~]# mdadm -C /dev/md1 -l 5 -n 3 /dev/sdb1 /dev/sdc1 /dev/sdd1
-C 代表创建
-l 代表创建的级别 
-n 代表活动的分区,也就是你要给这个级别多少个分区
-x 就是热备份的分区
OK以后,可以使用命令
#mdadm  --detail /dev/md1 
查看RAID状态
6.格式化 raid阵列 (如下)
# 3 /dev/md0
7.查看raid阵列
# mdadm -D /dev/md0
8.挂载raid阵列。(如下)
# mount -t ext3 /dev/md0 /mnt/
raid5  在线扩容
1.先将新加入的硬盘进行分区备用(此处省略,如不会请参考上面命令)
2.添加新设备到原有的raid5阵列中(命令如下)
[root@localhost ~]# mdadm /dev/md0 --add /dev/sde1
3.将raid5中原有的3块盘增加到4
块盘组成(命令如下)
[root@localhost ~]# mdadm --grow /dev/md0 --raid-devices=4
4.查看raid5是否完成后阵列的容量已扩充(命令如下)
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sde1[4] sdd1[3] sdc1[1] sdb1[0]
31443456 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]  (扩容以完成)
unused devices: <none>
5.调整raid5文件系统的大小了(命令如下)
[root@localhost ~]# resize2fs /dev/md0     
6.查看挂载的/mnt 目录是否扩容完成,以及内部数据是否丢失 (命令如下)
[root@localhost ~]# df -lH
Filesystem            Size  Used  Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
19G  6.2G    12G  35% /
tmpfs                  528M  103k  528M  1% /dev/shm
/dev/sda1              508M    32M  451M  7% /boot
/dev/md0                32G  181M    30G  1% /mnt
[root@localhost ~]# ll /mnt/
total 20
drwx------. 2 root root 16384 Jul  2 10:04 lost+found
-rw-r--r--. 1 root root  487 Jul  2 10:08 majianjun

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。