FUSE filesystem that removes the oldest files whenever the used space reaches the set percentage.
You can use it in a no empty directory, anything you write in will be written in the underlying filesystem. After unmounting it all files remain in the unmounted directory.
Once limit-fs is installed running it is very simple:
limit-fs [FUSE options] [mount options] mountPoint
It is strongly recommended to run limit-fs as regular user (not as root). For this to work the mount point must be owned by the user.
To unmount the filesystem use fusermount -u mountpoint
You can specify the options:
long option | short option | default | description |
---|---|---|---|
--usage-limit= | -u | 80 | set the usage limit in percentage. |
--help | -h | print help message | |
--version | -V | print version |
limit-fs --usage-limit=90 /mnt/
Add the FS to the /etc/fstab file. For example take the line:
limit-fs /mnt/tmpfs/limitfs limit-fs usage-limit=95,id=1000,gid=1000,user 0 0
Second part is the mount point which the limit-fs is mounted.
Next use limit-fs in the file system type.
Then comes the options usage-limit=95,uid=1000,gid=1000,user
The name of file for automatic mounting must reflect the mount point, to doesn't make a mistake use the command to compose the name:
$ systemd-escape -p --suffix=mount /path/to/mount/point
path-to-mount-point.mount
Substitute /path/to/mount/point with the correct mount point. If the mount point does not exist at the time of mounting, it is created.
- Create the file to setup the mount itself
# cat > /etc/systemd/system/path-to-mount-point.mount <<EOF
[Unit]
Description=limit-fs
[Mount]
What=limit-fs
Where=/path/to/mount/point
Options=usage-limit=95,uid=1000,gid=1005,users
Type=limit-fs
[Install]
WantedBy=multi-user.target
EOF
- Create the file to perform automatic mounting
# cat > /etc/systemd/system/path-to-mount-point.automount <<EOF
[Unit]
Description=Automount limit-fs
[Automount]
Where=/path/to/mount/point
[Install]
WantedBy=multi-user.target
EOF
- Notify systemd there are some new files available
# systemctl daemon-reload
- Enable the automount
# systemctl enable path-to-mount-point.automount
-
Install dependences:
- Fedora >= 27
# dnf install m4 automake autoconf gcc fuse3 fuse3-devel
- CentOS/RHEL/Fedora
# yum install m4 automake autoconf gcc fuse fuse-devel
- Debian
# apt-get install m4 automake autoconf gcc fuse libfuse-dev pkg-config make
- Fedora >= 27
-
Compile and install
$ ./setup.sh $ ./configure $ make $ sudo make install