How to avoid certain file being defragmented?

2015-04-01 Thread Wang, Zhiye
Hello,

I have some files which I hope their on-disk data can be on fixed location of 
disk. My understanding is that defragmentation operation can potentially move 
data blocks of a file.

So, can I avoid certain file being defragmented in btrfs? 


Thanks
Mike​



Re: How to avoid certain file being defragmented?

2015-04-01 Thread Hugo Mills
On Wed, Apr 01, 2015 at 12:42:04PM +, Wang, Zhiye wrote:
 Hello,

 I have some files which I hope their on-disk data can be on fixed
 location of disk. My understanding is that defragmentation operation
 can potentially move data blocks of a file.

 So, can I avoid certain file being defragmented in btrfs? 

   Simple: Don't defragment it.

   Also, set the file to nodatacow if you're planning on writing to it
at any point; don't take snapshots or reflink copies of it if that's
the case. Finally, don't ever run a balance on the FS.

   Alternatively, have a hard think about why you want to bypass the
filesystem, because it's probably a fairly bad idea. Even most
bootloaders these days put the data they can't move in the 64k before
the FS starts, and then have enough code to read the FS through its
normal data structures.

   If you need some kind of raw(ish) block interface, using a file and
a loopback device may be more useful.

   Hugo.

-- 
Hugo Mills | I get nervous when I see words like 'mayhaps' in a
hugo@... carfax.org.uk | novel, because I fear that just round the corner is
http://carfax.org.uk/  | lurking 'forsooth'
PGP: 65E74AC0  |  GRRM's UK editor


signature.asc
Description: Digital signature