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 Mon 01 Sep 2014, 08:10
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Remove unneeded modules and firmware
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Sun 17 Jan 2010, 23:33    Post subject:  Remove unneeded modules and firmware
Subject description: only what you need for your system
 

New versions available for testing here:
http://www.murga-linux.com/puppy/viewtopic.php?t=51552

TODO
Generate firmware module dependencies dynamically from either /etc/modules/firmware.dep or /etc/modules/firmware.dep.$(uname -r)
Build a list of modules that may not be loaded and still wanted (+gui)
Make it easier to integrate into remaster script.

_________________
Web Programming - Pet Packaging 100 & 101

Last edited by technosaurus on Wed 20 Jan 2010, 23:09; edited 4 times in total
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Mon 18 Jan 2010, 20:23    Post subject:  

Progress update:

lsmod > tmp #puts raw ouput in file mods
sed -i "1,1 d" tmp #removes the header line
sed -i "s/ /\*\) /g" tmp #can be .ko or .ko.gz & maybe others
cut -d " " -f 1 tmp > mods #removes all but the first column
sed -i "s/_/?/g" mods #replaces the _ with ? so that - and . will not give false evaluation
echo *) rm $FILE;; >>mods

while {recurse directories in /lib/modules/ --***NEED to CODE still***---}
case $FILE in
. $PATHTO/mods
esac

cp -a /lib/modules $DESTDIR/lib/modules
dir2sfs $DESTDIR
Now you have a case condition for each module that does nothing - can add stuff to steps 3 & 4 if we later find we need to do something on the fly (perhaps cp $FILE $DEST/lib/modules....), but for now will just use the final *) to delete the modules that do not match

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2238

PostPosted: Tue 19 Jan 2010, 16:07    Post subject:  

Code:
#!/bin/bash

CWD=$(pwd)

# set this to the name of a temp dir:
TMP=/tmp/mymodules

# create the module directory in the TMP dir:
mkdir -p $TMP

# get the version of your kernel
KVERS=$(uname -r)

lsmod |tail +2 |cut -f1 -d' ' > $CWD/mods

cd /
for module in $(cat $CWD/mods) ; do
   # uncomment the first and comment the second one to just see the list
   # find lib/modules/$KVERS -type f -name "$module*\.o"
   find lib/modules/$KVERS -type f -name "$module*\.o" -exec cp --parents {} $TMP/ \;
done

depmod -b $TMP/lib/modules/$KVERS -e -F /path/to/kernel/System.map


You'll need to run depmod on the created directory so that the module symbol tables are created.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Tue 19 Jan 2010, 21:53    Post subject:  

Yeah! it builds now - thanks for the assist amigo - now time to remaster and reboot
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=/mnt/shm/$ZDIR
# create the module directory in the TMP dir:
mkdir -p $TMPDIR
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*\.o"
   find lib/modules/$KVERS -type f -name "$module*" -exec cp --parents {} $TMPDIR/ \;
done
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

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


Joined: 18 May 2008
Posts: 4348

PostPosted: Wed 20 Jan 2010, 21:11    Post subject:  

cool, the firmware deps are in /etc/modules/firmware.dep and /etc/modules/firmware$(uname -r).dep - that should help with code to reduce some of the firmware dependencies

I hard-coded it for now for testing, but it seems that it would be possible to build the "case ... esac" for the firmware directly from firmware.dep using sed and cut

NOTES for adding dynamic creation:
sed to
replace ".ko," with |
replace ".ko" with )
cut
using : to separate firmware from modules and -s to remove comments
cut -d ":" -f 1 for firmware
cut -d ":" -f 2 for modules
then go line by line using echo to build the commands
echo $moduledeps" echo "$firmware" >>$TMPDIR/fw;;"
zdrv_cutter-0.2.pet
Description 
pet

 Download 
Filename  zdrv_cutter-0.2.pet 
Filesize  2.02 KB 
Downloaded  300 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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