qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: possible to resize (extend) a raw image online with qemu-img ?


From: Dongli Zhang
Subject: Re: possible to resize (extend) a raw image online with qemu-img ?
Date: Tue, 19 Oct 2021 10:34:20 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1

I never use qemu-img but just FYI my notes on how to resize raw image.

To resize with 'raw' format.

1. To create image file in 'raw' format.

guest# dd if=/dev/zero of=test.raw bs=1M count=64 oflag=direct

2. To boot VM with QEMU.

host# qemu-system-x86_64 -m 4000M -enable-kvm -smp 4 -vnc :5 \
  -net nic -net user,hostfwd=tcp::5025-:22 \
  -device virtio-blk-pci,drive=drive0,id=virtblk0,num-queues=16 \
  -drive file=ol7.qcow2,if=none,id=drive0 \
  -device virtio-blk-pci,drive=drive1,id=virtblk1,num-queues=16 \
  -drive file=test.raw,if=none,id=drive1 \
  -monitor stdio -cpu host
QEMU 4.2.0 monitor - type 'help' for more information
(qemu)

3. To view disk size within VM.

guest# cat /sys/block/vdb/size
131072

4 (optional). To extend the host image file from 64M to 128M. This step is
optional as 'block_resize' in QEMU shell would be able to do that.

host# dd if=/dev/zero of=test.raw bs=1M count=64 oflag=append conv=notrunc

5. To extend the host image file from 64M to 128M and propagate the change to
guest via QEMU.

(qemu) block_resize drive1 128M

6. Now the new disk size is available within VM.

guest# cat /sys/block/vdb/size
262144

[  124.446907] virtio_blk virtio1: [vdb] new size: 262144 512-byte logical
blocks (134 MB/128 MiB)
[  124.448132] vdb: detected capacity change from 67108864 to 134217728

Dongli Zhang

On 10/19/21 10:08 AM, Lentes, Bernd wrote:
> Hi ML,
> 
> is it possible to extend the disk (raw format) of a running guest with 
> qemu-img ?
> 
> Thanks.
> 
> 
> Bernd
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]