Difference between revisions of "From QEMU to BigEndian FreeBSD"

From RCS Wiki
Jump to navigation Jump to search
m
m
Line 1: Line 1:
 
This tutorial takes the reader from the bare minimum to launch a virtual machine with QEMU to a full installation of big-endian FreeBSD.  The Raptor POWER9 host machine is running little-endian Debian.  The short version is for experienced users just needing specifics, while the long version examines each parameter and shows the effect on the virtual machine and installation.  Specific details in the short version are linked to explanations in the long version.
 
This tutorial takes the reader from the bare minimum to launch a virtual machine with QEMU to a full installation of big-endian FreeBSD.  The Raptor POWER9 host machine is running little-endian Debian.  The short version is for experienced users just needing specifics, while the long version examines each parameter and shows the effect on the virtual machine and installation.  Specific details in the short version are linked to explanations in the long version.
  
This documentation is released under the requirements of the GPL v2, per the licensing of the QEMU documentation, as knowledge was derived from the QEMU documentation and therefore this is derivative works.  This supercedes the Creative Commons deed under which this documentation is released.
+
Although this documentation is intended to provide information to public users and be freely available, it is released and licensed as required by the GPL v2, per the licensing of the QEMU documentation.  Since knowledge was derived from the QEMU documentation, this is therefore derivative works.  This supercedes the Creative Commons deed under which this documentation is released.
  
 
=== The short version ===
 
=== The short version ===

Revision as of 08:02, 30 June 2025

This tutorial takes the reader from the bare minimum to launch a virtual machine with QEMU to a full installation of big-endian FreeBSD. The Raptor POWER9 host machine is running little-endian Debian. The short version is for experienced users just needing specifics, while the long version examines each parameter and shows the effect on the virtual machine and installation. Specific details in the short version are linked to explanations in the long version.

Although this documentation is intended to provide information to public users and be freely available, it is released and licensed as required by the GPL v2, per the licensing of the QEMU documentation. Since knowledge was derived from the QEMU documentation, this is therefore derivative works. This supercedes the Creative Commons deed under which this documentation is released.

The short version

Make sure #qemu-system-ppc64 and #qemu-img are installed. Use apt install if they are not.

Download the most recent version of big-endian FreeBSD from

https://download.freebsd.org/releases/powerpc/powerpc64/ISO-IMAGES/

Using the example of FreeBSD 14.3 as the iso-based installer, fbsd.raw as the destination #storage device, four threads per #CPU core with four cores, 8GB of #RAM, e1000 #NIC, no IPv6, and 2222 as the ssh port into the guest:

# qemu-system-ppc64 --enable-kvm -M pseries,cap-nested-hv=true,cap-ibs=workaround -cpu host -smp cores=4,threads=4,sockets=1 -m 8G -nographic -drive file=fbsd.raw,format=raw,if=virtio,id=drive0 -drive file=FreeBSD-14.3-RELEASE-powerpc-powerpc64-disc1.iso,media=cdrom,if=virtio,id=drive1 -nic user,ipv6=off,model=e1000,mac=52:54:98:76:54:32,hostfwd=tcp::2222-:22

Choose MBR for disk partition type. Use DHCP to configure IPv4, and do not configure IPv6. Choose any additional components as needed during the installation process. For this example we named the machine "BEFreeBSD." Add a user and add the user to group wheel (for this we created "user1").

While in the installer, choose "Yes" to enter the shell and modify /etc/fstab to use /dev/vtbd0 instead of /dev/vtbd1 (if necessary):

# cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/vtbd0s2a   /               ufs     rw      1       1
/dev/vtbd0s2b   none            swap    sw      0       0

Either remove remote login by root at this time or do so after rebooting. Shutdown the VM and relaunch it with

# qemu-system-ppc64 --enable-kvm -M pseries,cap-nested-hv=true,cap-ibs=workaround -cpu host -smp cores=4,threads=4,sockets=1 -m 8G -nographic -drive file=fbsd.raw,format=raw,if=virtio,id=drive0 -nic user,ipv6=off,model=e1000,mac=52:54:98:76:54:32,hostfwd=tcp::2222-:22

to remove the CD installer. Log in with the user ("user1") that was added to the wheel group. Check the configuration for any unexpected values.

% dmesg | grep CPU
FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs
xicp0: Handling CPUs 0-15
cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0

 % dmesg | grep memory
real memory  = 8544366592 (8148 MB)
avail memory = 8216293376 (7835 MB)

% uname -a
FreeBSD BEFreeBSD 14.3-RELEASE FreeBSD 14.3-RELEASE releng/14.3-n271432-8c9ce319fef7 GENERIC powerpc

% ifconfig -a
em0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
        options=48525bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,LRO,WOL_MAGIC,VLAN_HWFILTER,VLAN_HWTSO,HWSTATS,MEXTPG>
        ether 52:54:98:76:54:32
        inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Log in locally with the created user ("user1") to check SSH:

# ssh -p 2222 user1@127.0.0.1
(user1@127.0.0.1) Password for user1@BEFreeBSD:
Last login: Sun Jun 29 09:02:48 2025 from xx
FreeBSD 14.3-RELEASE (GENERIC) releng/14.3-n271432-8c9ce319fef7

Welcome to FreeBSD!
...

Check that su works:

% su root
Password:
#

Log in remotely to make sure external ssh access is available. Configure automatic restart of VM with reboot of host machine.

The long version

This tutorial draws from the following web sites:

https://www.qemu.org/docs/master/system/introduction.html

https://www.qemu.org/docs/master/system/invocation.html

https://www.qemu.org/docs/master/tools/qemu-img.html

https://www.qemu.org/docs/master/system/ppc/powernv.html


qemu-system-ppc64

qemu-system-ppc64 is the QEMU executable used to provide a virtual machine on Raptor's hosts. To determine if you are running on a physical or virtual host, execute

# facter | grep virtual
is_virtual => false
virtual => physical

This is real host. A virtual one would look like

# facter | grep virtual
is_virtual => true
virtual => kvm

QEMU needs several parameters to describe the

CPU

RAM

No devices added (default SLOF boot):

0 > dev /   ok
0 > ls  
7e644530 :  /
7e644b40 :  |-- ibm,persistent-memory
7e644da0 :  |-- hypervisor
7e644f00 :  |-- chosen
7e645310 :  |-- rtas
7e646638 :  |-- event-sources
7e6467f0 :  |   |-- hot-plug-events
7e646948 :  |   +-- epow-events
7e646ae8 :  |-- cpus
7e646db0 :  |   |-- PowerPC,POWER9@0
7e6477e8 :  |   |-- PowerPC,POWER9@4
7e648220 :  |   |-- PowerPC,POWER9@8
7e648c58 :  |   +-- PowerPC,POWER9@c
7e649738 :  |-- pci@800000020000000
7e64bd18 :  |   |-- vga@0
7e64c230 :  |   +-- usb-xhci@1
7e68f7f8 :  |       |-- usb-keyboard@1
7e6902b8 :  |       +-- usb-mouse@2
7e64c908 :  |-- vdevice
7e64cb88 :  |   |-- vty@71000000
7e64cda8 :  |   |-- nvram@71000001
7e64d018 :  |   |-- l-lan@71000002
7e64d3e8 :  |   +-- v-scsi@71000003
7e673ba8 :  |       +-- disk
7e64d8a8 :  |-- memory@0
7e64daa0 :  |-- interrupt-controller
7e650be0 :  |-- aliases
7e650ce8 :  |-- options
7e650da8 :  |-- openprom
7e650eb0 :  |-- packages
7e650f78 :  |   |-- deblocker
7e651a18 :  |   |-- disk-label
7e6560b8 :  |   |-- fat-files
7e658830 :  |   |-- rom-files
7e659250 :  |   |-- ext2-files
7e65bcc8 :  |   |-- obp-tftp
7e65c098 :  |   +-- iso-9660
7e660ae0 :  +-- mmu ok
0 > 

qemu-img

Create a raw disk file to be the installation destination (in this case, 120GB):

# qemu-img create fbsd.raw 120G
Formatting 'fbsd.raw', fmt=raw size=128849018880
# ls -sl
total 924700
     4 -rw-r--r-- 1 root root 128849018880 Jun 28 13:31 fbsd.raw
924696 -rw-r--r-- 1 root root    952018944 Jun 25 05:04 FreeBSD-14.3-RELEASE-powerpc-powerpc64-disc1.iso


Storage

With CDROM and hard drive:

Ready! 
0 > dev /   ok
0 > ls  
7e644530 :  /
7e644b40 :  |-- ibm,persistent-memory
7e644da0 :  |-- hypervisor
7e644f00 :  |-- chosen
7e645310 :  |-- rtas
7e646638 :  |-- event-sources
7e6467f0 :  |   |-- hot-plug-events
7e646948 :  |   +-- epow-events
7e646ae8 :  |-- cpus
7e646db0 :  |   |-- PowerPC,POWER9@0
7e6477e8 :  |   |-- PowerPC,POWER9@4
7e648220 :  |   |-- PowerPC,POWER9@8
7e648c58 :  |   +-- PowerPC,POWER9@c
7e649738 :  |-- pci@800000020000000
7e64bd18 :  |   |-- vga@0
7e64c230 :  |   |-- usb-xhci@1
7e692660 :  |   |   |-- usb-keyboard@1
7e693120 :  |   |   +-- usb-mouse@2
7e64c860 :  |   |-- scsi@2             <-- Added device
7e64ce18 :  |   +-- scsi@3             <-- Added device
7e64d478 :  |-- vdevice
7e64d6f8 :  |   |-- vty@71000000
7e64d918 :  |   |-- nvram@71000001
7e64db88 :  |   |-- l-lan@71000002
7e64df58 :  |   +-- v-scsi@71000003
7e674718 :  |       +-- disk
7e64e418 :  |-- memory@0
7e64e610 :  |-- interrupt-controller
7e651750 :  |-- aliases
7e651858 :  |-- options
7e651918 :  |-- openprom
7e651a20 :  |-- packages
7e651ae8 :  |   |-- deblocker
7e652588 :  |   |-- disk-label
7e656c28 :  |   |-- fat-files
7e6593a0 :  |   |-- rom-files
7e659dc0 :  |   |-- ext2-files
7e65c838 :  |   |-- obp-tftp
7e65cc08 :  |   +-- iso-9660
7e661650 :  +-- mmu ok


NIC

With the network card:

0 > dev /    ok
0 > ls  
7e644530 :  /
7e644b40 :  |-- ibm,persistent-memory
7e644da0 :  |-- hypervisor
7e644f00 :  |-- chosen
7e645310 :  |-- rtas
7e646638 :  |-- event-sources
7e6467f0 :  |   |-- hot-plug-events
7e646948 :  |   +-- epow-events
7e646ae8 :  |-- cpus
7e646db0 :  |   |-- PowerPC,POWER9@0
7e6477e8 :  |   |-- PowerPC,POWER9@4
7e648220 :  |   |-- PowerPC,POWER9@8
7e648c58 :  |   +-- PowerPC,POWER9@c
7e649738 :  |-- pci@800000020000000
7e64bd18 :  |   |-- ethernet@0          <-- Added device
7e64c280 :  |   |-- vga@1
7e64c798 :  |   |-- usb-xhci@2
7e6933f8 :  |   |   |-- usb-keyboard@1
7e693eb8 :  |   |   +-- usb-mouse@2
7e64cdc8 :  |   |-- scsi@3
7e64d380 :  |   +-- scsi@4
7e64d9e0 :  |-- vdevice
7e64dc60 :  |   |-- vty@71000000
7e64de80 :  |   |-- nvram@71000001
7e64e0f0 :  |   +-- v-scsi@71000002
7e6742b8 :  |       +-- disk
7e64e5b0 :  |-- memory@0
7e64e7a8 :  |-- interrupt-controller
7e6518e8 :  |-- aliases
7e6519f0 :  |-- options
7e651ab0 :  |-- openprom
7e651bb8 :  |-- packages
7e651c80 :  |   |-- deblocker
7e652720 :  |   |-- disk-label
7e656dc0 :  |   |-- fat-files
7e659538 :  |   |-- rom-files
7e659f58 :  |   |-- ext2-files
7e65c9d0 :  |   |-- obp-tftp
7e65cda0 :  |   +-- iso-9660
7e6617e8 :  +-- mmu ok


FreeBSD Installer


% uname -a
FreeBSD BEFreeBSD 14.3-RELEASE FreeBSD 14.3-RELEASE releng/14.3-n271432-8c9ce319fef7 GENERIC powerpc


Post-boot blues

Mountroot fails

mountroot: waiting for device /dev/vtbd1s2a...
Mounting from ufs:/dev/vtbd1s2a failed with error 19.

Loader variables:
  vfs.root.mountfrom=ufs:/dev/vtbd1s2a
  vfs.root.mountfrom.options=rw

Solution: There is a mismatch in the device tree configuration and the boot configuration. The following will get FreeBSD up and running

mountroot> ?

List of GEOM managed disk devices:
  cd0 ufsid/6860fe636e2c3598 vtbd0s2b vtbd0s2a vtbd0s2 vtbd0s1 vtbd0

mountroot> ufs:/dev/vtbd0s2

and then edit /etc/fstab:

# cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/vtbd0s2a   /               ufs     rw      1       1
/dev/vtbd0s2b   none            swap    sw      0       0

Some other errors

QEMU's output is somewhere else.

At the end of the output from QEMU, further output is suppressed and the last line is

char device redirected to /dev/pts/N (label monitor-base)

Solution: Output has now been redirected to /dev/pts/N where N is a number correlated to the pseudo-tty in /dev/pts/. You can attach to it with

# screen /dev/pts/N 115200 8 N 1

or add -nographic to the command line.


Duplicate/conflicting serial devices

qemu-system-ppc64: Duplicate ID 'serial0' for chardev
qemu-system-ppc64: could not connect serial device to character backend 'vc:80Cx24C'

Solution: Most likely you are attempting to add a chardev with the id=serial0 parameter. vc is the default i/o and is named "serial0." Use -nodefaults and provide your own chardev (on the command line) or use the default serial0.


No host

 qemu-system-ppc64: unable to find CPU model 'host'

Solution: The command line is missing --enable-kvm.


No discs

Trying to load:  from: disk ... 
E3405: No such device
Trying to load:  from: /vdevice/v-scsi@71000003/disk@8200000000000000 ... No medium !

Solution: No virtio has been specified in the command line. Add one.


Can not use IDE on pSeries VMs

qemu-system-ppc64: -drive file=FreeBSD-14.3-RELEASE-powerpc-powerpc64-disc1.iso,if=ide,index=1,media=cdrom: machine type does not support if=ide,bus=0,unit=1
qemu-system-ppc64: -drive file=fbsd.raw,if=ide,index=0,format=raw: machine type does not support if=ide,bus=0,unit=0

Solution: Add a virtio.