############################################################################# # Document: INSTALL_QEMU.TXT # Purpose : How to install Slackware ARM inside QEMU on # Slackware/x86. # Author : Stuart Winter # For questions and support, please use the Slackware ARM forum # http://www.linuxquestions.org/questions/slackware-arm-108/ # Date : 03-Mar-2015 # Version : 2.01 ############################################################################# # v2.01 - 03-Mar-2015 # * Use initrd rather than uinitrd, since the standard format gzip compressed # installer and OS images are now provided in the main tree. # v2.00 - 01-Dec-2013 # * Updated for the ARM Versatile Express ############################################################################# Slackware ARM inside QEMU ========================= This document describes the process of installing Slackware ARM inside of QEMU. What is QEMU? ------------- QEMU is a full system emulator that can emulate a range of real hardware architectures. In this case we will using 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 Intel-based Slackware PC/server (in most cases this will be a desktop machine, but it is possible to run QEMU on a headless server and use VNC for graphics). 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 but would like to try out Slackware ARM. Whilst QEMU is an excellent emulator, it is very slow compared to real ARM hardware; I used QEMU for approximately a year and most of Slackware ARM version 12.2 was built on QEMU (using distcc to several x86 machines to speedup compilation), so it's possible to use Slackware ARM in qemu -- however I am concious that it will not present the best user experience due to the slow speed. Ideally Slackware ARM should be run on real ARM hardware. One of the cheapest options at the time of writing is the Marvell SheevaPlug which is supported by Slackware ARM. However, that said I am very happy to be able to present Slackware ARM for use by all who care to install QEMU. === Installation & running instructions ===================== 1.0 Assumptions ----------- Several assumptions -- in the form of IP addresses and directory paths -- are made to help writing the examples for this documentation. These values are easy to modify to suit your environment. - You have a secure (you trust the people using it) LAN, on 192.168.1.0/24 - You're running Slackware/x86: You have root on this machine and can compile software. Your host Slackware/x86 machine has the IP 192.168.1.1; You have the 'bridge-utils' Slackware package installed on this machine; You can NFS export the Slackware ARM tree from this machine; You want to use /export to house the Slackware ARM tree on this machine. You only need one Slackware/x86 host machine to perform an installtion of Slackware ARM inside QEMU. A single machine can be the NFS server (used for the one time installation) and host Slackware ARM inside QEMU. 2.0 Configuring your environment on the Slackware/x86 machine --------------------------------------------------------- 2.1 Create a location for your Slackware ARM host ---------------------------------------------- We need a location for the hard disk image, Kernel, initrd and QEMU helper scripts. For this example, we will put them into /export/armhost. These do not need to be available to the OS or installer, so they do not need to be NFS exported. # mkdir -p /export/armhost 2.2 NFS export ---------- On your Slackware x86 host, add a line similar to the example below in to your /etc/exports file: /export/slackwarearm 192.168.1.0/255.255.255.0(insecure,ro,nohide,root_squash,sync,no_subtree_check) Note: The 'insecure' value is set because we install Slackware ARM inside QEMU, running as a normal user, through NAT - so the source port number is higher than 1024. If you don't have an NFS server already running: # chmod +x /etc/rc.d/{rc.rpc,rc.nfsd} # /etc/rc.d/rc.nfsd If you have an NFS server already running: # exportfs -va 2.3 Download & build a Slackware QEMU and supporting packages --------------------------------------------------------- QEMU must be built for your environment. You need to download 'device-tree-compiler' and the 'QEMU' build scripts from SlackBuilds.org: http://slackbuilds.org/repository/14.1/development/device-tree-compiler/ http://slackbuilds.org/repository/14.1/system/qemu/ Follow the build instructions for each package, then proceed in this order: Build device-tree-compiler first, and install it. Build QEMU and install it. 2.3.1 Download QEMU helper scripts ----------------------------- You also need some 'helper' scripts specifically for Slackware ARM: On your host machine: # cd /tmp ; mkdir qemu ; cd qemu # rsync \ -Pavv \ ftp.arm.slackware.com::slackwarearm/platform/arm/refs/qemu/slackwarearm-14.2 . We'll move these into the Slackware ARM host's directory: # cd slackwarearm-14.2 # cp -fav helper-scripts/* /export/armhost/ 2.3.2 setuid root for qemu -------------------- /usr/bin/qemu-system-arm needs root permissions. You can either accomplish this using sudo, editing /etc/sudoers; this would be the most secure option if you have multiple users on your host. If like me you only have yourself using your system, it's easiest to: # chmod +s /usr/bin/qemu-system-arm ifconfig & brctl also need to run as root if you are using bridged mode. If you intend on only using NAT, you can skip this. Again, you can use sudoers for security if you prefer. # chmod +s /sbin/{ifconfig,brctl} 2.4 Setting up your Slackware ARM host ----------------------------------- The ARM machine needs an 'SD card' - QEMU provides this ability by emulating an MMC controller, and providing a single file on the x86 host. # cd /export/armhost # vi makeimg The script creates a 15G SD card image. A full installation of Slackware occupies around 7GB of this, so there's plenty of room to play with afterwards. Please adjust the size if you need to. Create the image: # ./makeimg # note that it wipes the original disk image!! 2.5 QEMU network settings --------------------- The easiest way to get going with QEMU is to use NAT mode. For the expert user, I have provided two helper/example scripts to get your system working with bridged mode (which is by far the best method if you intend on doing any serious stuff): rc.local-additions - Additions for /etc/rc.d/rc.local These lines must be modified for your system, and you may prefer to add the configuration into /etc/rc.d/rc.inet1. qemu-network-tun.sh - Script to bring up the Tunnel interface when using QEMU in bridge mode. This script is run by qemu and referenced by the helper script 'disk_launch' - you do not need to run it directly - it only needs to be in the same location as the 'disk_launch' script. For more reading about QEMU in bridged mode, please see these sites: http://compsoc.dur.ac.uk/~djw/qemu.html http://blog.alantan.com/2007/01/qemu-tap-bridge-network-configuration.html http://fedoraproject.org/wiki/Architectures/ARM/HowToQemu Please email me if you need more help with the QEMU bridge setup! 4.0 Downloading Slackware ARM ------------------------- Assumptions: [ ] Your current user has read/write/execute access to /export. Make the directory that we'll download Slackware ARM into: # mkdir -p /export/slackwarearm # cd /export/slackwarearm Download: The easiest way to download Slackware ARM is to use rsync. # rsync \ --exclude '*/source/*' \ --delete -Pavv \ ftp.arm.slackware.com::slackwarearm/slackwarearm-14.2 . Whilst it is possible to use the FTP installation inside the installer, it's recommended to download the full tree first, as in this example, and install off an NFS host on your LAN. The full download will be approximately 3GB. You may choose a mirror site - some are listed on the Slackware ARM web page: http://arm.slackware.com 4.1 Copy the Kernel & Initial RAM disk into the ARM host directory -------------------------------------------------------------- The Kernel & initrd need to be in the directory where the ARM emulated hard disk and QEMU scripts are located. Copy them from the Slackware ARM tree: # cp -fa slackwarearm-14.2/kernels/armv7/{zImage*,initrd*,dtb} /export/armhost/ Copy the installer: # cp -fa slackwarearm-14.2/isolinux/initrd-armv7.img /export/armhost/ 5.0 Installing Slackware ARM ------------------------ I will assume that you are now in X Windows, running as your normal user account, and you have followed the steps above. Please note that even on a 3.4GHz Pentium D, installing Slackware ARM inside QEMU takes about 6 hours, so give it some time. 5.1 Booting the installer --------------------- # cd /export/armhost # ./installer_launch You may see some warnings from QEMU about being unable to open audio and video devices - you can ignore these. You should see the Linux kernel boot messages, and finally the question regarding selection of a key map. The 'installer_launch' script provided will make the Slackware installer obtain an IP via DHCP. The QEMU emulator will take care of providing the IP via its built-in DHCP server. The side-effect of this however, is that you will need to refer to your x86 NFS server via its IP address rather than any canonical host name. ( e.g. 192.168.1.1 rather than server.myhouse.com ) 5.2 Installation ------------ The installer for Slackware ARM is mostly identical to that of x86, so if you're familiar with installations upon x86, there's no real learning curve for the ARM platform. 5.2.1 Partitioning your SD card -------------------------- QEMU provides an emulated SD card, and the SD card image you created in section 2.4 will show as /dev/mmcblk0p2 Please choose a partitioning scheme. I recommend /dev/mmcblk0p1 - 200MB swap /dev/mmcblk0p2 - the rest of the disc, "Linux" - type 83. Use can use the 'fdisk' tool (or the tool of your preference) to create the partitions. 5.2.2 Begin the setup --------------- To begin, type 'setup' into the shell and proceed as normal, but take note of the following suggestions. 5.2.2.1 Caveats about the installer --------------------------- 1. After installation has finished, running 'MKFONTSCALE' takes a long time. It may appear as if the installation has hung, as the system seems unresponsive and you are unable to change virtual console. If you run 'top' on your host OS, you will probably find QEMU busy using 100% of the CPU. Solution: be patient ;-) 5.2.3 Source media selection ---------------------- Choose '3 - Install from NFS (Network Filesystem)' Enter the IP address: 192.168.1.1 Enter the directory: /export/slackwarearm/slackwarearm-14.2/slackware 5.2.4 Package selection ----------------- Slackware ARM has all of the Slackware packages apart from those which are x86 only. It's up to you which packages you install, but we recommend a full installation. 5.2.5 Network setup ------------- If you intend on using NAT for networking, QEMU has a built-in DHCP server, so the best and easiest way is to configure the OS to use DHCP. If you will be using bridging and have a DHCP server, you may also wish to choose DHCP. 5.2.6 Window manager for X -------------------- You can choose any of them, but it's recommended to choose something light weight such as WindowMaker or Fluxbox. Note that currently, Linux 3.12.x does not provide support for the graphics card used in QEMU; so access to QEMU will either be through the serial port or logging into the VM remotely. 6.0 Booting the Slackware ARM OS ---------------------------- Congratulations! The first thing to do is amend the 'disk_launch' script: # cd /export/armhost # vi disk_launch Changes to make & installation tips: 1. Root filesystem type: Change the root filesystem type to match the one you chose in the Slackware installer. The supported types are listed and you must comment/uncomment as appropriate. 2. Root filesystem location: If you followed the example in this document, you will have used /dev/mmcblk0p2 which is the default setting in this script; Otherwise set the partition name of the location of your root ('/') filesystem. 3. If you are going to be using bridging for your networking, you must make the appropriate changes. The default is to use NAT which is good enough to begin with. Once you've made your changes, you're ready to go! # ./disk_launch After a few seconds you should see the Kernel messages, the modules being loaded from the initrd and finally the output from the familiar Slackware boot scripts. Note that upon first boot, 'fc-cache' will run and begin building information about any fonts that have been installed. This is a normal process when booting Slackware, but on ARM it's very noticeable due to the performance impact it has upon the virtual machine. It will have completed within approximately 10 mins. 7.0 Help support the Slackware ARM project -------------------------------------- Maintainance of the Slackware ARM port takes not only a lot of time, but also has financial costs such as the on-going use of electricity, Internet hosting and purchasing and maintainance of ARM hardware. Once you find yourself enjoying using the ARM port of Slackware, please take a few moments to show your appreciation by sponsoring either through * A one-off donation: https://paypal.me/armedslack * or (preferably, for this author) a monthly appreciation payment: https://www.patreon.com/armedslack More information on this subject may be found here: http://arm.slackware.com/sponsor 7.1 Helping support the upstream Slackware project ---------------------------------------------- Please consider donating to the parent Slackware project also, developed and maintained by Patrick Volkerding. Without this project, the ARM port of Slackware would, in short order, cease to exist. https://www.patreon.com/slackwarelinux/overview 8.0 Suggestions/alterations ----------------------- If you have any suggestions, recommendations or corrections(!) for this document, please do email me. Thanks! Stuart Winter. -- Stuart Winter mozes@slackware.com