Remastering grml from an existing ISO

Note: The current version of this document is at remastering.

This page documents the manual remastering approach which was used for older grml versions (year 2007 and before).

Tip of the day

Note: grml-live is a new framework (based on FAI) for creating your own Linux Live-CD based on Debian/grml. Instead of remastering an existing grml-ISO (like described below) you can create a fully customized version from scratch.

Moreover, you can use it to create Stacked Grml.

However, if you decide to use the method below, be aware that the latest versions of GRML use lzma compression instead of gzip with squashfs, so systems like Fedora9 (without some work) will not be able to unpack the image. Boot from an un-remastered version and use its squash utils. See http://grml.org/grml-live/#current_state for more details.

Also, if mksquashfs hangs at the same place each time, it is probably this bug. Use -no-sparse to get around it.

Copying /

Hint before you begin:
You can remaster grml on grml itself! Just install grml to harddisk with grml2hd and have a nice environment to remaster grml with this. Doing it this way has the advantage that you have support for squashfs etc. builtin. Furthermore, the kernel-modules and headerfiles inside the chroot fit to your running kernel. This is helpful if you want to integrate applications like VMware into grml.

To get access to grml's /, you first have to mount the grml_X.Y.iso somewhere. This ISO image is a iso9660 filesystem - any recent distribution kernel should include support for iso9660.

I put all my remastering stuff under ~/grml-remaster, just to keep track of all the files. So create a mount point and mount the iso image:

$ mkdir -p ~/grml-remaster/mount1 # We will create another mountpoint, hence the '1' at the end 
$ sudo mount /path/to/grml-X.Y.iso ~/grml-remaster/mount1 -o loop

Now we have the CD image mounted at mount1/. Inside the cd image there's e.g. the isolinux stuff, the index.html (which you get displayed when you put grml into a windows pc) and a file called GRML in the directory GRML. This file contains grml's root file system and is a squashfs filesystem.

The rest of this procedure depends on whether you intend to change the contents of the sqashfs filesystem or not. Since grml is very flexible, there are chances that you do not need to modify the squashfs.

Remaster while keeping the original squashfs

You can start exploring the grml CD's / in ~/grml-remaster/mount1 right now. Beware that the file system is mounted read-only, as iso9660 is a read-only filesystem (anything else wouldn't make sense on the CD, either :-)).

To make changes, we have to copy the mounted CD. I created ~/grml-remaster/copy-mount1 for this and copied mount1/ there:

$ mkdir ~/grml-remaster/copy-mount1
$ cp -av ~/grml-remaster/mount1/* ~/grml-remaster/copy-mount1

This takes some time. After cp is finished you have a read-/writeable copy of the grml CD's / in ~/grml-remaster/copy-mount1. You may umount ~/grml-remaster/mount1 now, if you wish.

After making your changes, create a new .iso:

$ cd copy-mount1
$ mkisofs -V "locally modified grml" -publisher 'Your Name <your.address@example>' -l -r -J \
  -no-emul-boot -boot-load-size 4 -boot-info-table -c boot/isolinux/boot.cat -b \
  boot/isolinux/isolinux.bin -o ../my-local-grml.iso .

Remaster with modified squashfs

You need to apply the kernel patch for SquashFS to your kernel sources and set CONFIG_SQUASHFS to m or y to make your kernel squashfs-ready. Don't panic, you don't have to reboot for it. ;-) make modules && sudo make modules_install will work fine if you set CONFIG_SQUASHFS to m.

Important: please notice that the squashfs version needed for remastering grml strongly depends on which version of grml you are remastering. Current grml versions us squashfs with lzma compression. Check out grml-kernel git repository, squashfs-lzma at grml and squashfs-lzma at upstream. Reminder: check out current state at grml-live documentation.

So, for example:

$ cd /usr/src
$ wget http://mesh.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz
$ tar xvzf squashfs2.2-r2.tar.gz
$ cd /lib/modules/`uname -r`/build
$ patch -p1 --dry-run < /usr/src/squashfs2.2-r2/linux-2.X.Y/squashfs2.2-patch
Check, if the patch succeeded. --dry-run is generally a good idea. If everything went fine:
$ patch -p1 < /usr/src/squashfs2.2-r2/linux-2.X.Y/squashfs2.2-patch
$ make menuconfig
(enable SquashFS)
$ make modules
$ sudo make modules_install
$ sudo modprobe squashfs

Now your kernel is ready for squashfs. You can verify this with grep squashfs /proc/filesystems.

Next, mount the grml root file system. I created ~/grml-remaster/mount2 for this.

$ mkdir ~/grml-remaster/mount2
$ sudo mount ~/grml-remaster/mount1/GRML/GRML ~/grml-remaster/mount2 -o loop -t squashfs

You can start exploring grml's / in ~/grml-remaster/mount2 right now. Beware that the file system is mounted read-only, as squashfs is a read-only filesystem (anything else wouldn't make sense on the CD, either :-)).

To make changes to the grml filesystem, we have to copy the mounted /. I created ~/grml-remaster/copy-mount2 for this and copied mount2/ there:

$ mkdir ~/grml-remaster/copy-mount2
$ sudo cp -av ~/grml-remaster/mount2/* ~/grml-remaster/copy-mount2

This takes some time. After cp is finished you have a read-/writeable copy of grml's / in ~/grml-remaster/copy-mount2. You may umount ~/grml-remaster/mount2 now, if you wish.

Making changes

You can treat ~/grml-remaster/copy-mount2 like a root filesystems of an installed linux (in fact, it isn't something else).

You can just copy files there or chroot into it, to run apt-get or so.

$ sudo chroot ~/grml-remaster/copy-mount2 /usr/bin/zsh
root@foo ~ #
(do whatever you like to do with grml)
[you might to need
root@foo ~ # mount -t proc none /proc
root@foo ~ # mount -t devpts none /dev/pts
for some actions, don't forget to umount /proc && umount /dev/pts before leaving the chroot]
root@foo ~ # exit
$

This is straightforward. You may consult any knoppix remastering howto (like the one on knoppix.net) to find out how to remove unnecessary packages (but hey, are there really any? ;-)) or install new ones. If you are familiar with Debian, feel at home.

Putting the changes back

You have to create a new squashfs image (the huge GRML/GRML file), for which mksquashfs is needed. You may build it by yourself (see /usr/src/squashfs2.2-r2/squashfs-tools, if you followed the steps above) or, if you are on a Debian system, just apt-get install squashfs-tools. Please note that filesystems generated whith squashfs-tools 3.x are not backwards compatible to version 2.x of squashfs which for instance is used by grml-small 0.4. If your remastered cd fails to find a grml-image, check mksquashfs -version .

Next, mksquashfs is ran with the source directory and the destination file as arguments:

You should do this as root, else mksquashfs can't read all files:
$ sudo mksquashfs ~/grml-remaster/copy-mount2 ~/grml-remaster/new-GRML

You can additionally add -info to the end of the command line to get some additional information about the state of the build process. The building of the squashfs image takes some time again. (Note: There´s a little bug in mksquashfs 3.3 - which is shipped in grml64-0.2 - resulting mksquashfs running in a deadlock. You should add the option -no-sparse. SquashFS-Devel-Mailinglist)

When mksquashfs is finished, you should have a look at ~/grml-remaster/new-GRML. If it's too large and unlikely to fit on a CD-R and you should remove some packages or files.

You may remove ~/grml-remaster/copy-mount2 at this point, but beware that you can easily re-create ~/grml-remaster/new-GRML out of it anything goes (or even already went) wrong.

The next step is to put the new-GRML into an iso9660 image. The original image is mounted at ~/grml-remaster/mount1 – read-only, of course. So to replace files (the GRML/GRML), we have to copy it:

$ mkdir ~/grml-remaster/copy-mount1
$ rsync -av --exclude=GRML/GRML ~/grml-remaster/mount1/. ~/grml-remaster/copy-mount1

We use rsync here, so we can –exclude GRML/GRML – as it gets replaced anyway.

You may umount ~/grml-remaster/mount1/ now, if you wish.

Next, put new-GRML back to the iso9660 root:

$ mv ~/grml-remaster/new-GRML ~/grml-remaster/copy-mount1/GRML/GRML

You should update the md5sums in GRML/md5sums to make automatic checking tools happy. I am lazy and just overwrite ./GRML's entry.

$ md5sum ~/grml-remaster/copy-mount1/GRML/GRML
057dba8064085c10e90b1291fcbe418d  /home/foobar/grml-remaster/copy-mount1/GRML/GRML
$ chmod 644 ~/grml-remaster/copy-mount1/GRML/md5sums # this file is mode 444, as the CD was r/o.
$ vim ~/grml-remaster/copy-mount1/GRML/md5sums
(change the line)
$

At the last step, you have to create the iso9660 image. You have to supply mkisofs some additional information, e.g. the path to isolinux.

$ mkisofs -pad -l -r -J -v -V "grml X.Y" -no-emul-boot \
  -boot-load-size 4 -boot-info-table \
  -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
  -hide-rr-moved \
  -o ~/grml-remaster/grml_X.Y-remastered.iso \
  ~/grml-remaster/copy-mount1
 (...)
 xxxxxxx extents written (yyy MB)
$

Congratulations. Delete ~/grml-remaster/copy-mount2 if you want and try out your remastered grml image in ~/grml-remaster/grml_X.Y-remastered.iso with qemu, vmware or with CD-RW on real hardware.

Copyright

I, Sebastian Schmidt (yath-grmlwiki@yath.de), hereby put this text into the public domain. Do with it what you like. Some modifications by Marc Haber and Michael Prokop are also in the public domain.

 
remastering-old.txt · Last modified: 2011/10/13 21:55 (external edit)
 
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Grml homepage Driven by DokuWiki