Linux虚拟机vmware中使用gparted调整磁盘大小并设置swap分区

参考链接:

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. 重启电脑

 

posted @ 2021-11-19 16:00  ziwuxian  阅读(1511)  评论(0编辑  收藏  举报