Pidora 2014 qemu

From CDOT Wiki
Revision as of 11:51, 28 May 2014 by Oatley (talk | contribs)
Jump to: navigation, search
Pidora-horizontal.png
Important.png
Security Warning!
This page is a work in progress. The page is not formatted correctly and the information may or may not lead to breaking your computer. Don't use this page till it is complete, or you really know what you are doing.


Pidora QEMU

This page is here to assist people who would like to run Pidora 2014 in a QEMU environment. This tutorial has been adapted from this website: http://xecdesign.com/compiling-qemu/

Pidora QEMU Compose

Using pidora in a qemu environment has some important restrictions to note. The model that is used to emulate pidora has a hard coded restriction on how much ram it can use(256mb). However the programs that we use


Pidora QEMU Setup

# Choose the directory to put both the image and the compiled qemu software
pidora_dir=/data/pidora-qemu

# Make the directory and enter it
mkdir ${pidora_dir}
cd ${pidora_dir}

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

# Download the pidora image
wget http://pidora.ca/pidora/releases/20/images/Pidora-2014-R1.zip

# Unzip the image file
unzip Pidora-2014-R1.zip

# Make a new directory for qemu and enter it
mkdir ${pidora_dir}/raspidev/
cd ${pidora_dir/raspidev/

There are multiple ways to get qemu-system-arm. You can compile a new version with a few select flags, or you can try installing the version that your distribution has already compiled.

git clone git://git.qemu-project.org/qemu.git cd ${pidora_dir}/raspidev/qemu/ </pre>




This tutorial is basically just using the tutorial found on this site(http://xecdesign.com/compiling-qemu/), with some added steps specifically for pidora.

This setup is done completely on fedora 20. If you are using ubuntu/debian it might be easier to use the site above.

This setup avoids the installation of the newly compiled qemu, so that your system stays clean, and keeps your system and any already install qemu instances managed by yum.

Some of the commands may need root.

  1. use whatever directory you'd like

pidora_dir=/data/pidora-qemu

mkdir ${pidora_dir} cd ${pidora_dir} wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu wget http://pidora.ca/pidora/releases/20/images/Pidora-2014-R1.zip

unzip Pidora-2014-R1.zip mkdir ${pidora_dir}/raspidev/ cd ${pidora_dir/raspidev/ git clone git://git.qemu-project.org/qemu.git cd ${pidora_dir}/raspidev/qemu/

  1. Before you can continue, you will probably need to install a bunch of build deps
  2. I will show all the packages I needed to install for the configure/make to finish successfully
  3. Note: I do NOT make install
  1. I think you might only need to install the devel packages in the below command.

yum install gcc-++ zlib zlib-devel SDL SDL-devel pixman pixman-devel libfdt-devel libtool glib2 glib2-devel

  1. Hopefully now, you have all the dependencies on the system

./configure --target-list="arm-softmmu arm-linux-user" --enable-sdl --prefix=/usr

make

  1. The newly compiled qemu program should now have compiled successfully
  1. The binary can be found in: ${pidora_dir}/raspidev/qemu/arm-softmmu/qemu-system-arm
  1. As per XEC's instructions I did the following(though I used vi)


${pidora_dir}/raspidev/qemu/arm-softmmu/qemu-system-armqemu-system-arm -kernel ${pidora_dir}/kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda ${pidora_dir}/Pidora-2014-R1.img

  1. Wait for the new qemu instance to boot for the first time, then do the below instructions

nano /etc/ld.so.preload

  1. Put a # in front of the first line so that it looks like this:
  2. /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so

Press ctrl-x then y then enter to save and exit. (Optional) Use steps 2 to 4 above to create a file /etc/udev/rules.d/90-qemu.rules with the following content: KERNEL=="sda", SYMLINK+="mmcblk0" KERNEL=="sda?", SYMLINK+="mmcblk0p%n" KERNEL=="sda2", SYMLINK+="root"

  1. Now just close the window or shut it down


  1. At this point it's probably a good idea to increase the size of the Pidora-2014-R1.img file. If you don't it might cause some errors when you start first boot and it tries to resize your partitions and filesystem.
  1. WARNING: This next command can be very dangerous, use at your own risk! Change the count=# number to the number of GB you would like to add to the size of the image. The command below should increase the size by 4 GB.
  2. You may be fine with 1GB more or maybe, if you are going to try composing your own images, much much more!

dd if=/dev/zero bs=1G count=4 >> ${pidora_dir}/Pidora-2014-R1.img

  1. you should now be able to run this command to start the pidora instance and get to first boot. This is the same command above, except without the init=/bin/bash part.

${pidora_dir}/raspidev/qemu/arm-softmmu/qemu-system-armqemu-system-arm -kernel ${pidora_dir}/kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda ${pidora_dir}/Pidora-2014-R1.img


  1. PROBLEMS: When I wrote this tutorial I accidentally ran first boot before I resized my image file, which cause a bunch of problems. I shut down the qemu instance after running first boot, and rebooted it in multi-user mode. This is done by adding a 3 to the arguments like in the below command.

${pidora_dir}/raspidev/qemu/arm-softmmu/qemu-system-armqemu-system-arm -kernel ${pidora_dir}/kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw 3" -hda ${pidora_dir}/Pidora-2014-R1.img

  1. WARNING: The following is done on the qemu machine. This only needs to be done if you need to manually resize the partitions on the image because you forgot to increase the img file size before you started first boot.
  1. Assuming that you ran the dd command above to increase the images size, you now need to manually modify the partitions size on the pidora image.
  1. On the pidora qemu instance that is booted in multi user mode

fdisk /dev/sda >d >2 >n >(press enter for default)

>(press enter for default) >(press enter for default)

>w

  1. Shutdown the pidora qemu machine
  1. Start the pidora qemu instance again and run the following command when it boots

resize2fs /dev/sda2

  1. Pidora should now have the proper root filesystem size.