我从最新的 Debian 云映像开始,并为我的虚拟机制作一个副本。
❯ cp debian-12-nocloud-arm64.qcow2 kthw-jumpbox
❯ qemu-img info kthw-jumpbox
image: kthw-jumpbox
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 381 MiB
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
refcount bits: 16
corrupt: false
extended l2: false
Child node '/file':
filename: kthw-jumpbox
protocol type: file
file length: 381 MiB (399179776 bytes)
disk size: 381 MiB
然后将其大小调整为15G:
❯ qemu-img resize kthw-jumpbox 15G
Image resized.
❯ qemu-img info kthw-jumpbox
image: kthw-jumpbox
file format: qcow2
virtual size: 15 GiB (16106127360 bytes)
disk size: 381 MiB
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
refcount bits: 16
corrupt: false
extended l2: false
Child node '/file':
filename: kthw-jumpbox
protocol type: file
file length: 381 MiB (399180288 bytes)
disk size: 381 MiB
所以我们可以看到虚拟大小是15GiB
。
我做了一些设置这个虚拟机的工作。但是当我复制文件时,出现错误:
# cp downloads/kubectl /usr/local/bin/
cp: error copying 'downloads/kubectl' to '/usr/local/bin/kubectl': No space left
on device
检查df
显示,在 2G 的使用情况下,其 100% 已满:
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 186M 0 186M 0% /dev
tmpfs 48M 696K 47M 2% /run
/dev/vda1 1.9G 1.8G 0 100% /
tmpfs 236M 0 236M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/vda15 127M 294K 127M 1% /boot/efi
tmpfs 48M 0 48M 0% /run/user/0
但qemu-img
仍然显示虚拟大小为15G
❯ qemu-img info kthw-jumpbox
image: kthw-jumpbox
file format: qcow2
virtual size: 15 GiB (16106127360 bytes)
disk size: 1.3 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
refcount bits: 16
corrupt: false
extended l2: false
Child node '/file':
filename: kthw-jumpbox
protocol type: file
file length: 1.3 GiB (1397948416 bytes)
disk size: 1.3 GiB
这是怎么回事?为什么虚拟机看不到虚拟大小以及如何修复它?