yum install gdisk # 安装 gdisk [root@i-5C222F91 ~]# parted /dev/vda # 输入 p 查看分区信息,这时会提示错误,输入 Fix 修复分区信息,q 退出。 [root@i-5C222F91 ~]# partprobe /dev/vda # 刷新存储信息 [root@i-5C222F91 ~]# gdisk /dev/vda Command (? forhelp): p Number Start (sector) End (sector) Size Code Name 1 2048 1026047 500.0 MiB EF00 EFI System Partition 2 1026048 1640447 300.0 MiB 0700 3 1640448 41936895 19.2 GiB 0700 #删除原分区 Command (? forhelp): d Partition number (1-3): 3 #新建分区,序号使用原分区序号,一路回车 Command (? forhelp): n Partition number (3-128, default 3): 3 #查看分区情况 Command (? forhelp): p Number Start (sector) End (sector) Size Code Name 1 2048 1026047 500.0 MiB EF00 EFI System Partition 2 1026048 1640447 300.0 MiB 0700 3 1640448 104857566 49.2 GiB 8300 Linux filesystem #修改分区类型 Command (? forhelp): t Partition number (1-3): 3 Hex code or GUID (L to show codes, Enter = 8300): 0700 #检查分区情况 Command (? forhelp): v #保存分区 Command (? forhelp): w
Do you want to proceed? (Y/N): y #写入分区信息 [root@i-5C222F91 ~]# partprobe /dev/vda [root@i-5C222F91 ~]# partprobe /dev/vda3 #刷新存储信息,查看分区情况 [root@i-5C222F91 ~]# lsblk #更新扩容信息 [root@i-5C222F91 ~]# xfs_growfs /dev/vda3
0x07 扩容mbr分区(fdisk工具)
直接使用命令扩容系统分区会提示错误,这时我们可以使用 fdisk 扩容分区
## 刷新硬件信息 [root@i-351D0B02 ~]# partprobe /dev/vda ## 查看磁盘情况 [root@i-351D0B02 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom sr1 11:1 1 1024M 0 rom vda 253:0 0 100G 0 disk ├─vda1 253:1 0 8G 0 part [SWAP] └─vda2 253:2 0 22G 0 part /
[root@i-351D0B02 ~]# fdisk /dev/vda Welcome to fdisk (util-linux 2.23.2). Command (m forhelp): p ##查看原分区情况 Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x000504a5
Device Boot Start End Blocks Id System /dev/vda1 2048 16779263 8388608 82 Linux swap / Solaris /dev/vda2 * 16779264 62914559 23067648 83 Linux ##删除分区,删除分区后不可以保存 Command (m forhelp): d Partition number (1,2, default 2): 2 Partition 2 is deleted ##重新创建分区 Command (m forhelp): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): 2 First sector (16779264-209715199, default 16779264): Using default value 16779264 Last sector, +sectors or +size{K,M,G} (16779264-209715199, default 209715199): Using default value 209715199 Partition 2 of type Linux and of size 92 GiB is set ## 再次查看分区 Command (m forhelp): p
Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x000504a5
Device Boot Start End Blocks Id System /dev/vda1 2048 16779263 8388608 82 Linux swap / Solaris /dev/vda2 16779264 209715199 96467968 83 Linux ## 检查分区是不否有错误 Command (m forhelp): v Remaining 2047 unallocated 512-byte sectors ## 保存分区信息 Command (m forhelp): w The partition table has been altered!