Simulating CD-ROM device with BHyve and ISO disk image?

Craig Rodrigues rodrigc at FreeBSD.org
Tue Aug 27 23:12:11 UTC 2013


Hi,

I have an ISO image that I am trying to boot in BHyve.

I tried this:

truncate -s 2G /tmp/disk.img
sh /usr/share/examples/bhyve/vmrun.sh -I test.iso -d /tmp/disk.img freenas1

The initial kernel boots, but then fails to mount the root device:

============================================================================
mountroot> ?

List of GEOM managed disk devices:
  iso9660/CDROM vtbd1 vtbd0

FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.1-STABLE #0 r+42f8bbd: Sun Aug 18 00:03:25 PDT 2013
    root at build.ixsystems.com:/tank/home/rodrigc/freenas/freenas/os-base/amd64/tank/home/rodrigc/freenas/freenas/FreeBSD/src/sys/FREENAS.amd64
amd64
gcc version 4.2.1 20070831 patched [FreeBSD]
CPU: Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz (2494.19-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0x206a7  Family = 0x6  Model = 0x2a
Stepping = 7

Features=0x8f8bab7f<FPU,VME,DE,PSE,TSC,MSR,PAE,CX8,APIC,SEP,PGE,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,SS,PBE>

Features2=0x83ba6257<SSE3,PCLMULQDQ,DTES64,DS_CPL,SMX,SSSE3,CX16,xTPR,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,TSCDLT,AESNI,HV>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0x1<LAHF>
  TSC: P-state invariant
real memory  = 536870912 (512 MB)
avail memory = 492359680 (469 MB)
Event timer "LAPIC" quality 400
ACPI APIC Table: <BHYVE  BVMADT  >
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 2 package(s) x 1 core(s)
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
WARNING: VIMAGE (virtualized network stack) is a highly experimental
feature.
ACPI Warning: FADT (revision 5) is longer than ACPI 2.0 version, truncating
length 268 to 244 (20110527/tbfadt-320)
ioapic0: Changing APIC ID to 2
ioapic0 <Version 1.1> irqs 0-16 on motherboard
kbd0 at kbdmux0
aesni0: <AES-CBC,AES-XTS> on motherboard
cryptosoft0: <software crypto> on motherboard
acpi0: <BHYVE BVXSDT> on motherboard
atrtc0: <AT realtime clock> port 0x70-0x71,0x72-0x77 irq 8 on acpi0
Event timer "RTC" frequency 32768 Hz quality 0
Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
acpi_timer0: <32-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pcib0: no PRT entry for 0.31.INTA
virtio_pci0: <VirtIO PCI Network adapter> port 0x2000-0x201f mem
0xc0000000-0xc0001fff at device 1.0 on pci0
vtnet0: <VirtIO Networking Adapter> on virtio_pci0
virtio_pci0: host features: 0x1018020
<NotifyOnEmpty,Status,MrgRxBuf,MacAddress>
virtio_pci0: negotiated features: 0x1018020
<NotifyOnEmpty,Status,MrgRxBuf,MacAddress>
vtnet0: Ethernet address: 00:a0:98:30:99:23
virtio_pci1: <VirtIO PCI Block adapter> port 0x2040-0x207f mem
0xc0002000-0xc0003fff at device 2.0 on pci0
vtblk0: <VirtIO Block Adapter> on virtio_pci1
virtio_pci1: host features: 0x10000004 <RingIndirect,MaxNumSegs>
virtio_pci1: negotiated features: 0x10000004 <RingIndirect,MaxNumSegs>
vtblk0: 2048MB (4194304 512 byte sectors)
virtio_pci2: <VirtIO PCI Block adapter> port 0x2080-0x20bf mem
0xc0004000-0xc0005fff at device 3.0 on pci0
vtblk1: <VirtIO Block Adapter> on virtio_pci2
virtio_pci2: host features: 0x10000004 <RingIndirect,MaxNumSegs>
virtio_pci2: negotiated features: 0x10000004 <RingIndirect,MaxNumSegs>
vtblk1: 254MB (521624 512 byte sectors)
uart2: <16550 or compatible> port 0x3f8-0x3ff irq 4 at device 31.0 on pci0
uart2: console (9600,n,8,1)
Timecounters tick every 1.000 msec
ipfw2 (+ipv6) initialized, divert enabled, nat enabled, default to accept,
logging disabled
DUMMYNET 0xfffffe0002106940 with IPv6 initialized (100409)
load_dn_sched dn_sched WF2Q+ loaded
load_dn_sched dn_sched FIFO loaded
load_dn_sched dn_sched PRIO loaded
load_dn_sched dn_sched QFQ loaded
load_dn_sched dn_sched RR loaded
SMP: AP CPU #1 Launched!
Timecounter "TSC-low" frequency 1247092718 Hz quality 1000
Trying to mount root from cd9660:/dev/cd0 [ro]...
mountroot: waiting for device /dev/cd0 ...
Mounting from cd9660:/dev/cd0 failed with error 19.
Trying to mount root from cd9660:/dev/acd0 [ro]...
mountroot: waiting for device /dev/acd0 ...
Mounting from cd9660:/dev/acd0 failed with error 19.

Loader variables:

Manual root filesystem specification:
  <fstype>:<device> [options]
      Mount <device> using filesystem <fstype>
      and with the specified (optional) option list.

    eg. ufs:/dev/da0s1a
        zfs:tank
        cd9660:/dev/acd0 ro
          (which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /)

  ?               List valid disk boot devices
  .               Yield 1 second (for background tasks)
  <empty line>    Abort manual input

mountroot> ?

List of GEOM managed disk devices:
  iso9660/CDROM vtbd1 vtbd0

============================================================================

Currently the logic for how the root mount device is chosen
is hardcoded in the vfs_mountroot_conf0 function:

http://bxr.su/FreeBSD/sys/kern/vfs_mountroot.c#823


This logic basically says, try in this order:

cd9660:/dev/cd0
cd9660:/dev/acd0
device specified in vfs.root.mountfrom

It looks like with BHyve, if I invoke the vmrun.sh script as I have
done, the ISO file is not on cd0 or acd0, but is on vtbd1.

Is there a way I can mount the ISO file on a simulated cd0 device?
This would make the logic in my installer still work.
This ISO image successfully boots on real hardware,
and in qemu with the "-cdrom" flag.

Thanks.

--
Craig


More information about the freebsd-virtualization mailing list