NanoBSD: Disk usage function to check how full the image is

Nick Hibma nick at van-laarhoven.org
Wed Nov 3 19:54:58 UTC 2010


As part of the last_orders() function we use an aditional function which produces information on the amount of disk space used on the image (so I can make sure they are no more than 80% full when burnt).

(run_finalise is run_customize but from last_orders; not used very much by us).

Feel free to include this function in nanobsd.sh if someone feels like it.

Nick


disk_usage () {                                                                                      
       sync; sync; sync                                                                             

       set -- `du -sk $NANO_WORLDDIR/`                                                              
       used=$1                                                                                      
       set -- `ls -sk $NANO_DISKIMGDIR/_.disk.image`                                                
       size=$1                                                                                      

       avail=$(( $size - $used ))                                                                   
       availp=$(( ${avail}00 / $size))                                                              
       pprint 1 "disk usage: $used of $size used, $avail available ($availp%)"                      
}                                                                                                    

last_orders () {                                                                                     
       if test -f ${NANO_DISKIMGDIR}/_.disk.image; then                                             
               run_finalise                                                                         
               disk_usage                                                                           
       fi                                                                                           
}                                                                                                    


More information about the freebsd-embedded mailing list