[root@yjgltpc-cgzs-2 ~]# fdisk /dev/vda 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 # 键入“n”创建新的分区 Command action e extended p primary partition (1-4) e # 键入“e”创建扩展分区 Partition number (1-4): 3 First cylinder (1-416101, default 1): 208051 # 键入起始柱面从“208051”开始 Last cylinder, +cylinders or +size{K,M,G} (208051-416101, default 416101): # 直接回车 Using default value 416101 Command (m for help): p # 键入“p”查看分区创建情况 Disk /dev/vda: 214.7 GB, 214748364800 bytes 16 heads, 63 sectors/track, 416101 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00091944 Device Boot Start End Blocks Id System /dev/vda1 * 3 1018 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/vda2 1018 208051 104344576 8e Linux LVM Partition 2 does not end on cylinder boundary. /dev/vda3 208051 416101 104857304 5 Extended Command (m for help): n # 键入“n”创建逻辑分区 Command action l logical (5 or over) p primary partition (1-4) l # 键入“l”选择逻辑分区 First cylinder (208051-416101, default 208051): # 直接回车 Using default value 208051 Last cylinder, +cylinders or +size{K,M,G} (208051-416101, default 416101): Using default value 416101 Command (m for help): p # 键入“p”显示所有分区情况 Disk /dev/vda: 214.7 GB, 214748364800 bytes 16 heads, 63 sectors/track, 416101 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00091944 Device Boot Start End Blocks Id System /dev/vda1 * 3 1018 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/vda2 1018 208051 104344576 8e Linux LVM Partition 2 does not end on cylinder boundary. /dev/vda3 208051 416101 104857304 5 Extended /dev/vda5 208051 416101 104857272+ 83 Linux Command (m for help): w # 键入“w”保存分区 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 at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@yjgltpc-cgzs-2 ~]#
[root@yjgltpc-cgzs-2 ~]# mkfs.ext4 /dev/vda5 # 格式化为ext4文件系统 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 6553600 inodes, 26214318 blocks 1310715 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 800 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 27 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@yjgltpc-cgzs-2 ~]#
[root@yjgltpc-cgzs-2 ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 99.51 GiB PE Size 4.00 MiB Total PE 25474 Alloc PE / Size 25474 / 99.51 GiB Free PE / Size 0 / 0 # 表示没有可用的扩展空间 VG UUID YYbZEp-ddOk-gdIC-h0dU-seBF-Enlx-SeYIpP [root@yjgltpc-cgzs-2 ~]#
## 再次查看卷组,发现可扩展空间为100GB。 [root@yjgltpc-cgzs-2 ~]# vgextend /dev/centos /dev/vda5 Volume group "VolGroup" successfully extended [root@localhost ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 2 Act PV 2 VG Size 199.50 GiB PE Size 4.00 MiB Total PE 51073 Alloc PE / Size 25474 / 99.51 GiB Free PE / Size 25599 / 100.00 GiB VG UUID YYbZEp-ddOk-gdIC-h0dU-seBF-Enlx-SeYIpP [root@yjgltpc-cgzs-2 ~]#