Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 03 Nov 2010 19:54:58 -0000
From:      Nick Hibma <nick@van-laarhoven.org>
To:        Warner Losh <imp@village.org>
Subject:   NanoBSD: Disk usage function to check how full the image is
Message-ID:  <B084FCBC-46EF-4CAF-8EA9-0BA30C1FDEBC@van-laarhoven.org>
Resent-Message-ID: <20101103195457.DA875106564A@hub.freebsd.org>

index | next in thread | raw e-mail

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                                                                                           
}                                                                                                    


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B084FCBC-46EF-4CAF-8EA9-0BA30C1FDEBC>