virtualbox(ubuntu)扩大磁盘空间 - Mon, Dec 16, 2019
virtualbox(ubuntu)扩大磁盘空间
1. 概述
virtualbox初始设置的磁盘太小,在使用过程中,磁盘空间不足,所以需要对磁盘进行扩大。
2. 扩张方法
2.1 virtualbox 扩大磁盘
虚拟机管理->虚拟介质管理
扩大磁盘大小10G->20G
2.2 扩大lvm磁盘大小
- 查看磁盘信息
df -h
Filesystem Size Used Avail Use% Mounted on
udev 967M 0 967M 0% /dev
tmpfs 200M 992K 199M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 3.9G 3.5G 244M 94% /
tmpfs 997M 0 997M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 997M 0 997M 0% /sys/fs/cgroup
/dev/loop0 89M 89M 0 100% /snap/core/7270
/dev/loop1 90M 90M 0 100% /snap/core/8268
/dev/sda2 976M 77M 832M 9% /boot
gopath 466G 169G 297G 37% /home/pana/go
tmpfs 200M 0 200M 0% /run/user/1000
- 扩展lvm信息
sudo lvextend -L +1G /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 5.00 GiB (1280 extents) to 6.00 GiB (1536 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
多执行几次,直到
Insufficient free space: 256 extents needed, but only 255 available
- 重定义lvm大小
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 8G
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 2097152 (4k) blocks long.