我想在qemu中使用4k块大小的模拟nvme设备。所以我的剧本是这样的:
#!/bin/bash
QEMU_EXE="path/to/bin/qemu-system-x86_64"
SYSTEM_IMG="path/to/ubuntu1604.qcow2"
NVME_IMG="./nvme_8G.img"
$QEMU_EXE -m 2G \
-machine q35 \
-hda ${SYSTEM_IMG} \
-drive file=${NVME_IMG},format=raw,if=none,id=drv0 \
-device nvme,drive=drv0,serial=foo,opt_io_size=4096,min_io_size=4096,logical_block_size=4096,physical_block_size=4096 \
-smp 4 \
-enable-kvm \
-net nic \
-net user,hostfwd=tcp::2222-:22
但是,当我进入客户机时,“-device nvme…”中的块/io大小似乎没有任何影响:
lifeng@node0:~$ sudo fdisk -l
[sudo] password for lifeng:
Disk /dev/nvme0n1: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xbbb77ab7
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 58722303 58720256 28G 83 Linux
/dev/sda2 58724350 62912511 4188162 2G 5 Extended
/dev/sda5 58724352 62912511 4188160 2G 82 Linux swap / Solaris
我使用的是从源代码编译的QEMU 2.11(./configure,只更改了前缀),我遵循了下面的配置说明:
lifeng@1wk300:~/software/qemu-2.11.1qemu-system-x86_64 -device nvme,help
nvme.serial=str
nvme.rombar=uint32
nvme.logical_block_size=uint16 (A power of two between 512 and 32768)
nvme.discard_granularity=uint32
nvme.drive=str (ID of a drive to use as a backend)
nvme.bootindex=int32
nvme.multifunction=bool (on/off)
nvme.opt_io_size=uint32
nvme.min_io_size=uint16
nvme.romfile=str
nvme.command_serr_enable=bool (on/off)
nvme.addr=int32 (Slot and optional function number, example: 06.0 or 06)
nvme.physical_block_size=uint16 (A power of two between 512 and 32768)
如有任何帮助或意见,我们将不胜感激!
最佳答案
我发现qemu nvme可以有4k块和nvme的扇区大小,
安装后,请使用以下命令查看更多详细信息:
qemu\install\dir/bin/qemu-system-x86_64 -device nvme,help