View Single Post
Posts: 7 | Thanked: 34 times | Joined on Oct 2009 @ London, UK
#1
I was a little irritated this afternoon with a full rootfs, so I've knocked up a quick solution: http://pastebin.com/f1355fe1f

This is a simple script that calculates which packages are taking up the largest number of blocks in /usr on the filesystem and can relocate portions of them to /opt. It does this in a safe manner - every operation is atomic and it will verify the files are identical before the final switch. It can also undo the relocation, if needed.

The first run will take ages - leave the device on power for fifteen minutes or so while it churns through all your packages and works out which ones use up most space in /usr. Subsequent runs will use a cache, unless you start it with the --clean option.

A few caveats:
* The script does *NOT* make sure /opt is in a sensible location. Make sure it actually is referring to a different partition!
* There's no blacklisting of packages. It *WILL* be possible to damage your system with this script if you relocate something that is needed before the partition holding /opt is mounted. Only relocate packages you believe to be safe! Anything you know you've installed yourself is a good bet, or anything which is entirely GUI based. The n900's nokia-maps app is a prime candidate. 'busybox' is *NOT*, even though it will probably be detected as the largest package.
* The script has been tested and works on my Ubuntu box and my n900. There is no reason it won't work for the n8x0 on Maemo 4 or Mer.
* Technically, there's a race condition when switching files, so I suggest everyone disables multi-user logins on their tablets and makes sure there's no malicious software installed. Or in other words: It's not really a problem in this case.
* The script will only relocate normal files in /usr. Nothing from elsewhere, no directories, links, special files, etc.

Use:

Get root on your tablet.
Make sure bash is installed.
Download the script.

Code:
# bash pkgscan
Loading from cache...
Sorting...done
Ready.


Package: busybox
Files:   2
Size in /usr: 18792
Type 'arc' to archive:

Package: libqt4-core
Files:   1
Size in /usr: 9988
Currently archived in /opt
Type 'undo' to undo:
(anything other than 'arc' or 'undo' will skip that package)
__________________
--
for((P=10**8,Q=P/100,X=320*Q/(`tput cols`-1),Y=210*Q/`tput lines`,y=-105*Q,v=-2\
20*Q,x=v;y<105*Q;x=v,y+=Y));do for((;x<P;a=b=i=k=c=0,x+=X));do for((;a*a+b*b<4*\
P*P&&i++<99;a=((c=a)*a-b*b)/P+x,b=2*c*b/P+y));do :;done;(((j=(i<99?i%16:0)+30)>\
37?k=1,j-=8:0));echo -ne "\E[$k;$j"mE;done;echo -e \\E[0m;done # Charles Cooke
 

The Following 30 Users Say Thank You to ccooke For This Useful Post: