3. 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.
11. 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/ld.so.preload
12. 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
13. 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)
14. 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