Skip to content

Instantly share code, notes, and snippets.

@lbdremy
Last active October 13, 2019 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lbdremy/5561852 to your computer and use it in GitHub Desktop.
Save lbdremy/5561852 to your computer and use it in GitHub Desktop.
HOW-TO: Virtualize Raspian with Qemu.

#HOW-TO: Virtualize Raspian with Qemu

0.Workspace

mkdir -p ~/workspace/raspdev
cd ~/workspace/raspdev

1.Install Qemu

Ubuntu:

sudo apt-get install libsdl-dev
sudo add-apt-repository ppa:linaro-maintainers/tools
sudo apt-get update
sudo apt-get install qemu-system

or

From source:

sudo apt-get install git zlib1g-dev libsdl1.2-dev
sudo apt-get install libpixman-1-dev
git clone git://git.qemu-project.org/qemu.git
cd qemu
./configure --target-list="arm-softmmu arm-linux-user" --enable-sdl
make
sudo make install

2.Download kernel image

wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu

3.Download Raspian

wget http://downloads.raspberrypi.org/images/raspbian/2013-02-09-wheezy-raspbian/2013-02-09-wheezy-raspbian.zip
# should be b4375dc9d140e6e48e0406f96dead3601fac6c81
sha1sum 2013-02-09-wheezy-raspbian.zip
unzip 2013-02-09-wheezy-raspbian.zip

4.Patch Raspian:

This is a patch to prevent an error on startup. The error message is "init [0] respawning too fast disabled 5 minutes".

file 2013-02-09-wheezy-raspbian.img
#From the output of the file command, take the partition 2 'startsector' value an multiply by 512, and use this figure as the #offset value in the mount command below.
sudo mount 2013-02-09-wheezy-raspbian.img -o offset=62914560 /mnt
sudo nano /mnt/etc/ld.so.preload
# Comment the line in this file with #
sudo umount 2013-02-09-wheezy-raspbian.img /mnt

5.Run Raspian with Qemu

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2" -hda  2013-02-09-wheezy-raspbian.img

6.Repair the disk of the Raspian (you should be login as root)

fsck /dev/sda2
reboot

7.Start again the machine, you're set

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2" -hda  2013-02-09-wheezy-raspbian.img

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment