ImageModification
Contents |
This Howto is outlining the process to install a package inside Intrepid (8.10) Mobile and MID Images. Download the latest .img file from cdimage.ubuntu.com , then follow the steps below or use the script at the bottom of this page.
Before using either method, you will need to install the squashfs-tools package
The manual way
Preparation:
mkdir /tmp/image mkdir /tmp/squashfs mkdir /tmp/tmpfs mkdir /tmp/mergemount
Mount the filesystems:
sudo modprobe unionfs sudo mount -o loop <your downloaded .img file> /tmp/image sudo mount -o loop -t squashfs /tmp/image/casper/filesystem.squashfs /tmp/squashfs sudo mount -t tmpfs tmpfs /tmp/tmpfs sudo mount -t unionfs -o dirs=/tmp/tmpfs:/tmp/squashfs=ro none /tmp/mergemount
Make sure essential filesystems are mounted inside the image:
sudo chroot /tmp/mergemount mount -t proc proc /proc sudo chroot /tmp/mergemount mount -t sysfs sysfs /sys sudo chroot /tmp/mergemount mkdir -p /dev/pts sudo chroot /tmp/mergemount mount -t devpts devpts -o noexec,nosuid,gid=5,mode=620 /dev/pts
Make sure packagelists are up to date and install the software you like:
LANG=C sudo chroot /tmp/mergemount apt-get update LANG=C sudo chroot /tmp/mergemount apt-get install <your desired package>
Clean up:
sudo chroot /tmp/mergemount apt-get clean sudo chroot /tmp/mergemount umount /proc sudo chroot /tmp/mergemount umount /sys sudo chroot /tmp/mergemount umount /dev/pts sudo chroot /tmp/mergemount rm -rf /dev/pts
Build a new squashfs with your changes:
sudo mksquashfs /tmp/mergemount /tmp/filesystem.squashfs
Clean up the temporary mountpoints:
sudo umount /tmp/mergemount sudo umount /tmp/tmpfs sudo umount /tmp/squashfs
Copy the new squashfs in place:
sudo cp /tmp/filesystem.squashfs /tmp/image/casper/
Clean up the rest:
sudo umount /tmp/image sudo rm -rf /tmp/image /tmp/tmpfs /tmp/squashfs /tmp/mergemount /tmp/filesystem.squashfs
Have fun with your changed imagefile ....
The same as shellscript
The script below uses the same setup as above and spawns a rootshell inside the squashfs, you can then run "apt-get update" and install your package or make other changes, if you exit the shell with Ctrl-D or the 'exit' command it will offer you to re-roll the squashfs for you.
#!/bin/sh
if [ -z $1 ];then
echo 'i need a path to an imagefile as first argument'
exit 0
fi
mkdir /tmp/image
mkdir /tmp/squashfs
mkdir /tmp/tmpfs
mkdir /tmp/mergemount
sudo modprobe unionfs
sudo mount -o loop $1 /tmp/image
sudo mount -o loop -t squashfs /tmp/image/casper/filesystem.squashfs /tmp/squashfs
sudo mount -t tmpfs tmpfs /tmp/tmpfs
sudo mount -t unionfs -o dirs=/tmp/tmpfs:/tmp/squashfs=ro none /tmp/mergemount
sudo chroot /tmp/mergemount mount -t proc proc /proc
sudo chroot /tmp/mergemount mount -t sysfs sysfs /sys
sudo chroot /tmp/mergemount mkdir -p /dev/pts
sudo chroot /tmp/mergemount mount -t devpts devpts -o noexec,nosuid,gid=5,mode=620 /dev/pts
sudo cp /etc/resolv.conf /tmp/mergemount/etc/
LANG=C sudo chroot /tmp/mergemount su
sudo chroot /tmp/mergemount rm /etc/resolv.conf
sudo chroot /tmp/mergemount umount /proc
sudo chroot /tmp/mergemount umount /sys
sudo chroot /tmp/mergemount umount /dev/pts
sudo chroot /tmp/mergemount rm -rf /dev/pts
echo -n 'do you want to build a squashfs with the changes ? (y/n) '
read yesno
if [ -z $yesno ];then
yesno='n'
fi
if [ $yesno = 'y' ];then
sudo mksquashfs /tmp/mergemount /tmp/filesystem.squashfs
fi
sudo umount /tmp/mergemount
sudo umount /tmp/tmpfs
sudo umount /tmp/squashfs
if [ $yesno = 'y' ];then
sudo cp /tmp/filesystem.squashfs /tmp/image/casper/
fi
sudo umount /tmp/image
sudo rm -rf /tmp/image /tmp/tmpfs /tmp/squashfs /tmp/mergemount /tmp/filesystem.squashfsMobileTeam/Mobile/HowTo/ImageModification (last edited 2008-09-04 13:40:45 by p5098ed03)