Ok here is how I setup my chrooted RPI
Warning: it is a LONG post.
How to chroot RPI envoronment.
Keep in mind this took me so many hours to figure out it's not even funny. I'm not exactly a nix guru by any means of the word.
The 1st part sucks as it is how you get the img ready.
There are two ways to do it but I found it easier just to do it this way.
The hard way is to use gemu to expand the img file and then some fancy fdisk stuff in the image to expand. Pfft
My Way:
I do this part all in windows so if you're a linux user you will need to know how to do dd and other linuxy things.
Download the latest Raspbian 2013-02-09-wheezy-raspbian.img from
http://www.raspberrypi.org/downloads
http://downloads.raspberrypi.org/images/...spbian.zip
unzip it.
Write to your SD Card [8 gig is plenty but I did it on a 16 ] I use win32diskimager
Once completed insert SD into your RPI and boot it.
Run through initial setup screen paying attention to the "expand rootfs" as this one is really the only one of two parts that matter.
Run the last option which is like try to update.
Exit and reboot
log in
sudo apt-get install git-core
sudo wget
http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo rpi-update and let it do it's thing
you CAN do an apt-get update && apt-get dist-upgrade now but it takes forever, much faster to do it once it's chrooted
!!this part is VERY important with 2013-02-09
sudo nano /etc/ld.so.preload
comment out anything in there. If you do not then it will bork when you try to run nearly any command with the following error:
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction (core dumped)
ok all done with the prepping of the image
sudo shutdown -h now
pull the SD card and put it in your reader.
Again I use win32diskimager
read it to an image. I named it the same as the original
2013-02-09-wheezy-raspbian.img
when it's done writing the image [and it WILL take a while] you can pull the SD
on the nix box
sudo apt-get install qemu qemu-user qemu-user-static kpartx
I put all my Raspi images in /rpi-images and I mount it in /mnt/temp
so
sudo mkdir /rpi-images
sudo mkdir /mnt/temp
sudo chmod -R 777 /rpi-images
transfer your newly created image into /rpi-images
now create the following scripts
[mountrpi]
Code:
#! /bin/bash
kpartx -a -v /rpi-images/2013-02-09-wheezy-raspbian.img
mount /dev/mapper/loop0p2 /mnt/temp
cp /usr/bin/qemu-arm-static /mnt/temp/usr/bin
mount -o bind /dev /mnt/temp/dev
mount -o bind /dev/pts /mnt/temp/dev/pts
mount -o bind /proc /mnt/temp/proc
mount -o bind /sys /mnt/temp/sys
mount -o bind /run /mnt/temp/run
#sets up the interfaces
cp /etc/network/interfaces /mnt/temp/etc/network/interfaces
#makes networking actually work
cp /etc/resolv.conf /mnt/temp/etc/resolv.conf
#where the magic happens
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register
chroot /mnt/temp
[umountrpi]
Code:
#! /bin/bash
cd /devel
umount -l /mnt/temp/dev/pts
umount -l /mnt/temp/dev
umount -l /mnt/temp/proc
umount -l /mnt/temp/sys
umount -l /mnt/temp/run
umount -l /mnt/temp
kpartx -d -v /rpi-images/2013-02-09-wheezy-raspbian.img
make them executable
sudo chmod +x mountrpi umountrpi
ok you are now ready for the magic. But as a note I had issues trying this with sudo so just do it as root. ie
u [password] and be careful!
then just run ./mountrpi
if you followed my directions to a T you are now in your new chrooted raspbian environment
test it by
uname -a
Linux jothee 2.6.32 #42-Ubuntu SMP Fri Mar 8 23:20:06 UTC 2013 armv7l GNU/Linux #<--see the armv7l ? that's the gold!
you can now do everyhing just as if you are running on your RPI.
I tend to do a rpi-update just to make sure everything is good to go
and also do a apt-get update && apt-get dist-upgrade now
to unmount just type exit [enter] [or control D] and then sudo ./umountrpi
Word of warning, you are ROOT when doing this on the rpi chroot so you CAN royally screw up the image if you're not careful. as in do not try rm -rf / because it WILL
at this point you are ready to set up your xbmc build environment which is icky.
I will follow up with that in the next post!
Be careful on the mount script as the line that starts with "echo ':arm:M::\x7fELF" should NOT be line wrapped
Also note. I did this on Ubuntu 12.10 x86. It will work on x64 but takes a little more effort.