AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1840741
Accepted
Keith Herbert
Keith Herbert
Asked: 2024-04-29 09:01:44 +0800 CST2024-04-29 09:01:44 +0800 CST 2024-04-29 09:01:44 +0800 CST

QEMU 中的 VM 无法识别虚拟大小,报告“设备上没有剩余空间”

  • 772

我从最新的 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

这是怎么回事?为什么虚拟机看不到虚拟大小以及如何修复它?

virtual-machine
  • 1 1 个回答
  • 18 Views

1 个回答

  • Voted
  1. Best Answer
    Keith Herbert
    2024-04-29T09:19:34+08:002024-04-29T09:19:34+08:00

    我现在明白了。growpart我需要使用和 将文件系统扩展到虚拟分区的大小resize2fs。

    # apt-get install cloud-utils
    ...
    # growpart /dev/vda 1
    CHANGED: partition=1 start=262144 old: size=3930112 end=4192255 new: size=311951
    03 end=31457246
    
    # resize2fs /dev/vda1
    resize2fs 1.47.0 (5-Feb-2023)
    Filesystem at /dev/vda1 is mounted on /; on-line resizing required
    old_desc_blocks = 1, new_desc_blocks = 2
    [ 1374.335500] EXT4-fs (vda1): resizing filesystem from 491264 to 3899387 blocks
    [ 1374.682227] EXT4-fs (vda1): resized filesystem to 3899387
    The filesystem on /dev/vda1 is now 3899387 (4k) blocks long.
    
    # df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            186M     0  186M   0% /dev
    tmpfs            48M  700K   47M   2% /run
    /dev/vda1        15G  1.3G   13G   9% /
    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
    
    • 0

相关问题

  • 无法从 App Store 下载 xCode (Mojave VM Ware)

  • 来宾运行时主机 MacOS 自动更新后虚拟框 linux 来宾死机

  • vmwared 共享文件夹不工作

  • virtualbox 是否需要 CPU 来支持 VT-d 以托管 64 位客户操作系统?

  • VMware Workstation USB 仲裁服务无法自动启动

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve