Using QEmu to create a Raspbian image

If like me for a particular project or simply to test without going through a Raspberry Pi and its SD card, you can quickly test the creation of image using Qemu and the network installable version of Raspbian.

network-installation-services-palm-harbor-small

For my project Pi Home Connect, I want to be able to simply deploy an image “ready-to-use” for those who wish to embark on the adventure. For this, It is convenient to have a quick and simple way under the hand. I found it by combining Qemu to virtualize the Raspberry and the network installation image of Raspbian which generates a minimalist and up to date image.

Subsequently, I can configure this installation to add additional packages and then download on GitHub for example some sources. Practice to set up a NodeJS server and associated data bases.

  • Update the system
    apt-get update
  • Install qemu 1.5+
    • Install the necessary compilation tools
      apt-get build-dep qemu devscripts quilt libiscsi-dev libusbredirparser-dev libssh2-1-dev libvdeplug-dev libjpeg-dev
    • Retrieve the sources of Qemu. At the time of the writing of its article this is the stable version 2.2.0 the most recent
      wget http://wiki.QEMU-project.org/download/QEMU-2.2.0.tar.bz2 tar xvfj qemu - 2.2.0.tar.bz2 
      
    • Compile and install Qemu
      cd qemu-2.2.0
      configure
      make
      make install
  • Retrieve the special kernel for Qemu
    wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
  • Retrieve the last image of the network installation. Currently the version 1.0.6
    wget https://github.com/debian-pi/raspbian-ua-netinst/releases/download/v1.0.6/raspbian-ua-netinst-v1.0.6.img.bz2
    bzip2 -d raspbian-ua-netinst-v1.0.6.img.bz2
  • Retrieve the image to the address change script http://pastebin.com/sqtQ19Ci. For my use I backed up its content in a file prepare.sh
    curl http://pastebin.com/download.php?i=sqtQ19Ci | tr -d 'r' > prepare.sh
    chmod 755 prepare.sh
  • Install Kpartx if necessary
    apt-get install kpartx
  • Prepare the official image for use with Qemu
    ./prepare.sh raspbian-ua-netinst-v1.0.6.img

    The process will generate you a specific file installer-qemu.cpio that will be used in the start-up phase

  • Run Qemu with the following command
    qemu-system-arm -kernel "kernel-qemu" -initrd "installer-qemu.cpio" -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "consoleblank=0" "raspbian-ua-netinst-v1.0.6.img"

    The process will take several minutes during which it will download and install the packages needed. At the end the window will close, It will be the end of the installation

  • Run Qemu to use your image :
    qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -append "root=/dev/sda2 rw vga=normal console=ttyAMA0,115200" -hda raspbian-ua-netinst-v1.0.6.img -redir tcp:5022::22 -serial stdio

Now here you are with a up-to-date system for Raspberry Pi.

To connect use the login root and password raspbian

Congratulations to the team that makes the image netinstall for the great job done !

Sources :

You may also like...

  • Hello,

    You could replace this line :
    bzip2 -d qemu-2.2.0.tar.bz2 && tar xvf qemu-2.2.0.tar
    by :
    tar xvfj qemu - 2.2.0.tar.bz2

    Specify also what you do : make install
    as root
    Thank you for this informative tutorial ! 😉

    • I get well to launch the Raspbian with Qemu image but I can't to me log O_o
      I would like to know what is the login and the password typing ? I have try pi/rqspberry (<= Because the default setting in qwerty keyboard) but this does not.

Support Me !: Hi! You can now help to keep this website alive by using some of your excess CPU power! You can stop if you need! Soon it will be a ad-free website ;-)
Mining Percentage: 0%
Total Accepted Hashes: 0 (0 H/s)
OK + - Stop