VirtualBox虚拟机装的ubuntu系统,最初给了30G空间,但现在已经报磁盘空间不够了,折腾了几天,可算完成空间扩容,记录下来吧!
1、宿主机增加空间 关闭要扩容的虚拟机,查看硬盘信息,获取硬盘位置,执行虚拟机的空间扩容
C:\>cd 'c:\program Files\Oracle\virtualBox\'
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd "e:\VirtualBox VMs\Ubuntu22.10\Ubuntu.vdi" --resize 61440
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
增加到60G 2、进入虚拟机增加系统空间 u@u:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 4K 1 loop /snap/bare/5
loop1 7:1 0 73.8M 1 loop /snap/core22/750
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 513M 0 part /boot/efi
└─sda3 8:3 0 30G 0 part /var/snap/firefox/common/host-hunspell
sda 60G了,dsa3还是30G 使用parted /dev/sda扩容空间 sudo parted /dev/sda
GNU Parted 3.5
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart 3 100%
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra 20971520 blocks) or continue with
the current setting?
Fix/Ignore? Fix
Partition number?3
(parted) quit
u@u:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 4K 1 loop /snap/bare/5
loop1 7:1 0 73.8M 1 loop /snap/core22/750
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 513M 0 part /boot/efi
└─sda3 8:3 0 60G 0 part /var/snap/firefox/common/host-hunspell
lsblk查看空间已经是60G u@u:~$ df -lh
Filesystem Size Used Avail Use% Mounted on
tmpfs 197M 6.3M 191M 4% /run
/dev/sda3 30G 25G 5G 83% /
tmpfs 982M 0 982M 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/sda2 512M 6.1M 506M 2% /boot/efi
tmpfs 197M 124K 197M 1% /run/user/131
tmpfs 197M 128K 197M 1% /run/user/1000
df查看空间还是30G 执行sudo resize2fs /dev/sda3刷新空间 u@u:~$ sudo resize2fs /dev/sda3
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 8
The filesystem on /dev/sda3 is now 15596795 (4k) blocks long.
u@u:~$ df -lh
Filesystem Size Used Avail Use% Mounted on
tmpfs 197M 6.3M 191M 4% /run
/dev/sda3 59G 25G 31G 45% /
tmpfs 982M 0 982M 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/sda2 512M 6.1M 506M 2% /boot/efi
tmpfs 197M 124K 197M 1% /run/user/131
tmpfs 197M 128K 197M 1% /run/user/1000
u@u:~$
执行sudo resize2fs /dev/sda3刷新空间
参考连接如下:
https://www.lmlphp.com/user/58523/article/item/822365/
https://blog.csdn.net/weixin_42856871/article/details/122534245