[root@localhost ~]# fdisk /dev/sdb //进入要分配的磁盘
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n //创建分区
Command action
e extended
p primary partition (1-4)
e //创建扩展分区
Partition number (1-4): 4 //分区号
First cylinder (5121-10240, default 5121): //分区开始柱面,enter默认
Using default value 5121
Last cylinder, +cylinders or +size{K,M,G} (5121-10240, default 10240): //分区结束柱面
Using default value 10240
Command (m for help): p //打印分区情况
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb92c060c
Device Boot Start End Blocks Id System
/dev/sdb1 1 5120 5242864 83 Linux
/dev/sdb4 5121 10240 5242880 5 Extended
Command (m for help): n //创建分区
Command action
l logical (5 or over)
p primary partition (1-4)
l //创建逻辑分区
First cylinder (5121-10240, default 5121): //分区开始柱面,enter默认
Using default value 5121
Last cylinder, +cylinders or +size{K,M,G} (5121-10240, default 10240): 8192
Command (m for help): n //再创建一个分区
Command action
l logical (5 or over)
p primary partition (1-4)
l //再创建一个逻辑分区
First cylinder (8193-10240, default 8193): //分区开始柱面,enter默认
Using default value 8193
Last cylinder, +cylinders or +size{K,M,G} (8193-10240, default 10240): //分区结束柱面
Using default value 10240Command (m for help): p //打印分区表进行查看Disk /dev/sdb: 10.7 GB, 10737418240 bytes64 heads, 32 sectors/track, 10240 cylindersUnits = cylinders of 2048 * 512 = 1048576 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xb92c060c Device Boot Start End Blocks Id System/dev/sdb1 1 5120 5242864 83 Linux/dev/sdb4 5121 10240 5242880 5 Extended/dev/sdb5 5121 8192 3145712 83 Linux/dev/sdb6 8193 10240 2097136 83 LinuxCommand (m for help): w //w保存上面设置,q退出而不报错The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.[root@localhost ~]# mkfs.ext4 /dev/sdb5 //格式化mke2fs 1.41.12 (17-May-2010)Could not stat /dev/sdb5 --- No such file or directory //这里注意一下,先执行partprobe命令让系统内核重读分区表,如果报错要reboot一下[root@localhost ~]# mkfs.ext4 /dev/sdb5 //格式化/dev/sdb5mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks196608 inodes, 786428 blocks39321 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=80530636824 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Writing inode tables: done Creating journal (16384 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 28 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@localhost ~]# mkfs.ext4 /dev/sdb6 //格式化/dev/sdb6mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks131072 inodes, 524284 blocks26214 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=53687091216 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Writing inode tables: done Creating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 33 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@localhost var]# mkdir /disk01[root@localhost var]# mkdir /disk02[root@localhost var]# mount /dev/sdb5 /disk01 //挂载分区[root@localhost var]# mount /dev/sdb6 /disk02[root@localhost var]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 50G 3.9G 43G 9% /tmpfs 940M 72K 940M 1% /dev/shm/dev/sda1 485M 38M 423M 9% /boot/dev/mapper/VolGroup-lv_home 45G 532M 43G 2% /home/dev/sdb5 3.0G 69M 2.8G 3% /disk01/dev/sdb6 2.0G 35M 1.9G 2% /disk02[root@localhost var]# vi /etc/fstab //添加到配置文件,这里略