Raspberry Pi on QEMU - wyldckat/wyldckat.github.io GitHub Wiki
I've written down a few reference notes on the steps I took to sort out the fixes needed for the bug report #2051 at the OpenFOAM bug tracker.
The following links have the details I used on Ubuntu 16.04:
- Downloaded the image "Full desktop image based on Debian Jessie, Version: May 2016" from here: https://www.raspberrypi.org/downloads/raspbian/
- Instructions on how to use QEmu: https://wiki.debian.org/RaspberryPi/qemu-user-static
- I didn't notice an important detail that is given here: https://www.raspberrypi.org/forums/viewtopic.php?p=298537
- Reference notes on what to keep a look out for: http://sentryytech.blogspot.pt/2013/02/faster-compiling-on-emulated-raspberry.html
- Speed references, to ensure that I can get top performance: http://raspberrypi.stackexchange.com/questions/333/how-does-speed-of-qemu-emulation-compare-to-a-real-raspberry-pi-board
Base set-up:
mkdir -p /home/VMMachines/Raspberry/Raspbian_Jessie/mnt cd /home/VMMachines/Raspberry/Raspbian_Jessie/ unzip ~/Downloads/Linux\ ISOs/Raspbian/2016-05-27-raspbian-jessie.zip fdisk -lu 2016-05-27-raspbian-jessie.img
dd if=/dev/zero bs=10M count=1024 >> 2016-05-27-raspbian-jessie.img sudo losetup -f -P --show 2016-05-27-raspbian-jessie.img
sudo parted /dev/loop0 print rm 2 mkpart primary ext4 71,3 -1 #not 100% certain here of the order print
sudo e2fsck -f /dev/loop0p2 sudo resize2fs /dev/loop0p2 sudo losetup -d /dev/loop0
Mounting image and getting ready before jail-rooting it:
sudo losetup -f -P --show 2016-05-27-raspbian-jessie.img sudo mount /dev/loop0p2 -o rw $PWD/mnt
cd mnt sudo cp /usr/bin/qemu-arm-static usr/bin/
cp /etc/network/interfaces etc/network/interfaces cp /etc/resolv.conf etc/resolv.conf sed -i -e 's=^=#=' etc/ld.so.preload
Starting jail_root:
sudo mount --bind /dev dev/ sudo mount --bind /sys sys/ sudo mount --bind /proc proc/ sudo mount --bind /dev/pts dev/pts
sudo chroot . bin/bash
Wrapping up jail-root:
exit
sudo umount dev/pts sudo umount dev sudo umount sys sudo umount proc
cd .. sudo umount mnt sudo losetup -d /dev/loop0
Using this command (source):
time (echo '2^2^20' | bc > /dev/null)
It takes 3.5s in my AMD A10-7850k, while within the emulated chroot, it takes 20s. Which means that a build of OpenFOAM that takes 88 minutes on the real machine, using 4 pseudo-cores, will take roughly 8 hours to build within the emulated chroot.
In comparison with the stats given here, the jail-root emulation takes 0m6.187s, versus 0m5.310s given on that page... which means that the emulation on this machine is a bit slower than desirable... but at least I don't need to buy the hardware to do the tests.
Took the following time to build OpenFOAM:
real 1193m6.982s user 4035m14.252s sys 15m57.900s
Sooo... instead of 8 hours, it took 20 hours with the emulated system.