It seems silly to use our limited SD write cycles to upgrade the software shipped on the images. Can we upgrade the software and install new software before flashing an image to the SD card?
YesThe answer's always yes, right, just takes a while to work out how! The Hard WayI will be running this on a VPS, provided by Brightbox.com. I used a Nano Server (2 CPUs, 512MB RAM, 20GB disk space) and a Ubuntu Precise 12.04 LTS server image. It should work on EC2's or Linode's equivalents, and of course, on your home Linux machine. Furthermore, it should work on your home Linux machine. I have now tested it on my (x86) Arch installation, but know it doesn't work on Ubuntu 10.04 LTS because some of the packages are too old. Preparing your system - Debian/UbuntuEnsure your own system is up to date.
Install some new software
Preparing your system - ArchI can't find a statically linked
Download and unzip the imageGo to raspberrypi.org and download the image you want. Unzip it and save the
Find the correct partitionThe
We need to know the offset of the Linux partition, in this case it is Mount the image as a loopback deviceNext, we need to mount the image as a file system. This can be done using a loopback device. We use the offset from the previous section to tell
Preparing the filesystem.We're nearly ready to Debian/Ubuntu
Arch Linux
All host systemsWe also need to provide access to certain other parts of the system.
chrootWe are done!
You are now in your Raspberry Pi, but the services aren't running etc. Be careful, you are root! Update/Install software - Debian ImageTo update the software, we use
You can also install software using Update/Install software - Arch ImageTo update the software, we use
You can also install software using
ExitingYou can exit the You should remove Final WordsThis is a little long and tedious, but do it once and you'll learn loads about how this all works! The Easy Way -
|
You can also use sudo kpartx -av rpi_pisces_mate_r1.img, which will show the partitions. Use the biggest one and mount it, e.g. sudo mount /dev/mapper/loop0p3 /mnt/tmp. – elmicha Jul 14 '12 at 22:28 |
|
@AlexChamberlain: did you actually get this working on the Brightbox server? I've successfully tested this on my home PC but when I tried it on Brightbox I couldn't chroot and I wanted if that was because of trying to effectively get virtualisation on top of virtualisation. Of course I might have done something wrong as well, but I thought it was worth querying before completely giving up! Thanks for an excellent tutorial. – DrAl Feb 13 at 10:11 |
|
I followed the instructions looking for a method to just build stuff for the PI via my main PC, it turns out it was very easy, once you're chrooted you can treat the image as if it were a live system and use all of the native apps. on teh pi, so no need to install a cross compiler :) I do have one question though, during the setup of the chroot, we have to mount some partitions for the chroot to function properly:
How do we unmount these properly? leaving them mounted, which stops you from unmounting the .img file, any help here would be appreciated. I tried the -f option, not sure if there is something else underlying that is mounted. answering my own question, https://bugzilla.redhat.com/show_bug.cgi?id=194342 the 2nd method at the end of the post worked for me with a sudo modification.
Obviously change $MOUNTPOINT to the path of your chroot mount point (2nd partition containing the rootfs on the image file, which is /mnt in the above tutorial). Using this method you completely unmount the img file from the loopback devices and any other devices that were mounted via the chroot.
|
|||||
|