Your SlideShare is downloading. ×
Qemu - Raspberry | while42 Singapore #2
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Qemu - Raspberry | while42 Singapore #2


Published on

Presentation by Mathieu Feulvarch for the while42 Singapore #3

Presentation by Mathieu Feulvarch for the while42 Singapore #3

Published in: Technology

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Qemu in Chroot Make it easy
  • 2. QEMU is a hosted virtual machine monitor: It emulates central processing units through dynamic binary translation and provides a set of device models, enabling it to run a variety of unmodified guest operating systems.
  • 3. Qemu
  • 4. A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children.
  • 5. Chroot
  • 6. The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC),[3] which includes an ARM1176JZF-S 700 MHz processor
  • 7. Raspberry Pi
  • 8. What about speed? pi@raspberrypi:~$ cat /proc/cpuinfo | grep MIPS BogoMIPS : 697.95 pi@raspberrypi:~$ cat /proc/cpuinfo | grep MIPS BogoMIPS Not good! : 565.24
  • 9. Qemu compilation ARM1176JZF-S # # # # git clone ./configure --target-list="arm-softmmu arm-linux-user" --enable-sdl --static make sudo make install
  • 10. Preparation ● ● Download the latest version of Raspbian (link) Download the linux kernel for Qemu (link) # qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=0 ro single" -hda XXXXX-raspbian.img # mount / -o remount,rw ● ● Edit fstab and change mmcblk0p1 and mmcblk0p2 to sda1 and sda2 respectively Create /etc/udev/rules.d/90-qemu.rules KERNEL=="sda", SYMLINK+="mmcblk0" KERNEL=="sda?", SYMLINK+="mmcblk0p%n", ● Comment everything in /etc/
  • 11. Enlarge it! # cp XXXXX-raspbian.img raspbian.img # qemu-img resize raspbian.img +6G # qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1" -hda XXXXX-raspbian.img -hdb raspbian.img # sudo cfdisk /dev/sdb ●Delete the second partition and create a new partition with all space # sudo resize2fs /dev/sdb2 # sudo fsck -f /dev/sdb2 # sudo halt # qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1" -hda raspbian.img
  • 12. Chroot it # sudo kpartx -a -v 2012-12-16-wheezy-raspbian.img add map loop0p1 (252:8): 0 114688 linear /dev/loop0 8192 add map loop0p2 (252:9): 0 5763072 linear /dev/loop0 122880 # sudo mount /dev/mapper/loop0p2 /mnt/temp# sudo mount -o bind /dev /mnt/temp/dev # sudo mount -o bind /proc /mnt/temp/proc # sudo mount -o bind /sys /mnt/temp/sys Don’t forget to copy the qemu-arm binary to the image # sudo cp /usr/bin/qemu-arm /mnt/temp/usr/bin # cat /usr/share/binfmts/qemu-arm package qemu-user-static interpreter /usr/bin/qemu-arm-static credentials yes offset 0 magic x7fELFx01x01x01x00x00x00x00x00x00x00x00x00x02x00x28x00 mask xffxffxffxffxffxffxffx00xffxffxffxffxffxffxffxffxfexffxffxff Run sudo update-binfmts --import qemu-arm two times (yes, two times)
  • 13. And we are good to go Now, you should be able to chroot # sudo chroot /mnt/temp Let’s check if it’s working # uname -a Linux localhost 2.6.32 #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 armv7l GNU/Linux