Linux | ubuntu虚拟机扩容

Linux | ubuntu虚拟机扩容


1.情形

#查看虚拟机文件系统的磁盘空间占用情况
[user@fly-vm ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           393M   24M  369M   6% /run
/dev/sda1        49G   28G   19G  60% /
tmpfs           2.0G  216K  2.0G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
tmpfs           393M   52K  393M   1% /run/user/1001

查看,可知总的磁盘空间为50GB,已经使用了60%。担心未来可能需要更多的空间,决定扩容到80GB

2.操作

2-1.虚拟机设置(关机状态)

vm-ubuntu-00


vm-ubuntu-01

2-2.开启虚拟机

vm-ubuntu-02

2-3.安装gparted

[$(USER)@fly-vm ~]$ sudo apt-get install gparted
[sudo] password for $(USER): 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  snapd-login-service
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libglib2.0-0 libglib2.0-bin libglibmm-2.4-1v5 libgtkmm-2.4-1v5 libpangomm-1.4-1v5 libparted-fs-resize0 libparted2 libreadline7
  libsigc++-2.0-0v5 parted
Suggested packages:
  xfsprogs reiserfsprogs reiser4progs jfsutils kpartx dmraid dmsetup gpart libparted-dev libparted-i18n parted-doc
The following NEW packages will be installed:
  gparted libgtkmm-2.4-1v5 libparted-fs-resize0 libreadline7
The following packages will be upgraded:
  libglib2.0-0 libglib2.0-bin libglibmm-2.4-1v5 libpangomm-1.4-1v5 libparted2 libsigc++-2.0-0v5 parted
7 upgraded, 4 newly installed, 0 to remove and 1625 not upgraded.
Need to get 3,275 kB of archives.
After this operation, 7,426 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 libglib2.0-bin amd64 2.56.4-0ubuntu0.18.04.9 [68.9 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 libglib2.0-0 amd64 2.56.4-0ubuntu0.18.04.9 [1,169 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libreadline7 amd64 7.0-3 [124 kB]
Get:4 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 parted amd64 3.2-20ubuntu0.3 [42.5 kB]
Get:5 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 libparted2 amd64 3.2-20ubuntu0.3 [123 kB]
Get:6 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libsigc++-2.0-0v5 amd64 2.10.0-2 [10.9 kB]
Get:7 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libglibmm-2.4-1v5 amd64 2.56.0-1 [516 kB]
Get:8 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libpangomm-1.4-1v5 amd64 2.40.1-4 [42.5 kB]
Get:9 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libgtkmm-2.4-1v5 amd64 1:2.24.5-2 [666 kB]
Get:10 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 libparted-fs-resize0 amd64 3.2-20ubuntu0.3 [47.0 kB]
Get:11 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 gparted amd64 0.30.0-3ubuntu2 [466 kB]
Fetched 3,275 kB in 1s (2,291 kB/s)
(Reading database ... 243436 files and directories currently installed.)
Preparing to unpack .../libglib2.0-bin_2.56.4-0ubuntu0.18.04.9_amd64.deb ...
Unpacking libglib2.0-bin (2.56.4-0ubuntu0.18.04.9) over (2.48.2-0ubuntu4.8) ...
Preparing to unpack .../libglib2.0-0_2.56.4-0ubuntu0.18.04.9_amd64.deb ...
Unpacking libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.9) over (2.48.2-0ubuntu4.8) ...
Selecting previously unselected package libreadline7:amd64.
Preparing to unpack .../libreadline7_7.0-3_amd64.deb ...
Unpacking libreadline7:amd64 (7.0-3) ...
Preparing to unpack .../parted_3.2-20ubuntu0.3_amd64.deb ...
Unpacking parted (3.2-20ubuntu0.3) over (3.2-15ubuntu0.1) ...
Preparing to unpack .../libparted2_3.2-20ubuntu0.3_amd64.deb ...
Unpacking libparted2:amd64 (3.2-20ubuntu0.3) over (3.2-15ubuntu0.1) ...
Preparing to unpack .../libsigc++-2.0-0v5_2.10.0-2_amd64.deb ...
Unpacking libsigc++-2.0-0v5:amd64 (2.10.0-2) over (2.6.2-1) ...
Preparing to unpack .../libglibmm-2.4-1v5_2.56.0-1_amd64.deb ...
Unpacking libglibmm-2.4-1v5:amd64 (2.56.0-1) over (2.46.3-1) ...
Preparing to unpack .../libpangomm-1.4-1v5_2.40.1-4_amd64.deb ...
Unpacking libpangomm-1.4-1v5:amd64 (2.40.1-4) over (2.38.1-1) ...
Selecting previously unselected package libgtkmm-2.4-1v5:amd64.
Preparing to unpack .../libgtkmm-2.4-1v5_1%3a2.24.5-2_amd64.deb ...
Unpacking libgtkmm-2.4-1v5:amd64 (1:2.24.5-2) ...
Selecting previously unselected package libparted-fs-resize0:amd64.
Preparing to unpack .../libparted-fs-resize0_3.2-20ubuntu0.3_amd64.deb ...
Unpacking libparted-fs-resize0:amd64 (3.2-20ubuntu0.3) ...
Selecting previously unselected package gparted.
Preparing to unpack .../gparted_0.30.0-3ubuntu2_amd64.deb ...
Unpacking gparted (0.30.0-3ubuntu2) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu11.3) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1.1) ...
Setting up libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.9) ...
Setting up libglib2.0-bin (2.56.4-0ubuntu0.18.04.9) ...
Setting up libreadline7:amd64 (7.0-3) ...
Setting up libparted2:amd64 (3.2-20ubuntu0.3) ...
Setting up parted (3.2-20ubuntu0.3) ...
Setting up libsigc++-2.0-0v5:amd64 (2.10.0-2) ...
Setting up libglibmm-2.4-1v5:amd64 (2.56.0-1) ...
Setting up libpangomm-1.4-1v5:amd64 (2.40.1-4) ...
Setting up libgtkmm-2.4-1v5:amd64 (1:2.24.5-2) ...
Setting up libparted-fs-resize0:amd64 (3.2-20ubuntu0.3) ...
Setting up gparted (0.30.0-3ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for libc-bin (2.23-0ubuntu11.3) ...

2-4.打开软件

vm-ubuntu-03


vm-ubuntu-04


2-5.修改、设置

删除旧的交换分区,便于重新划分/dev/sda1linux-swap分区;

vm-ubuntu-05


vm-ubuntu-06


vm-ubuntu-07


重新划分/dev/sda1分区;

vm-ubuntu-08


vm-ubuntu-09


重新设置linux-swap分区;

vm-ubuntu-10


vm-ubuntu-11


最后点击确定,执行所有的设置。

vm-ubuntu-12


3.查看

[$(USER)@fly-vm Pictures]$ sudo fdisk -l
[sudo] password for $(USER): 
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 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
Disklabel type: dos
Disk identifier: 0xd9b6d031

Device     Boot     Start       End   Sectors Size Id Type
/dev/sda1  *         2048 165672959 165670912  79G 83 Linux
/dev/sda2       165672960 167772159   2099200   1G 82 Linux swap / Solaris

4.参考

vmware中ubuntu虚拟机扩容

posted @ 2023-05-28 11:53  hello,123456  阅读(225)  评论(0编辑  收藏  举报