[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
howtos:hardware:arm:qemu_support_in_slackware_arm [2020/03/06 13:13 (UTC)] – [Note: Needs update (March 2020)] mozeshowtos:hardware:arm:qemu_support_in_slackware_arm [2020/09/30 19:30 (UTC)] – [Sources] mralk3
Line 1: Line 1:
-===== Note: Needs update (March 2020) ===== 
- 
-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.  If you get the helper scripts working, please post a diff [[https://www.linuxquestions.org/questions/slackware-arm-108/qemu-system-arm-panic-on-x86_64-a-4175670124/|on here]] or email mozes at slackware. 
- 
-Please base fixes on the [[ftp://ftp.arm.slackware.com/slackwarearm/boardsupport/qemu/slackwarearm-current/helper-scripts/|the latest scripts]] 
 ====== Qemu Support in Slackware ARM ====== ====== Qemu Support in Slackware ARM ======
  
Line 12: Line 6:
   * QEMU provides a platform to allow an operating system to believe that it is running on real hardware.   * 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.   * 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).
 +
 +<del>The issues are to do with the network support.</del>  //They should be fixed//.
 +
 +If you have suggestions for the helper scripts, please post a diff [[https://www.linuxquestions.org/questions/slackware-arm-108/qemu-system-arm-panic-on-x86_64-a-4175670124/|on here]] or email mozes at slackware.  Please base fixes on the [[ftp://ftp.arm.slackware.com/slackwarearm/boardsupport/qemu/slackwarearm-current/helper-scripts/|the latest scripts]].
  
 ===== Who is Slackware ARM in QEMU aimed at? ===== ===== Who is Slackware ARM in QEMU aimed at? =====
Line 33: Line 35:
   * You have root access on the host machine and can compile software   * 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   * The Slackware host and QEMU emulator are on a secure Local Area Network
-  * You can export a Network File System file share on the host machine that shares the Slackware ARM tree with the QEMU guest 
-  * The root directory of the exported NFS share on the host is located at /export 
- 
-<note tip>These guidelines can be met with one Slackware x86/x86_64 host machine.  This single host machine can serve the NFS content, as well as host the Slackware ARM installation inside QEMU. </note> 
- 
 ===== Slackware x86 Host Prerequisites ===== ===== Slackware x86 Host Prerequisites =====
  
   - Download the **Slackwarearm** distribution package tree with rsync   - Download the **Slackwarearm** distribution package tree with rsync
   - Populate a location with the Slackware ARM QEMU files   - Populate a location with the Slackware ARM QEMU files
-  - Configure the Network File System (NFS) on the Slackware x86 Host 
   - Install QEMU and the device-tree-compiler software on the Slackware x86 host   - Install QEMU and the device-tree-compiler software on the Slackware x86 host
   - Configure QEMU Permissions on the Slackware x86 Host   - Configure QEMU Permissions on the Slackware x86 Host
   - Create the QEMU disk image using the helper scripts   - Create the QEMU disk image using the helper scripts
 +  - Configure a web server to mirror Slackware ARM for the qemu guest
 ==== Download Slackware ARM ==== ==== 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 your user has read, write, and execute permissions within the /export directory.+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:
 <code> <code>
-mkdir -p /export/slackwarearm +mkdir -p /slackwarearm/$SLACKREL 
-cd /export/slackwarearm+cd /slackwarearm/$SLACKREL
 rsync --exclude '*/source/*' --delete -Pavv ftp.arm.slackware.com::slackwarearm/$SLACKREL . rsync --exclude '*/source/*' --delete -Pavv ftp.arm.slackware.com::slackwarearm/$SLACKREL .
 </code> </code>
Line 62: Line 59:
 ==== Populate Slackware ARM Files and Directories ==== ==== 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 /export/armhost.+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: Copy the kernel and RAM disk:
 <code> <code>
-mkdir -p /export/armhost +cd /slackwarearm 
-cp -fa /export/slackwarearm/$SLACKREL/kernels/armv7/{zImage*,initrd*,dtb} /export/armhost/ +cp -fa /slackwarearm/$SLACKREL/kernels/armv7/{zImage*,initrd*,dtb} /slackwarearm 
-cp -fa /export/slackwarearm/$SLACKREL/isolinux/initrd-armv7.img /export/armhost/+cp -fa /slackwarearm/$SLACKREL/isolinux/initrd-armv7.img /slackwarearm
 </code> </code>
  
Line 76: Line 73:
 # rsync -Prlvv --delete ftp.arm.slackware.com::slackwarearm/boardsupport/qemu/$SLACKREL . # rsync -Prlvv --delete ftp.arm.slackware.com::slackwarearm/boardsupport/qemu/$SLACKREL .
 # cd $SLACKREL # cd $SLACKREL
-# cp -fav helper-scripts/* /export/armhost/+# cp -fav helper-scripts/* /slackwarearm
 </code>       </code>      
  
 You can find the [[http://slackware.uk/slackwarearm/boardsupport/qemu/slackwarearm-current/helper-scripts/ | helper scripts here]] if you do not wish to use rsync to download them. You can find the [[http://slackware.uk/slackwarearm/boardsupport/qemu/slackwarearm-current/helper-scripts/ | helper scripts here]] if you do not wish to use rsync to download them.
  
-<note tip>The $SLACKREL variable refers to the Slackware ARM tree you downloaded.  If you chose Slackwarearm-14.2, the path will be /export/slackwarearm/slackwarearm-14.2.  The rsync URL for the QEMU helper scripts will be:+<note tip>The $SLACKREL variable refers to the Slackware ARM tree you downloaded.  The rsync URL for the QEMU helper scripts will be:
  
-<code>ftp.arm.slackware.com::slackwarearm/boardsupport/qemu/slackwarearm-14.2</code></note>+<code>ftp.arm.slackware.com::slackwarearm/boardsupport/qemu/slackwarearm-current</code></note>
  
-==== Configure Network File System services ==== 
- 
-The Slackware x86 host needs to be configured appropriately in order to run the Slackwarearm installation process within QEMU.  The easiest and most efficient way to do so is by setting up a Network File System (NFS) share on the host machine.  This NFS share will be used by the Slackwarearm client (running inside QEMU) to access the Slackware distribution package tree on the host.  NFS services are not the only way to serve the Slackware distribution package tree to the QEMU client.  Other methods are quite a bit slower when used with QEMU emulated networking.  As a result, the NFS service is used for this tutorial. 
- 
-You need to know the QEMU network settings in order to access the NFS share.  It is recommended that you use NAT mode networking with QEMU.  NAT mode allows direct access to the Slackware x86 host NFS share through a QEMU hosted virtual network.  More information about the virtual network and assigned addressing is discussed later on in this guide. 
- 
-With a text editor, as root, add the following to the Slackware host's /etc/exports: 
- 
-<code> 
-# QEMU guest virtual IP address 
-/export/slackwarearm 10.0.2.15(insecure,ro,nohide,root_squash,sync,no_subtree_check) 
-</code> 
- 
-NAT mode does not allow direct access to the physical Local Area Network.  You will need to set up a bridged network interface if you decide you need direct network access.  NAT mode will be sufficient for most users. 
- 
-Use something similar to the following if you plan to use a bridged network interface: 
-<code> 
-/export/slackwarearm xxx.xxx.xxx.x/255.255.255.0(insecure,ro,nohide,root_squash,sync,no_subtree_check) 
-</code> 
- 
-Replace xxx.xxx.x.x/255.255.255.0 and match it with your network configuration.  (Example: 192.168.1.0/255.255.255.0) 
- 
-Activate the NFS share by executing the following as root: 
-<code> 
-# chmod +x /etc/rc.d/{rc.rpc,rc.nfsd} 
-# /etc/rc.d/rc.nfsd start 
-# exportfs -va 
-</code> 
 ==== Install QEMU and device-tree-compiler ==== ==== Install QEMU and device-tree-compiler ====
  
Line 139: Line 108:
 ==== Create QEMU Disk Image ==== ==== Create QEMU Disk Image ====
  
-Prior to booting the Slackware ARM installer in QEMU, you must create a disk image that acts as an emulated [[https://en.wikipedia.org/wiki/Secure_Digital | SD Card]].  This disk image is used to emulate the MMC controller in Slackware ARM.  Earlier you copied the Slackware ARM helper scripts to /export/armhost/.  Within this directory there is a script, **makeimg**.  This script creates a 15GB disk image automatically in /export/armhost/ when it is executed.  Initially all you need to do is run this script.+Prior to booting the Slackware ARM installer in QEMU, you must create a disk image that acts as an emulated [[https://en.wikipedia.org/wiki/Secure_Digital | 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**: Switch to the directory where you copied the helper scripts and execute **makeimg**:
  
 <code> <code>
-cd /export/armhost+cd /slackwarearm
 ./makeimg ./makeimg
-</code> 
- 
-For reference, this is the **makeimg** script: 
-<code> 
-# Create the QEMU disk image - the emulated SD card. 
- 
-IMG=sdcard.img 
-SIZE=15G 
- 
-rm -f $IMG 
-qemu-img \ 
-   create \ 
-   $IMG $SIZE 
 </code> </code>
  
Line 165: Line 121:
 ===== QEMU Network Settings ===== ===== QEMU Network Settings =====
  
-This section covers the process of setting up QEMU guest networking.  Two different processes will be described.  //Network Address Translation mode (NAT)// is the first and recommended way to get a functional network in QEMU guests.  The second is //bridged mode// 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.**+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 [[https://www.qemu.org/documentation/ | QEMU documentation]] if you need further explanation. 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 [[https://www.qemu.org/documentation/ | QEMU documentation]] if you need further explanation.
  
-<note warning>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 NFS share on the host.  This happens because QEMU emulation is very slow.  The NFS daemon on your host machine occasionally shuts down the network socket before large packages (rust, kernel-firmware, etc) finish being copied to the 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:+<note warning>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:
  
  
Line 180: Line 136:
 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: 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:
 <code> <code>
-# cd /export/armhost+# cd /slackwarearm
 # qemu-system-arm -nographic \ # qemu-system-arm -nographic \
    -m 1024 \    -m 1024 \
    -M vexpress-a9 \    -M vexpress-a9 \
 +   -smp 4 \
    -k en-us \    -k en-us \
    -net nic \    -net nic \
-   -net user+   -net user,restrict=n \
    ..snip..    ..snip..
 </code> </code>
Line 193: Line 150:
  
 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. 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.
-==== QEMU Bridged Mode Networking ====+==== Configure a Web Server to Mirror Slackware ARM ====
  
-The best way to set up a bridged network interface for QEMU is with the provided helper script, rc.local-additions.  If you choose to take this route, you need to disable the NetworkManager service.  NetworkManager comes with Slackware, but it is not developed by Slackware.  As result, the process of configuring a bridge with NetworkManager is not supported in this guide.+There is a very simple way to share the ARM directory on the host with the ARM guests.  Use python and launch basic web server like so:
  
-You can find the helper script with comments online here: [[http://slackware.uk/slackwarearm/boardsupport/qemu/slackwarearm-current/helper-scripts/rc.local-additions | rc.local-additions]]+<code> cd /slackwarearm && python -m SimpleHTTPServer</code>
  
-The following commands must be executed as root to disable NetworkManager: +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/.
-<code> +
-# /etc/rc.d/rc.networkmanager stop +
-# chmod -x /etc/rc.d/rc.networkmanager +
-</code> +
- +
-The following network settings are assumed for the **Slackware x86 host machine**.  Adjust these values throughout the remainder of this guide if you use different network settings. +
-<code> +
-Default Gateway: 192.168.1.1 +
-Static IP address: 192.168.1.2 +
-Network Mask: 255.255.255.0 / 192.168.1.0/24 +
-Name server: 192.168.1.1 +
-</code> +
- +
-You need to edit the //qemu-network-tun.sh// helper script for QEMU.  It is required to bring up the QEMU guest network interface.  It should exist in /export/armhost.  Change the IP address listed in $BRIDGEIP to match your network settings. +
- +
-File/export/armhost/qemu-network-tun.sh +
-<code> +
-#!/bin/sh +
- +
-# This is the IP of 'tap0' on the Slackware/x86 host: +
-BRIDGEIP=192.168.1.4 +
- +
-modprobe tun +
-/sbin/ifconfig $1 $BRIDGEIP netmask 255.255.255.0 +
-/sbin/brctl addif br0 $1 +
-</code> +
- +
-Here is the relevant portion of the rc.local-addtions script that requires modification.  This script is meant to replace on the host machine /etc/rc.d/rc.local.  Changes depend on your network settings: +
-<code> +
-.. snip .. +
- +
-# Turn on the bridge.  Note that this is a different IP from +
-# the one specified in your qemu-network-bridge.sh script +
-# in your 'armhost' directory on your Slackware x86 box. +
-# You need a bridge IP, a tunnel (tap0) IP, and then another +
-# IP which is assigned to the Slackware ARM host (by Linux inside QEMU) +
-# to its own eth0. +
-# I tried bringing this up after eth0 but the bridge didn't work. +
-# I don't know why that is! +
-ifconfig br0 192.168.1.3 up +
- +
-# Put back the original IP for eth0: +
-ifconfig eth0 192.168.1.2 up +
- +
-#  +
-route del default +
-route add default gw 192.168.1.1 +
-</code> +
- +
-These network settings assume static IP addressing.  The br0 interface is the bridged network interface.  The eth0 interface is the host machine network interface that allows the host machine to retain network connectivity.  The default gateway, 192.168.1.1, typically points to the network gateway on the physical network. +
- +
-Copy rc.local-addtions to /etc/rc.d/rc.local once you finish editing it.  Then mark it executable. +
-<code> +
-# cp /path/to/rc.local-additions /etc/rc.d/rc.local +
-# chmod +x /etc/rc.d/rc.local +
-</code> +
- +
-At this point it is recommended reboot your Slackware x86 host to assure the settings in rc.local are in use and that NetworkManager is completely disabled.+
  
-<note important>You may need to edit the /etc/resolv.conf file on the host.  Add in the IP addresses of your preferred primary and secondary name server(ssince you are not receiving these IP addresses by other means.  The name server is 192.168.1.1 (or the default gateway) in this tutorial</note>+For a production environment, the Apache Web server (httpd on Slackwaremay be more desirable.  Further directions to use Apache can be found [[howtos:network_services:setup_apache|here]].
  
-Modify the launcher helper scripts once you are certain your host has the appropriate network settings.  Pay close attention to the **$NETTYPE** variable.  Details about how to use this variable are documented in both the **installer_launch** and **disk_launch** helper scripts.  Edit the **$MACADDR** variable for each QEMU instance if you are running more than one Slackware ARM guest at once.+Alternatively, use a mirror on the internet if you have too much difficulty configuring your own mirror.
 ===== Install Slackware ARM ===== ===== Install Slackware ARM =====
  
Line 273: Line 172:
  
 <code> <code>
-cd /export/armhost+cd /slackwarearm
 ./installer_launch ./installer_launch
 </code> </code>
Line 293: Line 192:
 ==== Setup and Configuration ==== ==== Setup and Configuration ====
  
-Run the **setup** command at the shell prompt after you exit the partitioning tool.  Make the installer aware of your swap parition 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 4, **Install from NFS (Network Filesystem)**.  Enter the IP address of your Slackware x86 host.  Enter the path to the NFS mounted share.+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:
  
-The full path of the NFS share is required: +<code>What is the URL of your FTP/HTTP server?</code> 
-<code> +In this case we will use the host IP address, enter the URL address: http://192.168.1.2 
-Enter the IP address: 192.168.1.2 # Host machine IP address + 
-Enter the directory/export/slackwarearm/$SLACKREL/slackware +<code>What is the Slackware source directory?</code> 
-</code>+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. 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.
Line 328: Line 227:
  
 <code> <code>
-# cd /export/armhost+# cd /slackwarearm
 # vi disk_launch # vi disk_launch
 </code> </code>
Line 355: Line 254:
 ====== Sources ====== ====== Sources ======
 <!-- If you are copying information from another source, then specify that source --> <!-- If you are copying information from another source, then specify that source -->
-  * Originally written by [[wiki:user:mozes|Stuart Winter]]+  * Originally written by [[http://www.slackware.com/~mozes/|Stuart Winter]]
   * Original source: [[http://ftp.arm.slackware.com/slackwarearm/boardsupport/qemu/]]   * Original source: [[http://ftp.arm.slackware.com/slackwarearm/boardsupport/qemu/]]
 <!-- Authors are allowed to give credit to themselves! --> <!-- Authors are allowed to give credit to themselves! -->
 howtos:hardware:arm:qemu_support_in_slackware_arm ()