Skip to main content
9 of 18
added 107 characters in body

Tested on Ubuntu 16.04, QEMU 2.5.0, Raspbian Jessie 2016-05

  1. Download: https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/36ede073f4ccb64f60200ede36c231afe9502070/kernel-qemu-4.4.12-jessie

    We pick 4.4.12 since that is the kernel version in the Raspbian image.

    The process to generate that kernel blob is described at in the repository at: https://github.com/dhruvvyas90/qemu-rpi-kernel/tree/36ede073f4ccb64f60200ede36c231afe9502070/tools

    Why this extra kernel image is needed: Emulating with Qemu: why the extra kernel?

  2. Modify the Raspbian image as mentioned at: https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki/Emulating-Jessie-image-with-4.x.xx-kernel/0068f0c21d942b0f331e18014ff8e22c20cada5c Summary:

    1. Mount the second image of the partition. The easiest way is:

      sudo losetup -f --show -P 2016-05-27-raspbian-jessie.img 

      but it only works with latest losetup on Ubuntu 16.04. Other methods at: https://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device/496576#496576

      This prints a loop device, e.g.:

      /dev/loop0 

      and then mount the second partition from that device:

      sudo mkdir /mnt/rpi sudo mount /dev/loop0p2 /mnt/rpi 
    2. Edit the image:

      # Comment out the line present there with # sudo vim /mnt/rpi/etc/ld.so.preload # Comment out the lines of type: "/dev/mmcblk*" sudo vim /mnt/rpi/etc/fstab 
    3. Cleanup:

      sudo umount /mnt/rpi sudo losetup -d /dev/loop0 
  3. Enjoy:

    sudo apt-get install qemu-system-arm qemu-system-arm \ -kernel kernel-qemu-4.4.12-jessie \ -cpu arm1176 \ -m 256 \ -M versatilepb \ -no-reboot \ -serial stdio \ -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \ -hda 2016-05-27-raspbian-jessie.img 

Edit: -M raspi2 was added in QEMU 2.6, and is likely the best bet since, but I haven't tested it yet.