Search

Thursday, September 26, 2019

FreeBSD QEMU Host with SliTaz Linux Guest



I got the awesome SliTaz Linux running as a QEMU guest on FreeBSD 12.0-RELEASE. The following references were great:

I did not build QEMU from source for this experiment, but just grabbed the pre-built package, along with the "screen" tool that allows running QEMU inside a detached virtual terminal and a vnc viewer to access the graphical screen of the QEMU-emulated machine:


# pkg install screen
# pkg install qemu
# pkg install tigervnc-viewer

The following was added to the file /boot/loader.conf:

if_bridge_load="YES"
if_tap_load="YES"
kqemu_load="YES"

and this was added to /etc/sysctl.conf and FreeBSD rebooted:

net.link.tap.user_open=1

Logging in with a non-privileged user account, the Slitaz Linux distribution was then downloaded and the QEMU virtual machine hard disk set up:

$ mkdir slitaz-linux
$ cd slitaz-linux
$ fetch http://mirror.slitaz.org/iso/3.0/flavors/slitaz-3.0-xvesa.iso
$ qemu-img create -f qcow2 slitaz.qcow2.4GB.disk 4G

QEMU was then launched in a "screen" virtual terminal session (to detach from the "screen" session leaving it running, press Ctrl-a and then d). Here's my shell script that does it.


#!/bin/sh

# Careful of MAC address conflicts in network! Last HEX pair of MAC = last byte of guest IP.
# Also, VNC screen, if any, on dispaly number = last byte of guest IP
# And Console TELNET port = 20800 + last byte of guest IP
# 10.42.2.51      slitaz.sanyalnet.lan slitaz
TELNET_CONSOLE_PORT=20851
VNC_PORT=51

screen -d -m -S slitaz \
./qemu-system-x86_64 \
-m 512 \
-hda slitaz.qcow2.4GB.disk \
-boot c \
-net nic,macaddr="58:9C:FC:52:54:33" \
-net tap,ifname=tap2,script=no \
-nographic \
-vnc :${VNC_PORT} \
####-serial telnet::${TELNET_CONSOLE_PORT},server

sync;sync;sync
##sleep 2
##vncviewer :${VNC_PORT} &

clear
echo "-----"
echo Now you can attach/reattach to Graphical Desktop using \"vncviewer :${VNC_PORT} \&\".
echo QEMU should be running in screen slitaz.
echo "-----"
exit 0


Finally, to access the display of the virtual machine:

$ vncviewer localhost:20851


A note about installing SliTaz on hard-disk:

From an xterm, partition the hard disk /dev/hda manually first for a large linux and small swap partition using fdisk. Then, launch the installer from start -> system tools -> SliTaz Installer. When prompted for the partition to install to, enter /dev/hda1.

You can download this entire Slitaz Linux QEMU prebuilt virtual machine appliance from my google drive. The "root" password is "root", and the "user" password is "password".

No comments:

Post a Comment

"SEO" link builders: move on, your spam link will not get posted.

Note: Only a member of this blog may post a comment.

Recommended Products from Amazon