One-click editing of initrd.gz

This has been such a long time coming! I think that someone did develop a tool for editing an initrd.gz file, but anyway, I decided that it is about time this feature was built-in to Woof.

Just as we can click on any .sfs, .2fs or .3fs file in a ROX-Filer window, and have them opened up, now the same can be done with a 'initrd.gz' file.

initrd.gz is the initramfs, that gets loaded by the kernel. Developers often want to modify this file, perhaps to just quickly test a change. Or when remastering and want to make a permanent change.

Now, just click on a 'initrd.gz' file and it is recognised as mime-type 'application/initramfs-gz' and ROX-Filer will run /usr/sbin/edit-initramfs. The latter is a new script. The initrd.gz gets expanded at /root/initrd-expanded. After any modifications, clicking on the initrd.gz file again will update it. Dialog windows clearly explain each step.

This will work in all future Woof-built puppies, but for anyone who wants to implement it right now, you need to do these things:

1. Mime type
Append this line "application/initramfs-gz:initrd.gz" into /usr/share/mime/globs.

2. ROX-Filer
Get the file ''.

3. Handler script
Get the script ''

Woof commit:

Note, it is supposed to automatically recognise gzip, bzip2 and xz compression of intrd.gz, however I have only tested gzip.

Posted on 7 Apr 2012, 17:52


Posted on 7 Apr 2012, 24:41 by L18L
Append this line "application/initramfs-gz:initrd.gz" into /usr/share/mime/globs.

Append means at the end?
This does not work.
But inserted at line number 3 (prepended) it works.

Posted on 8 Apr 2012, 7:32 by BarryK
Re prepended
Before I posted that advice, I tested. I prepended and appended, both worked. I concluded that position does not matter. I had wondered if the earlier *gz would be found first and used, but not so.

I just tried it again, appended, it works.

Posted on 8 Apr 2012, 8:07 by MHHP
IIRC, /../../globs must not contain any empty lines and must end with an empty new line.

Posted on 8 Apr 2012, 8:25 by BarryK
Re globs
Yes, it is likely that L18L left off the newline on the last entry.

Posted on 8 Apr 2012, 12:20 by jamesbond
update puppy.xml too
Hi Barry,

If you do this, please remember to update /usr/share/mime/packages/puppy.xml too. That globs and globs2 file are re-created from those xml files when one runs update-mime-database (some installers will do this) - if you don't add the entry to puppy/xml, the changes you put in globs/globs2 will be lost.


Posted on 8 Apr 2012, 12:26 by jamesbond
spoke too soon
Please ignore the above, I see you have done that already :)

Posted on 8 Apr 2012, 16:29 by L18L
re re globs
I confirm: my wrong result was without newline

Posted on 20 Apr 2012, 22:52 by scottman
2 initrd files
I have found you cannot edit 2 initrd.gz files at the same time..

If I already have 1 initrd.gz file unpacked to edit, and I click on another to open up that one as well, the script gets tricked into thinking I have clicked on the first one again, and asks me to re-package it...

This is probably not important, although it does mean users cannot open 2 initrd.gz files and copy the contents of one into the other...

Posted on 21 Apr 2012, 3:08 by BarryK
Re 2 initrd files
You can, just rename the first 'initrd-expanded' folder, the one that you want to copy files out of.

Posted on 21 Apr 2012, 8:25 by technosaurus
save over 5mb per iso
I have been doing this a while for speed, but it turns out to also have a significant effect on the sfs size - to the tune of over 5Mb (a normally >24Mb zdrv reduces to <19Mb)

cd /lib/modules/$KERNEL_VERSION

while read LINE; do echo ${LINE##*/}; done <modules.order >modules.order~
mv -f modules.order~ modules.order
for KO in `find . -type f -name *.ko`;do mv "$KO" .;done
for x in *; do [ -d "$x" ] && rm -rf "$x"; done

short, simple, effective (at least on my hardware)
(Note: some embedded software has paths hard-coded - perhaps ndis_wrapper - though this would simplify those codes immensely)

You can think scottman for reminding me of this, since it was his oops that jostled my recollection.

Posted on 21 Apr 2012, 12:53 by technosaurus
modules continued
I forgot that we copied some modules over from the initrd, so it would actually be closer to ~6mb difference if we did the same for the initrd. Actually, I initially did this only for initrd to save size and speed up depmod (the slow part of the depmod code was the file tree walk looking for module dependencies) and it had the side effect that it simplified my C implementation of init (actually a combo of init, xinit and others). I eventually recompiled the kernel with the necessary modules builtin, so I would have totally forgotten about this if it weren't for scottman accidentally including an old zdrv in his latest Akita puplet. Turns out it really speeds up depmod on the full set of modules.