1 . : /lib and /bin,/sbin became more than 14MB
2 . : cp -a /bin copied a symlink to busybox , but not my own compiled busybox , which I symlinked after renaming the original busybox .
busybox itself and e2fsck are the main actors for /sbin/init , which if dynamically compiled need libs from /lib .
find@pup511 needs libm.so.6 -> , while find@pup430 not .
ls@pup430 needs libpthread* ......
While pup430 uses 3,5MB of /lib/lib*.so* , pup5xx are using 9-10MB ....
In this thread I want to discuss possibilities and want to present my solutions until now .
One of the main TODOs is to find out , which libs are essentially needed .
So here's the code to filter , which I am using :
Code: Select all
check_space_func(){
####
####KRG check for enough space ...
###Check for Available Test dev node :
if [ "`ls -l /dev/ram8 | cut -b 1-3`" != "brw" -o "`ls -l /dev/ram8 | cut -f 5,6 -d ' '`" != "1, 8" ] ; then
rm -f /dev/ram8
mknod /dev/ram8 b 1 8
fi
echo -e "\\033[1;34m"'Checking for Compiled RamDisk Size using:'"\\033[0;39m"
MAXSIZEdevRAM1=`mkfs.ext2 -v -b 1024 -i 1024 /dev/ram8 | grep 'blocks' | grep 'inodes' | tr -s ' ' | cut -f 3 -d ' '`
SIZEdevRAMdisk1=$(($MAXSIZEdevRAM1 * 93 / 100)) ###KRG 0.93 is precaution
echo
KERNV=`uname -r`
###Check for /lib/lib*.so* sizes :
echo -e "\\033[1;34m"'Checking Size of /lib/lib*.so* and /lib/ld*.so* ...'
echo -e "\\033[0;39m"
SPACElib=0
LLS=`ls -l /lib/* | grep -o '/lib/.*\->.*' | grep 'firefox' | cut -f 1 -d ' '`
[ "$DebugVal" -ge "2" ] && echo -e "\\033[0;31m"'firefox-libs: '$LLS && echo
LF=`find /lib -maxdepth 1 -name "lib*.so*" -o -name "ld*.so*"`
#Filter not needed files :
LIBF=`echo "$LF" | grep -v "$LLS" | grep -v -E 'libuClibc.*|ld\-uClibc.*|libthread.*|libm\.so\.0|libm\-0.*' | sort`
for i in $LIBF ; do
SiZElib=`ls -s $i | cut -f 1 -d ' '`
SPACElib=$(($SPACElib + $SiZElib))
[ "$DebugVal" -ge "2" ] && echo -n "$i"'='"$SiZElib " ###DBG
[ "$DebugVal" -eq "1" ] && [ "$SiZElib" -ne "0" ] && echo -n "$i"'='"$SiZElib "
done
[ "$DebugVal" -ge "2" ] && echo && echo 'total /lib='"$SPACElib" ###DBG
[ "$DebugVal" -ge "1" ] && echo
echo -e "\\033[1;34m"'Checking for available RAM ...'
echo -e "\\033[0;39m"
RAM=`free | grep -i 'mem' | sed 's#^[[:blank:]]*##' | tr -s ' ' | cut -f 2 -d ' '`
FREERAM=`free | grep -i 'mem' | sed 's#^[[:blank:]]*##' | tr -s ' ' | cut -f 4 -d ' '`
RAMLIMITdevRAM2=$(($MAXSIZEdevRAM1 * 2))
echo ' free counted total RAM:'"$RAM" ###DBG
echo 'Available RAM (minus Kernel and modules):'"$FREERAM" ###DBG
echo ' Minimum available free RAM required:'"$RAMLIMITdevRAM2"' ... ' ###DBG
if [ "$SPACElib" -gt "$SIZEdevRAMdisk1" -o "$RAMLIMITdevRAM2" -ge "$FREERAM" ] ; then #1
echo
echo ";)"
echo -e "\\033[1;31m"
if [ "$RAMLIMITdevRAM2" -ge "$FREERAM" ] ; then #1.1
echo "Needed free RAM is $RAMLIMITdevRAM2 , but free RAM is $FREERAM"
else #1.1
echo "/lib/lib*.so* is $SPACElib in KB and larger than the RamDisk compiled for"
echo -e "\\033[1;32m"
echo "kernel $KERNV with $SIZEevRAMdisk1 / $MAXSIZEevRAM1 in KB"
fi #1.1
echo -e "\\033[0;39m"
echo -e "\\033[1;31m"
echo 'fsck omitted !!!'
echo -e "\\033[1;32m"
echo 'please do the filesystemcheck via Live CD'
echo -e "\\033[1;33m"
echo 'or booting another Puppy or Linux'
echo -e "\\033[1;36m"
echo 'type [ reboot ] to reboot'
echo 'eventually you need to press CTRL+ALT+DELETE to reboot'
echo 'you may need to check BIOS bootorder also before booting LiveCD'
echo -e "\\033[0;39m"
echo
echo 'dropping to console now , partition still mounted !'
cd /
sleep 2
##BUG-1:15JUN2011##exit
exec chroot . sh ##BUG-1 fix##
fi #1
echo -e "\\033[1;32m"
echo -e ' ... OK :'"\\033[0;39m"$(( $RAM - $FREERAM + $RAMLIMITdevRAM2 ))"\\033[1;32m"' required of '"\\033[0;39m"$RAM
echo -e "\\033[0;39m"
#####
}
check_space_func
The dropping to console by using "exit" is only possible with busybox init running . The exit here in that state would lead to kernel panic . As long as init is not head of all processes , it has to be "exec sh" or "exec chroot . sh" . Bash by default compiles with a PATH that only includes "*/bin" executables and busybox ash both : "*/bin" and "*/sbin" . Calling /sbin executables using "#!/bin/bash" can olny be done by calling the whole path like "exec /sbin/chroot . sh" .
Solutions for this might be "#!/bin/bash --login" , "#!/bin/ash" or setting the PATH variable in the script , which had always worked for me .
Because of some Linux distributions like Debian or Ubuntu put the executables into "/usr/bin:/usr/sbin" it is actually a security feature to not invoke a command by the whole path . One example would be "chroot" which I recognized to be located in some development isos
in "/usr/sbin" like luma-001 by playdayz or dpup-003 by iguleder .[/edit]
The filtering part is this :
################################
###Check for /lib/lib*.so* sizes :
echo -e "\\033[1;34m"'Checking Size of /lib/lib*.so* and /lib/ld*.so* ...'
echo -e "\\033[0;39m"
SPACElib=0
LLS=`ls -l /lib/* | grep -o '/lib/.*\->.*' | grep 'firefox' | cut -f 1 -d ' '`
[ "$DebugVal" -ge "2" ] && echo -e "\\033[0;31m"'firefox-libs: '$LLS && echo
LF=`find /lib -maxdepth 1 -name "lib*.so*" -o -name "ld*.so*"`
#Filter not needed files :
LIBF=`echo "$LF" | grep -v "$LLS" | grep -v -E 'libuClibc.*|ld\-uClibc.*|libthread.*|libm\.so\.0|libm\-0.*' | sort`
for i in $LIBF ; do
SiZElib=`ls -s $i | cut -f 1 -d ' '`
SPACElib=$(($SPACElib + $SiZElib))
[ "$DebugVal" -ge "2" ] && echo -n "$i"'='"$SiZElib " ###DBG
[ "$DebugVal" -eq "1" ] && [ "$SiZElib" -ne "0" ] && echo -n "$i"'='"$SiZElib "
done
[ "$DebugVal" -ge "2" ] && echo && echo 'total /lib='"$SPACElib" ###DBG
[ "$DebugVal" -ge "1" ] && echo
################################
There is a interactive menu for the "DebugVal" , and several functions and lines for splitting /lib into a second ramdisk , which I will post another time .
This box should collect Ideas , on how to work with the huge amount of libs , which I suppose to become more than 13MB in future . I must say , that I had heard about raid arrays but don't know , if one single directory can be splitted over several partitions .