Welcome to the Slackware Documentation Project

Qemu Support in Slackware ARM

This document describes the process of installing Slackware ARM inside of QEMU.

  • QEMU is a full system emulator that can emulate a range of real hardware architectures. In this case we will use QEMU to emulate the ARM Ltd. “Versatile Express” development board.
  • QEMU provides a platform to allow an operating system to believe that it is running on real hardware.
  • QEMU runs on your Slackware PC or server. In most cases this will be a desktop machine. However, it is possible to run QEMU on a headless server and use VNC for graphics.

Last modified (September 2020)

This tutorial was last verified on September, 22 2020, on Qemu 4.1 installed on Slackware64-current, dated Sun Sep 20 08:08:08 UTC 2020. Verification on Slackware 14.2 is still necessary. The helper scripts were built for qemu-2.5, and do not work with the latest version of qemu (4.2 at the time of writing).

The issues are to do with the network support. They should be fixed.

If you have suggestions for the helper scripts, please post a diff on here or email mozes at slackware. Please base fixes on the the latest scripts.

Who is Slackware ARM in QEMU aimed at?

The aim of installing Slackware ARM inside QEMU is to allow people who do not have ARM hardware to try out Slackware ARM.

While QEMU is an excellent emulator, it is very slow compared to real ARM hardware. QEMU was used for approximately a year to develop most of Slackware ARM version 12.2. Due to the slow speed of QEMU, distcc can be used on several x86 machines to speedup compilations. It's possible to effectively use Slackware ARM in QEMU, however be aware that it will not present the best user experience due to its lack of speed. Ideally Slackware ARM should be run on real ARM hardware.

This document is a work in progress and it targets the development release of Slackware ARM, Slackwarearm-current.

Documentation for Slackware ARM 14.0, 14.1, and 14.2, can be found here:

Installation Environment Assumptions

Several assumptions are made to aid in writing this document.

  • The host machine is running a full installation of Slackware x86 or x86_64
  • You have root access on the host machine and can compile software
  • The Slackware host and QEMU emulator are on a secure Local Area Network

Slackware x86 Host Prerequisites

  1. Download the Slackwarearm distribution package tree with rsync
  2. Populate a location with the Slackware ARM QEMU files
  3. Install QEMU and the device-tree-compiler software on the Slackware x86 host
  4. Configure QEMU Permissions on the Slackware x86 Host
  5. Create the QEMU disk image using the helper scripts
  6. Configure a web server to mirror Slackware ARM for the qemu guest

Download Slackware ARM

Download Slackware ARM to your Slackware x86 Host. In this tutorial rsync is used to mirror Slackware ARM. Before running rsync, make sure your user has read, write, and execute permissions within the directory you pick. In this example /slackwarearm/$SLACKREL is used, but you can use a directory of your choice.

Log in as root and run the following:

mkdir -p /slackwarearm/$SLACKREL
cd /slackwarearm/$SLACKREL
rsync --exclude '*/source/*' --delete -Pavv ftp.arm.slackware.com::slackwarearm/$SLACKREL .

If you wish to use a web browser, wget, or lftp to download Slackware ARM, the mirror is here.

The $SLACKREL variable refers to the Slackware ARM tree you downloaded. If you chose Slackwarearm-14.2, the rsync URL will be ftp.arm.slackware.com::slackwarearm/slackwarearm-14.2

Populate Slackware ARM Files and Directories

In order to boot the Slackware ARM installer you need to create a directory that stores the Kernel and Initial RAM disk. You also need a few helper scripts to run QEMU. In this totorial, all of these files will be stored in /slackwarearm.

Copy the kernel and RAM disk:

cd /slackwarearm
cp -fa /slackwarearm/$SLACKREL/kernels/armv7/{zImage*,initrd*,dtb} /slackwarearm
cp -fa /slackwarearm/$SLACKREL/isolinux/initrd-armv7.img /slackwarearm

Download and copy the QEMU helper scripts:

# cd /tmp ; mkdir qemu ; cd qemu
# rsync -Prlvv --delete ftp.arm.slackware.com::slackwarearm/boardsupport/qemu/$SLACKREL .
# cd $SLACKREL
# cp -fav helper-scripts/* /slackwarearm

You can find the helper scripts here if you do not wish to use rsync to download them.

The $SLACKREL variable refers to the Slackware ARM tree you downloaded. The rsync URL for the QEMU helper scripts will be:
ftp.arm.slackware.com::slackwarearm/boardsupport/qemu/slackwarearm-current

Install QEMU and device-tree-compiler

Installing SlackBuilds is not apart of the scope of this article. If you need assistance with installing QEMU or device-tree-compiler, please refer to the SlackBuilds.org HOWTO page. With that said, there are a few recommendations:

  • If you are running Slackware-current you can install QEMU and skip installing the device-tree-compiler package. Slackware-current already includes the device-tree-compiler package in a full installation.
  • Please be certain that you did a full Slackware installation on your x86 host prior to installing these SlackBuilds.
  • Slackware 14.0, 14.1, and 14.2 users need to install the device-tree-compiler package from SlackBuilds.org prior to installing QEMU.
  • You can download and install QEMU from SlackBuilds.org.
  • You will not have the ability on 14.0, 14.1, and 14.2 systems to emulate the ARM architecture in QEMU if you do not first install the device-tree-compiler package.

QEMU Permissions

There are a few permissions that need to be set once you have successfully installed QEMU on your system. The QEMU client will be launched by running the /usr/bin/qemu-system-arm binary. This binary needs root permissions in order to be executed. You can run this binary with sudo by editing /etc/sudoers. Using sudo is the most secure option if you have multiple users on your system. If you are the only user on your system then setting the setuid permission as root is sufficient. Adjusting these permissions will allow a normal user to configure and boot the QEMU guest without logging in as root.

Setting the setuid root permission requires that you log in as root. As root execute the following commands:

# chmod +s /usr/bin/qemu-system-arm

If you plan to configure QEMU to use a network bridge, you also need to set the setuid root permission for /sbin/ifconfig and /sbin/brctl.

# chmod +s /sbin/{ifconfig,brctl}

Create QEMU Disk Image

Prior to booting the Slackware ARM installer in QEMU, you must create a disk image that acts as an emulated SD Card. This disk image is used to emulate the MMC controller in Slackware ARM. Earlier you copied the Slackware ARM helper scripts to /slackwarearm. Within this directory there is a script, makeimg. This script creates a 15GB disk image automatically in /slackwarearm when it is executed. Initially all you need to do is run this script.

Switch to the directory where you copied the helper scripts and execute makeimg:

cd /slackwarearm
./makeimg
Be aware that once you have installed Slackware ARM onto this disk image you must move it to a different directory for storage, or you risk it being destroyed when makeimg is executed at a later time.

QEMU Network Settings

This section covers the process of setting up QEMU guest networking. Network Address Translation mode (NAT) is the recommended way to get a functional network in QEMU guests. You can also use a bridged mode network. NAT mode does not allow direct access to the Slackware x86 host's physical network and bridged mode does. It is best to use bridged mode if you plan on doing any more advanced network operations that require full access to the host and the host's physical network. Most users will want to use NAT mode. As a result, Bridged mode will not be detailed here.

There are many different ways to configure QEMU guest networking. This document will only cover the QEMU functionality required to boot Slackware ARM. Refer to the QEMU man pages or the QEMU documentation if you need further explanation.

Later on when you boot the Slackware ARM installer in QEMU you may need to modify the txqueuelen for your network interfaces. This is because large Slackware packages time out while being downloaded from the host. This happens because QEMU emulation is very slow. The host machine occasionally shuts down the network socket before large packages (rust, kernel-firmware, etc) finish being copied to the emulated SD Card. Setting the txqueuelen to 10000 for all network interfaces should be sufficient to prevent this anomaly. The following command seems to resolve this issue:
ip link set eth0 txqueuelen 10000

Run this command for each network interface actively used by QEMU.

QEMU NAT Mode Networking

NAT mode does not require any additional configuration on the Slackware x86 host machine or in the QEMU guest machine. Here is a shortened example of a QEMU guest being launched with NAT mode networking:

# cd /slackwarearm
# qemu-system-arm -nographic \
   -m 1024 \
   -M vexpress-a9 \
   -smp 4 \
   -k en-us \
   -net nic \
   -net user,restrict=n \
   ..snip..

The -net nic and -net user options enable QEMU to start the Slackware ARM guest with NAT mode networking enabled. These settings are documented further in both the installer_launch and disk_launch helper scripts.

With NAT mode enabled, QEMU launches a virtual network of 10.0.2.0/24. The QEMU guest will be assigned the IP address 10.0.2.15. The guest can access the Slackware x86 host at 10.0.2.2 and the QEMU DNS server runs at 10.0.2.3. QEMU does not have direct access to the host's Local Area Network. This means that the QEMU guest isn't assigned a physical IP address by your router DHCP service. You will not be able to ping the QEMU guest from the host machine but the guest should be able to ping the host machine at 10.0.2.2. The QEMU guest should be able to access the internet and communicate with the host machine.

Configure a Web Server to Mirror Slackware ARM

There is a very simple way to share the ARM directory on the host with the ARM guests. Use python and launch a basic web server like so:

 cd /slackwarearm && python -m SimpleHTTPServer

The URL pointing to the mirror depends on the directory structure you used to store Slackwarearm on the qemu host. The directory /slackwarearm/$SLACKREL was used earlier in this guide. If you have mirrored slackwarearm-current, you would point your web browser at: http://192.168.1.2:8000/slackwarearm-current/.

For a production environment, the Apache Web server (httpd on Slackware) may be more desirable. Further directions to use Apache can be found here.

Alternatively, use a mirror on the internet if you have too much difficulty configuring your own mirror.

Install Slackware ARM

I will assume that you are now in X Windows, running as your normal user account, and that you followed the steps outlined earlier in this document. As stated earlier, QEMU runs extremely slow when emulating the ARM architecture. Depending on your hardware set up it may take several hours or more for the Slackware installer to copy all packages to the emulated disk. If the Slackware installer appears to be unresponsive, check your system process monitor (top or htop) to see if the QEMU process is still active. A good sign that QEMU is still active is that a single CPU core is operating at 100 percent.

The Slackware ARM installer is mostly identical to the Slackware x86 installer. There is no learning curve to install Slackware ARM if you have installed Slackware before.

Booting the Installer

In order to boot the installer you will need to configure and execute the installer_launch script within a terminal window.

cd /slackwarearm
./installer_launch

The installer_launch script can be found here.

You will see some warnings from QEMU about being unable to open audio and video devices. Those warnings can safely be ignored. Next you will see the Linux kernel boot messages and eventually the installer asking about what key map you want to use. Once you select your key map and log in to the system you will notice that the installer obtains an IP address via DHCP. The DHCP assigned IP address and resulting network configuration relies heavily on how you set up your networking on the host machine. If QEMU does not assign an IP address to the guest, then you need to go back and verify your network settings are configured appropriately.

Partitioning

The emulated SD Card created with the makeimg command is a blank image. You will have to partition this SD Card with the installer. It is best to keep the partition scheme simple in our case. It is recommended that you create a 200MB swap partition and to allocate the rest of the disk to the root partition. You can use the fdisk or cfdisk tools to create the partitions.

Example partitioning scheme:

/dev/mmcblk0p1 - 200MB swap
/dev/mmcblk0p2 - the rest of the disc, "Linux" - type 83.

Setup and Configuration

Run the setup command at the shell prompt after you exit the partitioning tool. Make the installer aware of your swap partition and root partition. It is recommended that you select the ext4 file system when you format the root partition. Next you will be prompted to select the source media. Choose option 5, Install from FTP/HTTP sever. Enter the IP address of your Slackware x86 host. The path to the Apache (httpd) directory is required:

What is the URL of your FTP/HTTP server?

In this case we will use the host IP address, enter the URL address: http://192.168.1.2

What is the Slackware source directory?

This is the directory that is accessible in your web browser. I used: /slackwarearm-current/slackware

Following that, you will be prompted for package selection. Slackware ARM has all of the standard Slackware packages apart from those which are x86 only. It is highly recommended that you do a full installation to satisfy all system dependencies. Please be patient, this is the most time consuming part of the installation process.

After installation has finished, running 'MKFONTDIR AND MKFONTSCALE UPDATE' takes a long time.

At the Network Setup screen it is best to select the DHCP option. The DHCP option best compliments QEMU's NAT mode and both bridged mode networking options. The only reason not to select DHCP is if your physical network uses static IP addressing.

Next you will reach the Window Manager selection for the X Windows server. It is recommended that you select a light weight window manager, such as Fluxbox or WindowMaker. KDE and Xfce are not very useful within the QEMU guest due to speed constraints.

Post-Installation

Once you complete the installation process you should drop to a shell prompt to configure the SSH Daemon. By default, OpenSSH does not allow root to log in with a password. This is a security concern. You may want to think about this carefully if your device is connected directly to an untrusted network. It is best to make a user account for remote connections to the SSH service and escalate privileges locally with “su” or “sudo”. If you wish to use root to log in remotely, follow these steps:

  1. Opt to drop in to a 'shell' when you exit from the installer
  2. At the shell, enter:
# sed -i 's?^#PermitRootLogin.*?PermitRootLogin yes?g' /mnt/etc/ssh/sshd_config
# poweroff                  

This completes the installation process of Slackware ARM within QEMU.

Boot Slackware ARM with QEMU

Congratulations for making it this far! The next step is booting into your fresh installation of Slackware ARM. Locate the disk_launch helper script in /export/armhost and modify it to fit your needs.

# cd /slackwarearm
# vi disk_launch

This script has a few variables you may want to change.

  • ROOTFSTYPE - root file system type, ext4 is the default
  • ROOTFSDEV - location of the root partition within the SD Card image
  • KEYBOARD - keyboard locale you wish to use, typically the same as what you chose during installation
  • NETTYPE - network configuration, NAT mode or bridged mode

The disk_launch script for Slackwarearm-current can be found online, here.

The first boot will take quite a while. This is due to the fact that Slackware will generate the font cache for the first time. Start up QEMU by executing the disk_launch script.

# ./disk_launch

Assuming all is well, you can begin using Slackware ARM just as you would any other Slackware installation.

Slackware ARM Graphical User Interface

Work in Progress

This section will discuss the positives and negatives around running X Windows, which window manager or desktop environment to use, and the ways you can start it up.

Sources


In Other Languages
Translations of this page?:
QR Code
QR Code howtos:hardware:arm:qemu_support_in_slackware_arm (generated for current page)