[mythtv-users] Fragmentation On Recording Disk?

Stroller linux.luser at myrealbox.com
Thu Apr 5 12:03:01 UTC 2007

On 4 Apr 2007, at 19:37, Michael T. Dean wrote:
> Myth starts a recording at 8:00pm, it begins writing to that file.   
> The
> filesystem has allocated a certain amount of space for the file,  
> and--to
> reduce fragmentation--has allocated blocks around the initial  
> blocks for
> file growth.  What the filesystem doesn't know is that Myth will
> continue to write to that file for 30 minutes, 1 hour, 2  
> hours, ...  The
> filesystem doesn't allocate gigabytes of additional storage for every
> file it creates, so any other files created during that recording are
> likely to get written where they prevent the recording from being
> allocated in one contiguous block.
> ...
> *** If Myth were to preallocate, the only completely reliable way of
> doing so is to write zeros to the disk before recording begins.  To  
> see
> how much of an issue this would be, run top in one terminal and watch
> the wa (I/O wait) value near the top of the screen as you run:
> dd if=/dev/zero of=~/testlargefilepreallocation bs=1M count=2048
> (for an SDTV show at 2GiB/hr)
> or
> dd if=/dev/zero of=~/testlargefilepreallocation bs=1M count=8192
> (for an HDTV show at 8GiB/hr)
> in another terminal.  Make sure you adjust the path of "of" to some
> location that has space (and to which you have permissions).

Here's a Dumb Question (tm). I'm not sure how far I'm straying off- 
topic in asking it, but I'm fairly sure you're knowledgeable enough  
to answer it easily, so:

Surely in this case the filesystem doesn't know when `dd` starts  
writing its file how much it is going to want to write out, so surely  
the big file of zeros will likewise end up fragmented into several  

I'd have expected a way to talk to the operating system and tell it  
in advance how much space you need (like malloc for memory). If the  
program could say in advance "hi there, I'd like to write a file and  
it's going to be 2gig in size" (obviously this isn't always possible)  
then the filesystem could better manage space to avoid fragmentation.


More information about the mythtv-users mailing list