View Single Post
jedi's Avatar
Posts: 1,411 | Thanked: 1,330 times | Joined on Jan 2010 @ Tatooine
#1
Inspired by a question that came up the other day, here's my script to show rootfs and /home disk usage by apps installed on your N900. It's incredilbly ineffecient and I'm sure there's a better way of doing it, but it works for me.

Code:
#!/bin/sh

FS1=rootfs
FS2=/dev/mmcblk0p2           

for PACKAGE in $(dpkg-query -W --showformat='${Package}\n'); do
   PKGSIZE1=0                                                  
   PKGSIZE2=0                                                  
   for FILE in $(dpkg -L "${PACKAGE}"); do
      if [ -f "${FILE}" ]; then           
         MPOINT=$(df "${FILE}" | tail -n 1 | awk '{print $1}')
         SIZE=$(du -k "${FILE}" | awk '{print $1}')           
         if [ "$FS1" == "$MPOINT" ]; then                     
            PKGSIZE1=$(($PKGSIZE1 + $SIZE))        
         fi                                
         if [ "$FS2" == "$MPOINT" ]; then  
            PKGSIZE2=$(($PKGSIZE2 + $SIZE))
         fi                                
      fi                                   
   done    
   echo "$PKGSIZE1 $PKGSIZE2 ${PACKAGE}"
done
To use:
  • Copy/paste the script into a file called "appspace.sh" (or download attached file) and store it somewhere convenient, ie /home/user/MyDocs
  • Run it as root user:
    Code:
    # sh appspace.sh
    0 1468 adblock-plus-1.0
    0 60 adflashblock-css
    6576 0 adobe-flashplayer
    0 0 advanced-clock-plugin
    28 264 advanced-interface-switcher
    0 236 advanced-power-common
    0 1364 aircrack-ng
    128 0 alarmd
    It will produce a list with 3 columns - the first is rootfs space used (in Kb), then /home space used, then the app name.
    It will take a long time to run - for me it's around 40mins to trawl through all the apps I have installed.
  • To make it more useful, pipe the output to a file, eg:
    Code:
    # sh appspace.sh > appspace.txt
    ...then use the sort utility to change the order -
    Code:
    # sort -nk1 appspace.txt
    ....
    5304 72 nokia-maps-core
    6504 0 omap3430-dsp-libraries-ti
    6576 0 adobe-flashplayer
    6804 0 libssl0.9.8
    7812 0 kernel-power-modules
    8808 0 libc6
    9832 0 perl
    10756 0 microb-l10n
    16924 0 microb-engine
    23352 0 posix-locales
    34848 0 kernel-power-headers
    - sort by rootfs space used (largest last).
    Code:
    # sort -nk2 appspace.txt
    ...
    0 14764 python-pyside.qtgui
    8 16228 mplayer
    1888 17872 pingus-data
    0 18116 libqt4-webkit
    4 18420 phototranslator-alpha
    8 20476 vim
    4 21856 stellarium-mobile
    2588 25264 frozen-bubble-data
    12 33656 angrybirds
    8 34048 njurassic
    16 35556 mypaint
    - sort by /home space used.

Despite the fact this is a crap example of coding, this script may not be used elsewhere without prior permission. Epitaph - I'm looking at you.
Attached Files
File Type: txt appspace.sh.txt (599 Bytes, 135 views)
__________________
May the source be with you.
 

The Following 7 Users Say Thank You to jedi For This Useful Post: