![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package btrfsmaintenance for openSUSE:Factory checked in at 2016-03-16 10:38:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/btrfsmaintenance (Old) and /work/SRC/openSUSE:Factory/.btrfsmaintenance.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "btrfsmaintenance" Changes: -------- --- /work/SRC/openSUSE:Factory/btrfsmaintenance/btrfsmaintenance.changes 2015-10-17 16:39:07.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.btrfsmaintenance.new/btrfsmaintenance.changes 2016-03-16 10:38:43.000000000 +0100 @@ -1,0 +2,10 @@ +Fri Mar 4 00:00:00 CET 2016 - dsterba@suse.cz + +- version 0.2 + - updated documentation + - support debian-like configuration paths + - no hardcoded paths to external utilities + - fixed logger name typos for 'journal' target + - defrag fixes (sysconfig, find arguments) + +------------------------------------------------------------------- Old: ---- btrfsmaintenance-0.1.2.tar.bz2 New: ---- btrfsmaintenance-0.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ btrfsmaintenance.spec ++++++ --- /var/tmp/diff_new_pack.OCorOG/_old 2016-03-16 10:38:44.000000000 +0100 +++ /var/tmp/diff_new_pack.OCorOG/_new 2016-03-16 10:38:44.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package btrfsmaintenance # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: btrfsmaintenance -Version: 0.1.2 +Version: 0.2 Release: 0 Summary: Scripts for btrfs periodic maintenance tasks License: GPL-2.0 ++++++ btrfsmaintenance-0.1.2.tar.bz2 -> btrfsmaintenance-0.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/README.md new/btrfsmaintenance-0.2/README.md --- old/btrfsmaintenance-0.1.2/README.md 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/README.md 2016-03-04 18:03:27.000000000 +0100 @@ -6,8 +6,8 @@ *defragmentation*. Each of the tasks can be turned on/off and configured independently. The -default config values were selected to fit the default installation profile of -openSUSE 13.2 where the root filesystem is formatted to *btrfs*. +default config values were selected to fit the default installation profile +with btrfs on the root filesystem. Overall tuning of the default values should give a good balance between effects of the tasks and low impact of other work on the system. If this does not fit @@ -137,3 +137,60 @@ The tasks' periods and other parameters should fit most usecases and do not need to be touched. Review the mountpoints (variables ending with `_MOUNTPOINTS`) whether you want to run the tasks there or not. + +## Distro integration ## + +Currently the support for widely used distros is present. More distros can be +added. This section describes how the pieces are put together and should give +some overview. + +### Installation ### + +* `btrfs-*.sh` task scripts are expected at `/usr/share/btrfsmaintenance` +* `sysconfig.btrfsmaintenance` configuration template is put to: + * `/etc/sysconfig/btrfsmaintenance` on SUSE and RedHat based systems or derivatives + * `/etc/default/btrfsmaintenance` on Debian and derivatives +* `/usr/lib/zypp/plugins/commit/btrfs-defrag-plugin.py` post-update script for + zypper (the package manager), applies to SUSE-based distros for now +* cron refresh scripts are installed (see bellow) + +### cron jobs ### + +The periodic execution of the tasks is done by the 'cron' service. Symlinks to +th task scripts are located in the respective directories in +`/etc/cron.<PERIOD>`. + +The script `btrfsmaintenance-refresh-cron.sh` will synchronize the symlinks +according to the configuration files. This can be called automatically by a GUI +configuration tool if it's capable of running post-change scripts or services. +In that case there's `btrfsmaintenance-refresh.service` systemd service. + +### Post-update defragmentation ### + +The package database files tend to be updated in a random way and get +fragmented, which particularly hurts on btrfs. For rpm-based distros this means files +in `/var/lib/rpm`. The script or plugin simpy runs a defragmentation on the affected files. +See `btrfs-defrag-plugin.py` for more details. + +At the moment the 'zypper' package manager plugin exists. As the package +managers differ significantly, there's no single plugin/script to do that. + +### Settings ### + +The settings are copied to the expected system location from the template +(`sysconfig.btrfsmaintenance`). This is a shell script and can be sourced to obtain +values of the variables. + +The template contains descriptions of the variables, default and possible +values and can be deployed without changes (expecting the root filesystem to be +btrfs). + +## About ## + +The goal of this project is to help administering btrfs filesystems. It is not +supposed to be distribution specific. Common scripts/configs are preferred but +per-distro exceptions will be added when necessary. + +License: [GPL 2](https://www.gnu.org/licenses/gpl-2.0.html) + +[Contributing guide](CONTRIBUTING.md). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/btrfs-balance.sh new/btrfsmaintenance-0.2/btrfs-balance.sh --- old/btrfsmaintenance-0.1.2/btrfs-balance.sh 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/btrfs-balance.sh 2016-03-04 18:03:27.000000000 +0100 @@ -12,7 +12,11 @@ export PATH if [ -f /etc/sysconfig/btrfsmaintenance ] ; then - . /etc/sysconfig/btrfsmaintenance + . /etc/sysconfig/btrfsmaintenance +fi + +if [ -f /etc/default/btrfsmaintenance ] ; then + . /etc/default/btrfsmaintenance fi LOGIDENTIFIER='btrfs-balance' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/btrfs-defrag-plugin.py new/btrfsmaintenance-0.2/btrfs-defrag-plugin.py --- old/btrfsmaintenance-0.1.2/btrfs-defrag-plugin.py 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/btrfs-defrag-plugin.py 2016-03-04 18:03:27.000000000 +0100 @@ -58,13 +58,13 @@ return if DEBUG: dbg('--- Fragmentation before') - dbg(qx('/usr/sbin/filefrag %s/*' % (PATH))) - ret = qx('/usr/sbin/btrfs filesystem defragment -v -f -r -t %s "%s"' % \ + dbg(qx('filefrag %s/*' % (PATH))) + ret = qx('btrfs filesystem defragment -v -f -r -t %s "%s"' % \ (str(EXTENT_SIZE), PATH)) if DEBUG: dbg(ret) dbg('--- Fragmentation after') - dbg(qx('/usr/sbin/filefrag %s/*' % (PATH))) + dbg(qx('filefrag %s/*' % (PATH))) self.ack() plugin = BtrfsDefragPlugin() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/btrfs-defrag.sh new/btrfsmaintenance-0.2/btrfs-defrag.sh --- old/btrfsmaintenance-0.1.2/btrfs-defrag.sh 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/btrfs-defrag.sh 2016-03-04 18:03:27.000000000 +0100 @@ -15,6 +15,10 @@ . /etc/sysconfig/btrfsmaintenance fi +if [ -f /etc/default/btrfsmaintenance ] ; then + . /etc/default/btrfsmaintenance +fi + LOGIDENTIFIER='btrfs-defrag' { @@ -26,14 +30,14 @@ echo "Path $P is not btrfs, skipping" continue fi - find "$P" -size "$BTRFS_DEFRAG_MIN_SIZE" -type f -xdev \ - -exec /sbin/btrfs filesystem defrag -t 32m -f "$BTRFS_VERBOSITY" '{}' \; + find "$P" -xdev -size "$BTRFS_DEFRAG_MIN_SIZE" -type f \ + -exec btrfs filesystem defrag -t 32m -f $BTRFS_VERBOSITY '{}' \; done } | \ case "$BTRFS_LOG_OUTPUT" in stdout) cat;; - journal) sytemd-cat -t "$LOGIDENTIFIER";; + journal) systemd-cat -t "$LOGIDENTIFIER";; *) cat;; esac diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/btrfs-scrub.sh new/btrfsmaintenance-0.2/btrfs-scrub.sh --- old/btrfsmaintenance-0.1.2/btrfs-scrub.sh 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/btrfs-scrub.sh 2016-03-04 18:03:27.000000000 +0100 @@ -15,6 +15,10 @@ . /etc/sysconfig/btrfsmaintenance fi +if [ -f /etc/default/btrfsmaintenance ] ; then + . /etc/default/btrfsmaintenance +fi + LOGIDENTIFIER='btrfs-scrub' readonly= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/btrfs-trim.sh new/btrfsmaintenance-0.2/btrfs-trim.sh --- old/btrfsmaintenance-0.1.2/btrfs-trim.sh 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/btrfs-trim.sh 2016-03-04 18:03:27.000000000 +0100 @@ -15,6 +15,10 @@ . /etc/sysconfig/btrfsmaintenance fi +if [ -f /etc/default/btrfsmaintenance ] ; then + . /etc/default/btrfsmaintenance +fi + LOGIDENTIFIER='btrfs-trim' { @@ -27,13 +31,13 @@ continue fi echo "Running fstrim on $MNT" - /usr/sbin/fstrim "$MNT" + fstrim "$MNT" done } | \ case "$BTRFS_LOG_OUTPUT" in stdout) cat;; - journal) sytemd-cat -t "$LOGIDENTIFIER";; + journal) systemd-cat -t "$LOGIDENTIFIER";; *) cat;; esac diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/btrfsmaintenance-refresh-cron.sh new/btrfsmaintenance-0.2/btrfsmaintenance-refresh-cron.sh --- old/btrfsmaintenance-0.1.2/btrfsmaintenance-refresh-cron.sh 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/btrfsmaintenance-refresh-cron.sh 2016-03-04 18:03:27.000000000 +0100 @@ -30,13 +30,19 @@ . /etc/sysconfig/btrfsmaintenance fi +if [ -f /etc/default/btrfsmaintenance ]; then + . /etc/default/btrfsmaintenance +fi + refresh_period() { EXPECTED="$1" SCRIPT="$2" echo "Refresh script $SCRIPT for $EXPECTED" for PERIOD in daily weekly monthly; do - FILE="/etc/cron.$PERIOD/$SCRIPT" + # NOTE: debian does not allow filenames with dots in /etc/cron.* + LINK="${SCRIPT%.*}" + FILE="/etc/cron.$PERIOD/$LINK" if [ "$PERIOD" = "$EXPECTED" ]; then ln -sf "$SCRIPTS/$SCRIPT" "$FILE" else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/debian-install.sh new/btrfsmaintenance-0.2/debian-install.sh --- old/btrfsmaintenance-0.1.2/debian-install.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/btrfsmaintenance-0.2/debian-install.sh 2016-03-04 18:03:27.000000000 +0100 @@ -0,0 +1,6 @@ +#!/bin/sh +install -oroot -groot -m644 sysconfig.btrfsmaintenance /etc/default/btrfsmaintenance +install -d -oroot -groot -m755 /usr/share/btrfsmaintenance +install -oroot -groot -m755 btrfs-*.sh /usr/share/btrfsmaintenance/ +echo "Now edit cron periods and mount points in /etc/default/btrfsmaintenance then run ./btrfsmaintenance-refresh-cron.sh to update cron symlinks +" \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.1.2/sysconfig.btrfsmaintenance new/btrfsmaintenance-0.2/sysconfig.btrfsmaintenance --- old/btrfsmaintenance-0.1.2/sysconfig.btrfsmaintenance 2015-10-14 17:39:46.000000000 +0200 +++ new/btrfsmaintenance-0.2/sysconfig.btrfsmaintenance 2016-03-04 18:03:27.000000000 +0100 @@ -24,10 +24,10 @@ ## Path: System/File systems/btrfs ## Type: string -## Default: "+1m" +## Default: "+1M" # # Minimal file size to consider for defragmentation -BTRFS_DEFRAG_MIN_SIZE="+1m" +BTRFS_DEFRAG_MIN_SIZE="+1M" ## Path: System/File systems/btrfs ## Type: string