Reply
Thread Tools Search this Thread
jedi's Avatar
Posts: 1,410 | Thanked: 1,309 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, 25 views)
__________________
May the source be with you.
 

The Following 7 Users Say Thank You to jedi For This Useful Post:
F2thaK's Avatar
Posts: 4,283 | Thanked: 2,342 times | Joined on Jan 2010 @ Australia Mate
#2
 
Captwheeto's Avatar
Posts: 301 | Thanked: 192 times | Joined on Oct 2008 @ England
#3
>Epitaph - I'm looking at you.

Lol'd
 
AgogData's Avatar
Posts: 870 | Thanked: 129 times | Joined on Aug 2010
#4
same as storage usage without the gui
 
jedi's Avatar
Posts: 1,410 | Thanked: 1,309 times | Joined on Jan 2010 @ Tatooine
#5
Originally Posted by AgogData View Post
same as storage usage without the gui
Not really the same 'without a gui' - storageusage will do much more! This script could be useful in certain instances - for example: no disk space left on rootfs.
__________________
May the source be with you.
 
jedi's Avatar
Posts: 1,410 | Thanked: 1,309 times | Joined on Jan 2010 @ Tatooine
#6
Originally Posted by epitaph View Post
It's bad script and it's probably stolen, too. You should seek attention somewhere else.
LOL! What a hypocrite! Yes, my coding sucks but at least I can 100% guarantee it's my own code. I threw it up here in case anyone wants to use it. No charge - no enforced "donations" - no theft - no lame nag screens.
__________________
May the source be with you.
 

The Following User Says Thank You to jedi For This Useful Post:
jedi's Avatar
Posts: 1,410 | Thanked: 1,309 times | Joined on Jan 2010 @ Tatooine
#7
Originally Posted by epitaph View Post
You even don't know the difference between a guarantee and a warranty
Even if I didn't know the difference, what's your point?


Originally Posted by epitaph View Post
Where did you pick your code?
Out of my nose.
__________________
May the source be with you.
 

The Following User Says Thank You to jedi For This Useful Post:
Posts: 782 | Thanked: 315 times | Joined on May 2010
#8
Originally Posted by jedi View Post
out of my nose.
lol!!!!!!!!!!!!!!!
 
Captwheeto's Avatar
Posts: 301 | Thanked: 192 times | Joined on Oct 2008 @ England
#9
Originally Posted by epitaph View Post
You seek attention.
And you're a d-bag that steals code that wrecks users devices and plagues them for money. Please don't act any more aloof about being a blight.
 

The Following User Says Thank You to Captwheeto For This Useful Post:
jedi's Avatar
Posts: 1,410 | Thanked: 1,309 times | Joined on Jan 2010 @ Tatooine
#10
Originally Posted by epitaph View Post
You seek attention.
At least I can troll better than I code
__________________
May the source be with you.
 
Reply

Tags
close this plz, crap code, disk usage, jedi is lonely, troll party

Thread Tools Search this Thread
Search this Thread:

Advanced Search

 
Forum Jump


All times are GMT -4. The time now is 03:57 PM.