fix: Add memory limit to duperemove service

This commit is contained in:
Kyle Gospodnetich 2024-01-31 14:26:53 -08:00
parent 13187924fb
commit ab41b7c22f
3 changed files with 42 additions and 3 deletions

View File

@ -280,9 +280,7 @@ RUN rpm-ostree install \
ln -s /usr/share/fonts/google-noto-sans-cjk-fonts /usr/share/fonts/noto-cjk && \
wget https://raw.githubusercontent.com/KyleGospo/steam-proton-mf-wmv/master/installcab.py -O /usr/bin/installcab && \
wget https://github.com/KyleGospo/steam-proton-mf-wmv/blob/master/install-mf-wmv.sh -O /usr/bin/install-mf-wmv && \
wget https://raw.githubusercontent.com/jlu5/icoextract/master/exe-thumbnailer.thumbnailer -O /usr/share/thumbnailers/exe-thumbnailer.thumbnailer && \
wget https://gitlab.com/popsulfr/steamos-btrfs/-/raw/11114e4ff791eb2c385814c2fcbac6a83f144f35/files/usr/lib/systemd/system/btrfs-dedup@.service -O /usr/lib/systemd/system/btrfs-dedup@.service && \
wget https://gitlab.com/popsulfr/steamos-btrfs/-/raw/11114e4ff791eb2c385814c2fcbac6a83f144f35/files/usr/lib/systemd/system/btrfs-dedup@.timer -O /usr/lib/systemd/system/btrfs-dedup@.timer
wget https://raw.githubusercontent.com/jlu5/icoextract/master/exe-thumbnailer.thumbnailer -O /usr/share/thumbnailers/exe-thumbnailer.thumbnailer
# Install Steam & Lutris, plus supporting packages
RUN rpm-ostree install \

View File

@ -0,0 +1,30 @@
[Unit]
Description=Btrfs deduplication on %f
ConditionPathIsMountPoint=%f
RequiresMountsFor=%f
[Service]
Type=oneshot
MemoryHigh=1G
ExecCondition=sh -c '[ "$(stat -f -c "%%T" "$1")" = btrfs ]' _ %f/
ExecStartPre=-find %f/ -mindepth 1 -maxdepth 1 -mtime +14 -name .duperemove.hash -exec rm -f '{}' \;
ExecStartPre=-cp -a %f/.duperemove.hash duperemove.hash
ExecStartPre=-compsize %f/
ExecStart=rmlint --hidden --types="duplicates" --config=sh:handler=clone %f/
ExecStart=sh -c 'exec ./rmlint.sh -d -p -r -k'
ExecStart=-compsize %f/
ExecStart=-sh -c '[ "$(sqlite3 -readonly duperemove.hash "SELECT keyval FROM config where keyname=''version_major''")" -ge 4 ] || rm -f duperemove.hash'
ExecStart=duperemove -r -d -h -q --hashfile=duperemove.hash --skip-zeroes --exclude="%f/.duperemove.hash" --exclude="%f/@swapfile/swapfile" %f/
ExecStartPost=-compsize %f/
ExecStopPost=-cp -a duperemove.hash %f/.duperemove.hash
TimeoutStartSec=4h
RuntimeDirectory=%p/%i
WorkingDirectory=%t/%p/%i
Nice=19
CPUSchedulingPolicy=batch
IOSchedulingClass=best-effort
IOSchedulingPriority=7
OOMScoreAdjust=1000
CPUWeight=30
CPUQuota=300%
IOWeight=30

View File

@ -0,0 +1,11 @@
[Unit]
Description=Weekly Btrfs deduplication on %f
[Timer]
OnCalendar=weekly
AccuracySec=1h
RandomizedDelaySec=1d
Persistent=true
[Install]
WantedBy=timers.target