ImageModification

Differences between revisions 2 and 3
Revision 2 as of 2008-09-03 09:59:32
Size: 1595
Editor: p5098ed03
Comment: typo
Revision 3 as of 2008-09-03 11:21:01
Size: 3151
Editor: p5098ed03
Comment: add a script that makes the process easier
Deletions are marked like this. Additions are marked like this.
Line 63: Line 63:

== 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 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 aufs -o br:/tmp/tmpfs:/tmp/squashfs none /tmp/mergemount

sudo chroot /tmp/mergemount mount -t proc proc /proc
sudo chroot /tmp/mergemount mount -t sysfs sysfs /sys

sudo cp /etc/resolv.conf /tmp/mergemount/etc/

sudo chroot /tmp/mergemount

sudo chroot /tmp/mergemount rm /etc/resolv.conf
sudo chroot /tmp/mergemount umount /proc
sudo chroot /tmp/mergemount umount /sys

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
}}}

This Howto is outlining the process to install a package inside Intrepid (8.10) Mobile and MID Images. Download the latest .img file, then follow the steps below.

Preparation:

mkdir /tmp/image
mkdir /tmp/squashfs
mkdir /tmp/tmpfs
mkdir /tmp/mergemount

Mount the filesystems:

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 aufs -o br:/tmp/tmpfs:/tmp/squashfs 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

Make sure packagelists are up to date and install the software you like:

sudo chroot /tmp/mergemount apt-get update
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

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

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.

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 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 aufs -o br:/tmp/tmpfs:/tmp/squashfs none /tmp/mergemount

sudo chroot /tmp/mergemount mount -t proc proc /proc
sudo chroot /tmp/mergemount mount -t sysfs sysfs /sys

sudo cp /etc/resolv.conf /tmp/mergemount/etc/

sudo chroot /tmp/mergemount

sudo chroot /tmp/mergemount rm /etc/resolv.conf
sudo chroot /tmp/mergemount umount /proc
sudo chroot /tmp/mergemount umount /sys

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

MobileTeam/Mobile/HowTo/ImageModification (last edited 2008-09-04 13:40:45 by p5098ed03)