Gentoo Archives: gentoo-user

From: Laurence Perkins <lperkins@×××××××.net>
To: "gentoo-user@l.g.o" <gentoo-user@l.g.o>
Subject: RE: [gentoo-user] [OT] how to delete a directory tree really fast
Date: Fri, 22 Oct 2021 19:49:14
Message-Id: MW2PR07MB405832C54F4FE364DF211621D2809@MW2PR07MB4058.namprd07.prod.outlook.com
In Reply to: Re: [gentoo-user] [OT] how to delete a directory tree really fast by Rich Freeman
1 > -----Original Message-----
2 > From: Rich Freeman <rich0@g.o>
3 > Sent: Friday, October 22, 2021 12:29 PM
4 > To: gentoo-user@l.g.o
5 > Subject: Re: [gentoo-user] [OT] how to delete a directory tree really fast
6 >
7 > On Fri, Oct 22, 2021 at 3:21 PM Helmut Jarausch <jarausch@××××××.be> wrote:
8 > >
9 > > Is it possible to have a hard link from one subvolume to a different
10 > > one?
11 >
12 > 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.
13 >
14 > 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.
15 >
16 >
17 > --
18 > Rich
19
20 So the BTRFS filesystem itself supports hardlinks and reflinks between subvolumes because it has to for writable snapshots to work correctly.
21 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.
22
23
24 Note also that all these garbage-collected filesystems are basically doing the equivalent of "mv to-delete .deleted ; ionice -c3 rm -rf .deleted"
25 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.
26 Groveling over the metadata is the part that takes a long time for the rm command.
27 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.
28
29 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.
30
31 LMP

Replies

Subject Author
Re: [gentoo-user] [OT] how to delete a directory tree really fast Helmut Jarausch <jarausch@××××××.be>