Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 Oct 2014, 16:01
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Remove unneeded modules and firmware - Zdrv_Cutter
Moderators: deshlab, Flash, GuestToo, Ian, JohnMurga, Lobster
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Tue 19 Jan 2010, 23:39    Post_subject:  Remove unneeded modules and firmware - Zdrv_Cutter
Sub_title: 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
zdrv_cutter-0.3.pet
Description  also removes initrd modules since they get built automatically
adds some dialogs and chance to edit/check the build
pet

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

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

 Download 
Filename  zdrvcutr.gz 
Filesize  825 Bytes 
Downloaded  608 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101

Edited_times_total
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: 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 ~ &

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: 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

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: 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
zdrv_cutter-0.3.pet
Description 
pet

 Download 
Filename  zdrv_cutter-0.3.pet 
Filesize  2.13 KB 
Downloaded  617 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: 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

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: 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
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: 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

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0660s ][ Queries: 13 (0.0083s) ][ GZIP on ]