[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to change sector size using qemu-img
From: |
Nir Soffer |
Subject: |
Re: how to change sector size using qemu-img |
Date: |
Fri, 25 Jun 2021 22:06:30 +0300 |
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
Nir