修改虚拟机镜像大小(qcow2/raw resize)

创建一个镜像文件,大小1G  

taw

muxueqz@muxueqz /tmp $ qemu-img create -f raw t.raw 1G  
Formatting 't.raw', fmt=raw size=1073741824  
muxueqz@muxueqz /tmp $ qemu-img info t.raw  
image: t.raw  
file format: raw  
virtual size: 1.0G (1073741824 bytes)  
disk size: 1.0M  

qcow2

muxueqz@muxueqz /tmp $ qemu-img create -f qcow2 t.qcow2 1G  
Formatting 't.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=0  

 

查看镜像文件实际占用空间

muxueqz@muxueqz /tmp $ ls -alh t.qcow2  
-rw-r--r-- 1 muxueqz muxueqz 193K 8月 31 13:18 t.qcow2  

查看qcow2信息

muxueqz@muxueqz /tmp $ qemu-img info t.qcow2  
image: t.qcow2  
file format: qcow2  
virtual size: 1.0G (1073741824 bytes)  
disk size: 136K  
cluster_size: 65536  

 

加1G(resize +)

 

muxueqz@muxueqz /tmp $ qemu-img resize t.qcow2 +1G  
Image resized.  

 

相关文章:

  • 2021-05-16
  • 2022-01-09
  • 2021-10-24
  • 2021-09-23
  • 2021-07-18
  • 2021-09-06
  • 2021-07-07
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2021-11-29
  • 2021-10-17
相关资源
相似解决方案