Running Linux for ARM processors under qemu

Source: Internet
Author: User
ArticleDirectory
    • Preparing the host server
Qemu is well-known as a free replacement for VMware, allowing users to run a PC within a PC. what isn't so well known about qemu is that, in addition to emulating x86 ubuntures, it can emulate amd64, iSCSI, MIPS, PPC and arm CPUs.

In the case of the ARM architecture, qemu provides a convenient, if slow, environment in which development can be done for embedded systems.

This article describes the process involved in building a Debian/ARM server running under qemu. It assumes that Debian is also being used as the host server.

Since qemu's arm emulator has no ability to emulate either ide or SCSI disks, it will be necessary to install the server on an NFS exported partition.

Preparing the host server

Firstly, install the required packages on your host server:


Host # apt-Get qemu VDE nfs-kernel-server debootstrap

DebootstrapAllows the creation of a base Debian or Ubuntu system, and is a very simple method for building chroots and virtual machines quickly.

Vde is a virtual network emulator, much like user mode Linux's uml_net, allowing a qemu-emulated machine to connect to the host server's network through a tap interface.

Make sure that your host kernel has support for the "Universal tun/TAP device driver"; the Kernel configuration option for this is named "tun ". if you're running a modularised kernel, there's a good chance that it will
Be Named 'tun. o '.

Once you have a kernel with Tun support, set up a tap interface for the emulated machine to communicate through. In/Etc/Network/interfacesOn your host machine, add the following stanza:

Auto tap0
Iface tap0 Inet static
Address 10.1.6.1
Netmask 255.255.255.0
Network 10.1.6.0
Broadcast 10.1.6.255
Vde-switch VDE-Net

Ensure that/Dev/NET/TUNIs owned by groupVde-NetAnd that you are also a member of that group; add this to your host server's/Etc/groupFile and log out and back in again, if necessary.

Then, bring up the interface:

Host # IFUP tap0

You'll need a partition with enough spare space on it to hold a basic Debian installation; make sure you have enough room on it to grow in the future. you can probably get out with 300 mb at the minimum. I placed my tree under/Nfs/share/ARM/.

Now, run debootstrap to download and install the base Debian/ARM distribution, and copy a few of the files from your host system into it:

Host # mkdir/nfs/share/ARM
Host # debootstrap -- foreign -- arch arm etch/nfs/share/ARM
Host # cd/nfs/share/ARM
Host # cp/etc/passwd
Host # cp/etc/shadow
Host # cp/etc/group
Host # echo "proc/proc defaults 0 0"> etc/fstab
Host # echo "10.1.6.1:/nfs/share/ARM/nfs defaults 0 1"> etc/fstab

debootstrap's -- foreign Option tells it to only perform the first stage of the bootstrap process, downloading and unpacking the packages. since we're downloading Debian for a different architecture from that on which we're re running on the host server, our host system wocould not be able to use this new system in a chroot to run the pre-and post-installation scripts.

qemu is well-known as a free replacement for VMware, allowing users to run a PC within a PC. what isn't so well known about qemu is that, in addition to emulating x86 ubuntures, it can emulate amd64, iSCSI, MIPS, PPC and arm CPUs. in the case of the ARM architecture, qemu provides a convenient, if slow, environment in which development can be done for embedded systems. this article describes the process involved in building a Debian/ARM server running under qemu. it assumes that Debian is also being used as the host server. since qemu's arm emulator has no ability to emulate either ide or SCSI disks, it will be necessary to install the server on an NFS exported partition.

We're re going to use the same server that is being used as the host server for running qemu as the NFS server for the guest server's root filesystem; an emulated system is slow enough as it is, we don't need to make things worse by having a real Ethernet network in between the guest OS and Its filesystem (as opposed to a virtual ethernet, in this case ).

Share the new directory out via NFS, by adding the following entry/Etc/exports:

/Nfs/share/ARM 10.1.6.0/24 (RW, no_root_squash, sync)

Then export the filesystem:

Host # exportfs-

Download a kernel for ARM-Linux; there's one provided in the arm-test files on the qemu website (and a copy here.

Place the arm-Linux zimage in/Usr/local/etc/images/zimage. Arm, And then create the following script/Usr/local/bin/start-qemu-arm:

#! /Bin/sh

Console = "ttyama0" # serial console
Nfsserver = "10.1.6.1" # address of NFS server
Nfsdir = "/nfs/share/arm" # exported share where Debian/ARM is installed
Address = "10.1.6.50" # address for guest Server
Gateway = "10.1.6.1" # Default Gateway
Netmask = "255.255.255.0" # Subnet Mask
Hostname = "arm. Home" # hostname for guest Server
Device = "eth0" # interface that guest server will use
Mem = 256 # memory for guest server in MB
Tap = "/var/run/Vde/tap0.ctl" # VDE tap socket

Kernel = "/usr/local/etc/images/zimage. Arm" # ARM Kernel
Nfsopts = "rsize = 8192, wsize = 8192, hard, Intr, TCP, nolock" # NFS options

Consoleopt = "console = $ console"
Nfsrootopt = "nfsroot = $ nfsserver: $ nfsdir, $ nfsopts"
Ipopt = "IP = $ address: $ Gateway: $ netmask: $ hostname: $ device"

Init = ""

If ["x $1" = "xsingle"]
Then
Init = "init =/bin/bash"
Fi

Vdeq qemu-system-arm-Sock $ tap-M $ mem \
-Kernel $ kernel-nographic \
-APPEND "$ consoleopt root =/dev/nfs $ nfsrootopt $ ipopt $ init"

Adjust the parameters at the top of the script to suit your requirements.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.