JFFS2 file sizes

Ian Bicking ianb at colorstudy.com
Wed Jul 25 15:58:27 EDT 2007


When considering what content can be shipped or stored on the laptop, 
we're wondering what the real disk(/flash) usage is for files.  Since 
JFFS2 is doing compression behind the scenes, it's not completely clear. 
  Also, it would be nice if we could estimate how much disk something 
will use without actually having to put the content on a laptop.

My guess is that there will be per-file compression using gzip/zlib.  So 
we could estimate the size by doing something like:

   copy -r uncompressed-files compressed-files
   gzip -r compressed-files/*
   du -s --apparent-size uncompressed-files compressed-files

Should I use --apparent-size?  Otherwise it looks like du is taking into 
account the actual disk usage, which on my ext3 system isn't going to be 
representative.  Presumably there's some filesystem overhead on JFFS2, 
but maybe less than on ext3.  Will du give accurate disk usage amounts 
on the laptop (taking into account compression)?  If there was an 
equation that would be handy, e.g.:

   alignment = 1024
   directory_overhead = overhead = 256
   directory_file_listing = 256
   def file_size(filename):
       if os.path.isdir(filename):
           return (directory_overhead +
                   directory_file_listing*len(os.listdir(filename)))
       compressed_size = len(open(filename, 'rb').read().encode('zlib'))
       compressed_size += compressed_size % alignment
       compressed_size += overhead
       return compressed_size


-- 
Ian Bicking : ianb at colorstudy.com : http://blog.ianbicking.org


More information about the Library mailing list