• qemu-img操作文件出现“Could not read snapshots: File too large”问题解决办法


    因为kvm虚拟机磁盘满,准备扩容磁盘,但用qemu-img命令执行扩容扩容的时候出现了下面的问题

    1. # qemu-img resize /data/AnolisOS.qcow2 +20G
    2. qemu-img: Could not open '/data/AnolisOS.qcow2': Could not read snapshots: File too large

    然后发现虚拟机也启动不了了

    1. # virsh start AnolisOS
    2. 错误:开始域 AnolisOS 失败
    3. 错误:内部错误:qemu unexpectedly closed the monitor: 2022-09-05T08:57:21.971604Z qemu-kvm: -drive file=/data/AnolisOS.qcow2,format=qcow2,if=none,id=drive-virtio-disk0: could not open disk image /ssd/vm/host-38.AnolisOS.qcow2: Could not read snapshots: File too large

    通过百度找到仅有的一篇,无头无尾 qemu-img报错 - 知了社区

    果断挂梯子,Google之,资料多了些,好像是一个bug,有人已经遇到了 https://bugs.launchpad.net/qemu/+bug/1354167

    2个解决方案,都要下载qemu源码,todd大神建议1.7.2版的

    1. # wget https://download.qemu.org/qemu-1.7.2.tar.bz2
    2. 。。。。
    3. # tar jxvf qemu-1.7.2.tar.bz2

    1、参考百度来的方案使用test工具(bug回复中也有人回)

    1. # ./tests/qemu-iotests/qcow2.py /data/AnolisOS.qcow2 dump-header
    2. magic 0x514649fb
    3. version 3
    4. backing_file_offset 0x0
    5. backing_file_size 0x0
    6. cluster_bits 16
    7. size 21475270656
    8. crypt_method 0
    9. l1_size 62
    10. l1_table_offset 0x11a7c0000
    11. refcount_table_offset 0x10000
    12. refcount_table_clusters 1
    13. nb_snapshots 2
    14. snapshot_offset 0xb0000
    15. incompatible_features 0x0
    16. compatible_features 0x0
    17. autoclear_features 0x0
    18. refcount_order 4
    19. header_length 104
    20. # ./tests/qemu-iotests/qcow2.py /data/AnolisOS.qcow2 set-header nb_snapshots 0
    21. # ./tests/qemu-iotests/qcow2.py /data/AnolisOS.qcow2 set-header snapshot_offset 0x0
    22. # ./tests/qemu-iotests/qcow2.py /data/AnolisOS.qcow2 dump-header
    23. magic 0x514649fb
    24. version 3
    25. backing_file_offset 0x0
    26. backing_file_size 0x0
    27. cluster_bits 16
    28. size 21475270656
    29. crypt_method 0
    30. l1_size 62
    31. l1_table_offset 0x11a7c0000
    32. refcount_table_offset 0x10000
    33. refcount_table_clusters 1
    34. nb_snapshots 0
    35. snapshot_offset 0x0
    36. incompatible_features 0x0
    37. compatible_features 0x0
    38. autoclear_features 0x0
    39. refcount_order 4
    40. header_length 104

    成功!

    2、编译后使用编译后的执行文件转换(不要安装)

    # ./configure && make
    

    编译后执行

    1. # ./qemu-img convert /data/AnolisOS.qcow2 /data/AnolisOS.fixed.qcow2
    2. # mv /data/AnolisOS.qcow2 /data/AnolisOS.qcow2.bak && mv /data/AnolisOS.fixed.qcow2 /data/AnolisOS.qcow2

    检查文件信息正常了,损害的时候info查看不了

    1. # qemu-img info /data/AnolisOS.qcow2
    2. image: /data/AnolisOS.qcow2
    3. file format: qcow2
    4. virtual size: 20G (21475270656 bytes)
    5. disk size: 25G
    6. cluster_size: 65536
    7. Format specific information:
    8. compat: 1.1
    9. lazy refcounts: false

     之后扩容就正常了

    1. # qemu-img resize /data/AnolisOS.qcow2 +20G
    2. Image resized.

  • 相关阅读:
    HFSS-API入门第二弹:基本形状和操作
    GTK构件之杂项构件(2)
    第七章 树与森林
    论文解读(S^3-CL)《Structural and Semantic Contrastive Learning for Self-supervised Node Representation Learning》
    GCC优化
    springboot+jacob实现文字转语音
    【Azure 架构师学习笔记】-Azure Storage Account(6)- File Layer
    【云原生】K8S--负载均衡详细介绍;什么是K8S的负载均衡?
    设计模式-行为型模式-责任链模式
    java毕业设计基于javaweb+mysql数据库实现的在线学习网站|在线课堂含论文+开题报告
  • 原文地址:https://blog.csdn.net/ljf1279/article/details/126709891