Skip to content

Commit

Permalink
fix: Add memory limit to duperemove service
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Jan 31, 2024
1 parent 1318792 commit ab41b7c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Weekly Btrfs deduplication on %f

[Timer]
OnCalendar=weekly
AccuracySec=1h
RandomizedDelaySec=1d
Persistent=true

[Install]
WantedBy=timers.target

0 comments on commit ab41b7c

Please sign in to comment.