> -----Original Message-----
> From: Rich Freeman <[email protected]> 
> Sent: Friday, October 22, 2021 12:29 PM
> To: [email protected]
> Subject: Re: [gentoo-user] [OT] how to delete a directory tree really fast
> 
> On Fri, Oct 22, 2021 at 3:21 PM Helmut Jarausch <[email protected]> wrote:
> >
> > Is it possible to have a hard link from one subvolume to a different 
> > one?
> 
> You could do a quick test, but I don't think so.  I haven't used btrfs in 
> years but they're basically separate filesystems as far as most commands are 
> concerned.  I don't think you can create reflinks between subvolumes either.
> 
> The files are already reflinked by design though.  You'd just make a new 
> snapshot and then rsync over it.  Anything that doesn't change will already 
> share space on disk by virtue of the snapshot.  Anything that does change 
> will only be modified on the snapshot you target with rsync.  I'm not sure 
> why you'd want to use a hardlink - it doesn't provide the isolation you 
> already get from the snapshot.
> 
> 
> --
> Rich

So the BTRFS filesystem itself supports hardlinks and reflinks between 
subvolumes because it has to for writable snapshots to work correctly.
The utilities, on the other hand, have not all read that memo so actually 
making it do what you want can sometimes be a bit frustrating.


Note also that all these garbage-collected filesystems are basically doing the 
equivalent of "mv to-delete .deleted ; ionice -c3 rm -rf .deleted"
The files all seem to disappear instantly, but you don't get your space back 
until the garbage collector has had a chance to grovel over all the metadata.
Groveling over the metadata is the part that takes a long time for the rm 
command.  
The advantage to garbage-collected is mainly that if you need to reboot in the 
middle of it it will automatically pick up where it left off when the 
filesystem is mounted again.

But yes, in the future if you're building a massive directory tree that you're 
planning to delete, put it in a subvolume.  That lets you do all kinds of 
useful things with it.

LMP

Reply via email to