I have a filesystem with many small files that I erase regularly (the files are a cache that can easily be regenerated). It's much faster to simply create a new filesystem rather than run rm -rf
or rsync
to delete all the files (i.e. Efficiently delete large directory containing thousands of files).
The only issue with creating a new filesystem to wipe the filesystem is that its UUID changes, leading to changes in e.g. /etc/fstab
.
Is there a way to simply "unlink" a directory from e.g. an ext4 filesystem, or completely clear its list of inodes?
btrfs subvolume create
+btrfs subvolume delete
instead of deleting+creating ext4 partitions? btrfs subvolume is also an efficient way to delete huge amount of files – hanshenrik Jan 30 '22 at 00:45UUID=0b56138b-6124-4ec4-a7a3-7c503516a65c /data1 btrfs subvol=data1
where the uuid is the global btrfs uuid, separate from the subvolume being mounted, hence you'd never need to touch fstab when deleting/creating suvolumes with the same name – hanshenrik Jan 30 '22 at 00:55