其中的 vdb 磁盘为没有被使用的,那么我们接下来就里用它来实现我们的目的 接下来划分我们需要的分区: 使用命令 fdisk dev/vdb 然后输入 m 获得帮助 从中选择 n 代表需要划分一个分区
接下来的分区模式选择主分区 p 也就是默认分区 在选择Partition number (1-4, default 1): 这个随意
在接下来确定First sector (2048-20971519, default 2048): 这个最好选择默认,这样可以充分利用空间接下来就是选择分区的大小:然后就可以利用 p 查看分区有没有成功在下面重要的地方都用蓝色标示:[root@localhost ~]# fdisk /dev/vdb Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them. Be careful before using the write command.Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xe42a4683.Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p Partition number (1-4, default 1): 1 First sector (2048-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G Partition 1 of type Linux and of size 2 GiB is setCommand (m for help): pDisk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dosDisk identifier: 0xe42a4683 Device Boot Start End Blocks Id System /dev/vdb1 2048 4196351 2097152 83 LinuxCommand (m for help): 依次类推我们先划分出3个新的分区 Device Boot Start End Blocks Id System /dev/vdb1 2048 4196351 2097152 83 Linux /dev/vdb2 4196352 8390655 2097152 83 Linux /dev/vdb3 8390656 12584959 2097152 83 Linux 接下来我们需要将新建立的分区功能标签修改为 raid 先在 Command (m for help): l 输入 i发现倒数第三行 有 fd Linux raid auto 那么我们就找到了改为 raid 格式 所对应的命令接下来输入 m Command (m for help): mCommand (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition"s system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) 然后发现 t 是我们需要的 以此类推将三个分区格式都修改成 Linux raid autodetect 点击(此处)折叠或打开Command (m for help): t Partition number (1-3, default 3): 1 Hex code (type L to list all codes): fd Changed type of partition "Linux" to "Linux raid autodetect"Command (m for help): pDisk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xe42a4683Device Boot Start End Blocks Id System /dev/vdb1 2048 4196351 2097152 fd Linux raid autodetect /dev/vdb2 4196352 8390655 2097152 83 Linux /dev/vdb3 8390656 12584959 2097152 83 LinuxCommand (m for help): 然后出来 时用 wq退出保存 在用 命令 cat /proc/partitions 产看分区成功没[root@localhost ~]# cat /proc/partitions major minor #blocks name253 0 10485760 vda 253 1 10484142 vda1 253 16 10485760 vdb 253 17 2097152 vdb1 253 18 2097152 vdb2 253 19 2097152 vdb3 7 0 3655680 loop0 那么就该进入主题了 使用命令: mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 /dev/vdb{1..3} -C 建立 -a 文件不存在建立文件 -l raid级别 -n 设备个数 -x 闲置设备个数 这条命令就将/dev/md0设备做成相当于raid那个内接卡的功能 将vdb1 vdb2 设备关联 闲置设备 vdb3 以被后患用 cat/proc/mdstat 查看设备信息[root@localhost ~]# cat /proc/mdstatPersonalities : [raid1] md0 : active raid1 vdb3[2](S) vdb2[1] vdb1[0] 2096064 blocks super 1.2 [2/2] [UU] [===========>.........] resync = 56.3% (1181056/2096064) finish=0.2min speed=56240K/sec