Author |
Message |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Tue 19 Jan 2010, 23:39 Post subject:
Remove unneeded modules and firmware - Zdrv_Cutter Subject description: cutdown over 50MB of extra bloat (~20MB compressed) |
|
Thanks to amigo for the assist on this one...
This should remove about 20MB compressed of unneeded modules from your zdrv.... or during a remaster you can delete the contents of /lib/modules from your pupXXXsfs working directory and place the zdrv file in the iso directory ... thats about 1/5th the size of the iso
This is something I thought might be useful for the hardware specific distros to (pupeee, olpc etc...) and for low resource computers that still want to do a frugal install... or just the minimalist at heart
0.1 - just cutdown modules - still add all firmware(10-15MB)
0.2 - cutdown both modules and firmware(~5MB)
0.3 - removes initrd modules (~1MB)
TODO
#0.4 cover /lib/firmware (~2MB)
#0.5 cover xorg drivers (~4MB)
#0.6 patch woof to allow xorg drivers in zdrv
#0.7 patch remaster script to integrate this as option
#0.8 autobuild using /etc/modules/firmware.dep{,(uname -r)}
#0.9 bugfixes and GUI improvements
#1.0 Final release
#1.X main sfs support: stripping binaries (strip), removing manpages locales, DEV files and broken links; optimize images (optipng), symlink duplicate files (rdfind), compress large binaries (upx)
Development thread here:
http://www.murga-linux.com/puppy/viewtopic.php?t=51450
 |
Description |
also removes initrd modules since they get built automatically adds some dialogs and chance to edit/check the build
|

Download |
Filename |
zdrv_cutter-0.3.pet |
Filesize |
2.13 KB |
Downloaded |
1172 Time(s) |
Description |
cuts both modules and firmware
|

Download |
Filename |
zdrv_cutter-0.2.pet |
Filesize |
2.02 KB |
Downloaded |
958 Time(s) |
Description |
original script - just for reference
|

Download |
Filename |
zdrvcutr.gz |
Filesize |
825 Bytes |
Downloaded |
932 Time(s) |
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
Last edited by technosaurus on Thu 21 Jan 2010, 10:25; edited 5 times in total
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Wed 20 Jan 2010, 00:13 Post subject:
|
|
firmware is in tar.gz thus the loaded modules don't necessarily reference them, so the will need to be copied manually for now
example:
iwlwifi contains iwlwifi-3945... but the module name is iwl3945
iwlcore should get /lib/modules/all-firmware/iwlwifi.tar.gz
I added a couple lines that copy them all until we can figure out the cases (still cuts out 15MB)-
Does someone have a list of what module gets what firmware? rerwin? tempestuous?
Code: | #!/bin/sh
. /etc/DISTRO_SPECS #gets $DISTRO* variables
KERNELVER=$(uname -r) # get the version of your kernel
PREFIX1CHAR="`echo -n "$DISTRO_FILE_PREFIX" | cut -c 1`"
KERNEL3CHARS="`echo -n "$KERNELVER" | tr -d '.' | tr -d '\-' | tr -d '[a-z]' | rev | cut -c 1,2,3 | rev`"
ZDIR="z${PREFIX1CHAR}${DISTRO_VERSION}${KERNEL3CHARS}"
# set this to the name of a temp dir:
TMPDIR=/dev/shm/$ZDIR #faster to use /dev/shm
# create the module directory in the TMP dir:
mkdir -p $TMPDIR/all-firmware
lsmod |tail +2 |cut -f1 -d' ' > $TMPDIR/mods #just a list of modules
sed -i "s/_/?/g" $TMPDIR/mods #replaces the _ with ? so that - and . will not give false evaluation
cd /
for module in $(cat $TMPDIR/mods) ; do
# uncomment the first and comment the second one to just see the list
# find lib/modules/$KVERS -type f -name "$module*"
find lib/modules/$KVERS -type f -name "$module*" -exec cp --parents {} $TMPDIR/ \;
done
cp /lib/modules/all-firmware/* $TMPDIR/lib/modules/all-firmware #needed until we make case for each tarball
mv /lib/modules /lib/modules~ # can't force a link over a directory
ln -s -f $TMPDIR/lib/modules /lib #use link so busybox depmod works
depmod #-b $TMPDIR/lib/modules/$KERNELVER -e -F /path/to/kernel/System.map
rm $TMPDIR/mods #cleanup
dir2sfs $TMPDIR
mv $TMPDIR"_"$DISTRO_VERSION.sfs ~/$ZDIR.sfs #move to $HOME
mv $TMPDIR"_"$DISTRO_VERSION.sfs-md5.txt ~/$ZDIR.sfs-md5.txt #move to $HOME
rm -rf $TMPDIR
rm -rf /lib/modules
mv /lib/modules~ /lib/modules
Xdialog --left --buttons-style text --title "Zdrv Cutter" --ok-label "Show file" --cancel-label "Exit" --yesno "Cutdown z"${PREFIX1CHAR}${DISTRO_VERSION}${KERNEL3CHARS}".sfs is now in ~" 0 0
[ $? -eq 0 ] && rox ~ &
|
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Wed 20 Jan 2010, 21:26 Post subject:
|
|
beta 0.2 is now released (see initial post)
added firmware cutdown section using info from /etc/modules/firmware.dep - removes an additional 5MB compressed
a typical zdrv is now ~4.5 MB instead of 25 MB
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Wed 20 Jan 2010, 22:23 Post subject:
|
|
beta 0.3 is now released
removes /lib/modules/$(uname -r)/initrd since it gets built at startup
added some dialogs giving opportunity to check before and after it is built
fixed some typos
Description |
|

Download |
Filename |
zdrv_cutter-0.3.pet |
Filesize |
2.13 KB |
Downloaded |
935 Time(s) |
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Thu 21 Jan 2010, 01:05 Post subject:
|
|
you can do something similar with xorg drivers ~4MB
#this code tells you your xorg driver
grep -w card0driver /etc/X11/xorg.conf |cut -d "\"" -f 2
#files are located in /usr/X11R7/lib/xorg/modules/drivers/
#however some end in _drv.so and some just in .so
#but the ones without _drv are insignificantly small
There is no reason that these cannot go in the zdrv either AFAIK
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
greengeek

Joined: 20 Jul 2010 Posts: 4933 Location: Republic of Novo Zelande
|
Posted: Wed 13 Feb 2013, 14:25 Post subject:
|
|
Does a smaller zdrv bring the benefit of a smaller RAM footprint and speed gains?
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Wed 13 Feb 2013, 14:46 Post subject:
|
|
That depends on where the modules are originally located:
if they are in the pup*.sfs, you would need to remaster and it would reduce union/mount/decompression overhead and more with pfix=ram.
if they are already in a separate, larger zdrv.sfs, then it reduces the union/mount/decompression overhead.
Side note: after learning how modules are loaded (the entire module is memmapped first and then gets passed to init_module), I would guess that its possible to load the modules and then completely umount the zdrv.sfs
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
moeppyfan

Joined: 11 Feb 2016 Posts: 48
|
Posted: Fri 19 Feb 2016, 12:12 Post subject:
|
|
Hello technosaurus,
I tried your zdrv_cutter-0.3.pet on huge-kernel-3.14.55 (Slacko 6) and it shrinks my zdrv from 30MB to 2.8MB! Nice. The new 2.8MB zdrv boots to desktop - and trackpad, keyboard, video, sound all work on my Dell Latitude D410.
To get it to recognize my wireless, I had to recreate /lib/firmware dir and re-add these files:
Code: | /lib/firmware/ipw2200-bss.fw
/lib/firmware/ipw2200-ibss.fw
/lib/firmware/ipw2200-sniffer.fw |
And to get "depmod" to run without error, I had to re-add these two files:
Code: | /lib/modules/3.14.55/modules.builtin
/lib/modules/3.14.55/modules.order |
I'm not sure if copying that old module list is 100% accurate though, since stuff has been cut?
Everything seems to work now, so I'll keep using your cut version, and let you know if I spot anything else.
P.S. The user backi started a thread about your script here, which is how I found out about it.
edit: Tried also on Dell Latitude E4300. The process was similar, except I had to re-add /lib/firmware/b43 folder for wireless.
|
Back to top
|
|
 |
Pelo
Joined: 10 Sep 2011 Posts: 12591 Location: Mer méditerrannée (1 kms°)
|
Posted: Sat 26 Mar 2016, 15:28 Post subject:
I will try it with iwlwifi. |
|
Very usefull topic, 2016 most of us surf the web with at laptop at home. Wireless just needed for your firmware sure makes the Puppy Lighter.
I will try it with iwlwifi.
zdrv_vivid_6.5.sfs: 30 M
staging: 3735 K seems a place to study.. but all that is in english, and i am not a programer.
_________________ Passenger Pelo ! don't ask him to repair the aircraft. Don't use him as a demining dog .... pleeease.
|
Back to top
|
|
 |
jabu2
Joined: 07 Apr 2008 Posts: 46 Location: Australia
|
Posted: Sat 26 Mar 2016, 23:06 Post subject:
|
|
Likewise not a programmer,
but TechnoS has once more come up with what looks like something really useful -if I'm understanding his concepts.
TechnoS identified it as "for low resource computers that still want to do a frugal install... or just the minimalist at heart ".
I think its also what is needed for a custom job, to use on a laptop/portable taken travelling - running on CD or USB.
Minimalist, but secure, and low risk of loss (if running on an oldie but goodie), uncluttered but doing the basics needed: =email, internet (top browser), file managing for whatever storage/dumping space the oldie has, etc, and easy wifi and internet connection?
Is that correct? Or are there better options for such a travelling OS?
Thanks TechnoSaurus for your efforts/initiative,
and to anyone who can give us an end-product using Google chrome and simple connectivity choices built-in.
ATVB (all the very best)
jabu2
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2134 Location: In The Way
|
Posted: Mon 02 May 2016, 06:18 Post subject:
|
|
When will 1.0 be available?
|
Back to top
|
|
 |
Sailor Enceladus
Joined: 22 Feb 2016 Posts: 1475
|
Posted: Sat 03 Sep 2016, 20:26 Post subject:
|
|
stemsee wrote: | When will 1.0 be available? |
I would love a version 0.3b that patches modules.builtin and modules.order to match the new zdrv, rather than deletes them.
|
Back to top
|
|
 |
Pelo
Joined: 10 Sep 2011 Posts: 12591 Location: Mer méditerrannée (1 kms°)
|
Posted: Thu 03 Aug 2017, 14:41 Post subject:
being tested with my X-Slim Slacko |
|
being tested with my X-Slim Slacko backi information;
however i must keep iwlwifi, which is one of the biggest so no many MBs to delete
_________________ Passenger Pelo ! don't ask him to repair the aircraft. Don't use him as a demining dog .... pleeease.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Sun 13 Aug 2017, 19:14 Post subject:
|
|
I don't really use this method now since the kernel's introduction of allmodconfig and allyesconfig.
make allmodconfig rebuilds the kernel without support for unused modules.
make allyesconfig will then build those used modules into the kernel
(for the full effect you need to boot into the former before building the latter)
The down side is that you need the devx and kernel source (I normally do), so I can see how this may still be useful.
most of the modules.* files are either completely unnecessary or automatically rebuilt by other things like depmod and will end up just getting duplicated in the savefile, so putting it in the sfs would be wasteful and redundant.
I may be able to do something about keeping the appropriate firmware though.
I have to stress that this method is just a hack. If you are doing a commercial product, the above kernel build method is more appropriate (probably followed by iterations of make menuconfig for anticipated upgrades)
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
|