參考鏈接:
https://blog.csdn.net/qq_26779635/article/details/103574517
https://www.jianshu.com/p/1d020b01177c
1. 首先把vmware中的linux關機,然后打開設置-> 硬盤-> 擴展:

2. 打開Gparted應用,你可以看到已分配分區狀況和新增未分配的分區(如果無此應用的話,先安裝:sudo apt-get install gparted)

3. 然后依次刪除/dev/sda5和/dev/sda2,刪除后,就會剩下/dev/sda1(14GB)和未分配的(15GB)
4. 接下來重新調整/dev/sda1的大小,我這里調整為23552(23GB),然后剩下2GB作為linux_swap,重新將未分配的2GB格式化,先new出一個extended的分區,然后再在這個extended的分區里new一個邏輯分區,並且file system選擇為linux-swap,最后選擇綠色的鈎鈎,完成保存。最后執行完后,如下圖所示
這樣原來Ubuntu的空間就從原來的13GB擴充到25GB
5. 激活swap分區
root@ubuntu:~# mkswap /dev/sda5 Setting up swapspace version 1, size = 2097148 KiB no label, UUID=cc64ac36-f5b0-4877-afe6-a49e76c72336
root@ubuntu:~# swapon /dev/sda5
6. 編輯fstab文件
root@ubuntu:~# vim /etc/fstab
修改 最后的swap配置行的UUID為 第5步中生成的UUID:
# Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda2 during installation UUID=e5c8f43e-7983-4a80-a636-08d82ef85725 / ext4 errors=remount-ro 0 1 # /boot was on /dev/sda1 during installation UUID=a293384b-a435-4f2d-82fe-bf0dfb2f60df /boot ext4 defaults 0 2 # swap was on /dev/sda5 during installation UUID=cc64ac36-f5b0-4877-afe6-a49e76c72336 none swap sw 0 0
7. 重啟電腦
