qemu-discuss
[Top][All Lists]
Advanced

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

Re: how to change sector size using qemu-img


From: Kevin Wolf
Subject: Re: how to change sector size using qemu-img
Date: Mon, 28 Jun 2021 09:24:14 +0200

Am 25.06.2021 um 21:06 hat Nir Soffer geschrieben:
> On Fri, Jun 25, 2021 at 7:40 PM Jiatong Shen <yshxxsjt715@gmail.com> wrote:
> >
> > Hello community,
> >
> > I have a disk with both logical and physical sector size being 4096. I have 
> > a qcow2 image which is built from a virtual machine has legacy 512 bytes 
> > sector size.
> >
> > when I do something like
> >
> > qemu-img convert -f qcow2 -O host_device disk device
> 
> This cannot change the sector size used in the file system inside
> this image.
> 
> > turns out it will not work. mounting a filesystem reports an error.
> >
> > Any advice on how to possibly work around this? thank you.
> 
> You need to use physical block size of 4k when running the guest:
> 
>     -device virtio-scsi-pci,id=scsi1,bus=pci.0 \
>     -drive 
> file=/home/scsi/disk2.qcow2,if=none,id=drive-virtio-disk1,format=qcow2,cache=none,aio=native,media=disk,werror=stop,rerror=stop
> \
>     -device 
> scsi-hd,bus=scsi1.0,drive=drive-virtio-disk1,id=virtio-scsi-pci1,physical_block_size=4096,logical_block_size=512
> \
> 
> See https://bugzilla.redhat.com/1448021
> 
> If you use libvirt, it can be done via:
> 
>     <blockio logical_block_size='512' physical_block_size='4096'/>
> 
> See https://libvirt.org/formatdomain.html#elementsDisks

This shouldn't make a difference, the important part is the logical
block size. And QEMU is supposed to emulate 512 byte sectors on top of a
4k sector disk on the host anyway.

Unfortunately, I don't have any details about which operation
specifically is failing, the error message, or which version is
involved, so it's hard to take a guess.

Kevin




reply via email to

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