Welcome to fdisk (util-linux 2.34). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
GPT PMBR size mismatch (209715199 != 251658239) will be corrected by write. The backup GPT table is not on the end of the device. This problem will be corrected by write.
Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 209715166 209711071 100G Linux filesystem
删除/dev/sda上的2号分区, 即/dev/sda2
1 2 3 4
Command (m for help): d Partition number (1,2, default 2): 2
Partition 2 has been deleted.
新建2号分区, First sector和Last sector保持默认即可, 提示已存在ext4文件系统时注意不要删除.
1 2 3 4 5 6 7 8 9
Command (m for help): n Partition number (2-128, default 2): 2 First sector (4096-251658206, default 4096): Last sector, +/-sectors or +/-size{K,M,G,T,P} (4096-251658206, default 251658206):
Created a new partition 2 of type 'Linux filesystem' and of size 120 GiB. Partition #2 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
最后使用w命令保存.
1 2 3 4
Command (m for help): w
The partition table has been altered. Syncing disks.
Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 251658206 251654111 120G Linux filesystem
此时会发现磁盘分区已经扩大了, 但是文件系统还没有. 使用resize2fs命令完成这个扩展
1 2 3 4 5
root@lsp-sg-game-1:~# resize2fs /dev/sda2 resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/sda2 is mounted on /; on-line resizing required old_desc_blocks = 13, new_desc_blocks = 15 The filesystem on /dev/sda2 is now 31456763 (4k) blocks long.
再使用df命令查看, 可以发现文件系统已经扩展完成了.
1 2 3
root@lsp-sg-game-1:~# df -h . Filesystem Size Used Avail Use% Mounted on /dev/sda2 118G 65G 48G 58% /