Skip to content


Enlarge and run Raspbian image with QEMU under Ubuntu

To run Raspbian with QEMU might help to compile projects like mongopi or node.js with a bit more powerful environment than on raspberry pi itself. For sure, a cross compilation would be the best option, but is not as fun as virtual machines…

This short blog entry shows how to enlarge and run an virtual raspbian image with arm emulator qemu under debian/ubuntu and unifies three different blog entries to get this done.

Get Raspbian to run with QEMU under Ubuntu

Source

Install required packages

$ sudo apt-get install qemu qemu-kvm-extras

Download linux kernel for qemu kernel-qemu and latest Raspbian images from Raspbian e.g 2013-07-26-wheezy-raspbian.img.

Fix latest filesystem image

Source

Change the qemu -append parameter to: “root=/dev/sda2 panic=0 ro single” and boot the image and run:

# qemu-system-arm -net nic -net user,id=mynet0 -kernel kernel-qemu -cpu arm1136-r2 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=0 ro single" -hda 2013-07-26-wheezy-raspbian.img

This should leave you with a nice prompt. Then:

# mount / -o remount,rw

Next, edit fstab and change mmcblk0p1 and mmcblk0p2 to sda1 and sda2 respectively

Then create the file /etc/udev/rules.d/90-qemu.rules with the following contents:

KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n",

This should ensure that /dev/mmcblk0p1/2 exist and will make other stuff work.

Also edit /etc/ld.so.preload (if it exists) and remove or comment everything in it.

Create new and enlarged Raspbian image

Source

$ cp 2013-07-26-wheezy-raspbian.img rasbian.img
$ qemu-img resize raspbian.img +6G

and start original raspbian with enlarged image as second harddrive

$ qemu-system-arm -net nic -net user,id=mynet0 -kernel kernel-qemu -cpu arm1136-r2 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1" -hda 2013-07-26-wheezy-raspbian.img -hdb raspbian.img

Login with user pi and password raspbian

$ sudo cfdisk /dev/sdb

and delete 2nd partition, create a new partition with all space. Afterwards resize and check the old partition (the data will not be lost)

$ sudo resize2fs /dev/sdb2
$ sudo fsck -f /dev/sdb2
$ sudo halt

Start enlarged Raspbian image

$ qemu-system-arm -net nic -net user,id=mynet0 -kernel kernel-qemu -cpu arm1136-r2 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1" -hda raspbian.img

Resources

Posted in Nicht kategorisiert.

Tagged with , , , , , .