Keep Btrfs snapshots out of the locate index and put /home in it

The stock Arch updatedb.conf interacts badly with Omarchy's Btrfs
layout in both directions:

- Snapper snapshots under /.snapshots are nested subvolumes reached by
  plain directory traversal, so updatedb indexes the entire system once
  per snapshot. On machines that accumulated snapshots this means
  multi-hour updatedb runs at full CPU, gigabytes of RAM, and a
  multi-gigabyte plocate.db (observed: 18 GB db, 7.5 h runs at 96% CPU
  with 592 snapshots; 43 MB and ~1 min after the fix).
- PRUNE_BIND_MOUNTS="yes" treats Btrfs subvolume mounts like /home as
  bind mounts, so locate finds nothing in home directories at all.

Configure updatedb.conf at install time and migrate existing installs,
then rebuild the index in the background. Both settings are matched
tolerantly and appended when absent, so a hand-edited updatedb.conf is
fixed rather than silently skipped.
This commit is contained in:
Martin Bastien
2026-07-23 09:10:16 -04:00
parent 1b6ab15331
commit 8ef4eb24a2
4 changed files with 154 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
echo "Configure locate to skip Btrfs snapshots and index Btrfs subvolumes"
OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
locate_config_script=/usr/share/omarchy/install/config/locate.sh
if [[ ! -f $locate_config_script ]]; then
locate_config_script="$OMARCHY_PATH/install/config/locate.sh"
fi
UPDATEDB_CONF_PATH="${OMARCHY_UPDATEDB_CONF_PATH:-/etc/updatedb.conf}"
as_root() {
if (( EUID == 0 )); then
"$@"
else
sudo "$@"
fi
}
[[ -f $UPDATEDB_CONF_PATH ]] || exit 0
if grep -q '^PRUNE_BIND_MOUNTS = "no"' "$UPDATEDB_CONF_PATH" &&
grep -E '^PRUNEPATHS' "$UPDATEDB_CONF_PATH" | grep -qF '/.snapshots'; then
exit 0
fi
as_root env OMARCHY_UPDATEDB_CONF_PATH="$UPDATEDB_CONF_PATH" bash -euo pipefail "$locate_config_script"
# Rebuild the index with the new exclusions; pruning /.snapshots turns
# multi-hour runs on snapshot-heavy systems back into one-minute runs.
as_root systemctl start --no-block plocate-updatedb.service >/dev/null 2>&1 || true