How to run virtual Raspbian on QEMU in Ubuntu:
1. Compile QEMU for ARM (1176).
$ sudo apt-get install git zlib1g-dev libsdl1.2-dev libpixman-1-dev2. Prepare QEMU environment and raspbian image.
$ cd tmp
$ git clone git://git.qemu-project.org/qemu.git && cd qemu
$ ./configure --target-list="arm-softmmu arm-linux-user" --enable-sdl --prefix=/usr/local
$ make
$ sudo make install
$ mkdir ~/qemu-vms/ && cd ~/qemu-vms/
Download Raspbian Wheezy from http://www.raspberrypi.org/downloads and Linux kernel for QEMU from http://xecdesign.com/downloads/linux-qemu/kernel-qemu.
$ file ~/qemu-vms/2014-01-07-wheezy-raspbian.imgTake the partition 2 'startsector' value an multiply by 512, and use this figure as the offset value in the mount command below:
~/qemu-vms/2014-01-07-wheezy-raspbian.img: x86 boot sector; partition 1: ID=0xc, starthead 130, startsector 8192, 114688 sectors; partition 2: ID=0x83, starthead 165, startsector 122880, 5662720 sectors, code offset 0xb8
$ sudo mount ~/qemu-vms/2014-01-07-wheezy-raspbian.img -o offset=$((122880*512)) /mntComment out the line in the /mnt/etc/ld.so.preload file and unmount:
$ sudo emacs -nw /mnt/etc/ld.so.preload3. Run simulation.
$ sudo umount /mnt
$ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda ~/qemu-vms/2014-01-07-wheezy-raspbian.img -redir tcp:5022::22QEMU gives you a root shell, run:
$ fsck /dev/sda2
$ shutdown -r now
$ ssh -p 5022 pi@localhostUPDATE: how expand free space:
1. Create /etc/udev/rules.d/90-qemu.rules with the following content and shutdown the system:
KERNEL=="sda", SYMLINK+="mmcblk0"2. Resize the image:
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"
$ qemu-img resize /qemu-vms/2014-01-07-wheezy-raspbian.img +4G3. Boot up your emulator again and do:
$ sudo ln -snf mmcblk0p2 /dev/root
$ sudo raspi-config
Choose the first option to resize your disk, and it will tell you to reboot.
UPDATE: update keyboard mappings if necessary:
$ sudo dpkg-reconfigure keyboard-configuration
No comments:
Post a Comment