qemu Qemu kill the device files partitions of the sd card. (Resolved)

I use a script to boot an armv8 installation on an sd card from FreeBSD on a PC. So I need qemu-system-aarch64 to do so. I do it with the root previleges. Before to power up and after power down the virtual machine I see the device files of the sd card in the /dev directory:

ls -al /dev/da1*
crw-r----- 1 root operator 0x1b9 3 déc. 00:24 /dev/da1
crw-r----- 1 root operator 0x1ba 3 déc. 03:18 /dev/da1p1
crw-r----- 1 root operator 0x1bc 3 déc. 03:18 /dev/da1p2
crw-r----- 1 root operator 0x1bd 3 déc. 03:18 /dev/da1p3

This correspond to the sd card Gpt partition table according to geom and gpart. The problem start when I launch the qemu script. In the directory /dev on the host (FreeBSD) only the disk /dev/da1 stay and the partitions device files of the disk desappear. So, ArchLinux arm cannot boot because it cannot see the root partition. I must kill qemu to recover the prompt and than the partitions device files of the disk reappear as they where before starting Qemu.

I cannot explain this. No matter if the partition table of the sd card is Dos or Gpt I have the same desappear problem during qemu is active. The script is

#!/usr/local/bin/bash

qemu-system-aarch64 -append "audit=0 console=ttyAMA0 fbcon=scrollback:2048 loglevel=0 mitigations=off net.ifnames=0 nohz=off root=/dev/da1p3 rw selinux=0" \
-cpu cortex-a57 -display none \
-drive file=/dev/da1,format=raw,index=0,media=disk \
-full-screen -initrd Public/Alarm/initramfs-linux.img \
-kernel Public/Alarm/Image.gz -M virt -m 1024 \
-netdev tap,id=net0,ifname=tap0,script=no,downscript=no \
-net nic,model=e1000,netdev=net0 -nographic -usb -vga none

# -full-screen -nographic

exit 0
 
Isn't the disk exclusively occupied when you run qemu? Whatever vm is running in qemu - it should do its disk access inside the hypervisor and not on the host os level.

Why do you expect the partitions to be available on the host? Maybe you want to share your qemu command parameters?
 
By intuition or what ever when I use root=LABEL=Archv-part3 as the Linux kernel parameter instead of root=/dev/da1p3 it boot normally. It seem's that FreeBSD disable the partitions device files during qemu is active to prevent two sources access to the disk. I can use the device file name of Linux for it's root partition inside qemu root=/dev/vda3 and it work. I suppose that using root=UUID work too. So it resolved and I get more knowledge on how FreeBSD work with emulators.

I have been confuse by the fact that I am on FreeBSD because on a Linux host I use root=/dev/vda3 too as the kernel parameter inside the vm to boot the Arch arm.
 
Back
Top