Skip to content

Ensure /home is indexed by plocate on Btrfs#5320

Open
peteonrails wants to merge 1 commit intobasecamp:devfrom
peteonrails:fix-plocate-btrfs
Open

Ensure /home is indexed by plocate on Btrfs#5320
peteonrails wants to merge 1 commit intobasecamp:devfrom
peteonrails:fix-plocate-btrfs

Conversation

@peteonrails
Copy link
Copy Markdown
Contributor

@peteonrails peteonrails commented Apr 16, 2026

Summary

Btrfs subvolumes appear as bind mounts to plocate. The default PRUNE_BIND_MOUNTS="yes" in /etc/updatedb.conf causes plocate to skip $HOME entirely, so locate returns no results for any file in the user's home directory.

Sets PRUNE_BIND_MOUNTS to "no" during install (in localdb.sh) and adds a migration for existing installs.

This is the same fix merged in 9f561e0 and reverted in 262fadd because the migration file was missing the .sh extension, which prevented the migration system from executing it. Re-applies the fix with a correctly named migration.

If this approach is no longer the right direction, then #3744 may not be fixable another way.

Note on updatedb

The original commit (9f561e0) ran sudo updatedb inside the migration. We intentionally omit that here — plocate-updatedb.timer handles scheduled reindexing, so the next timer run picks up the config change without slowing down the update.

Test Notes

  • Verified locate ~/.bashrc returns nothing on fresh Omarchy 3.5.0 VM (Btrfs)
  • After applying sed, sudo updatedb, locate ~/.bashrc returns the correct path
  • Migration is idempotent (guarded with grep before sed)

Test Evidence

BEFORE

locate-bug-example

AFTER

locate-bug-fixed

Fixes #3744

Co-authored-by: David Heinemeier Hansson david@hey.com
Co-authored-by: Jorge Campo jorge-campo@users.noreply.github.com

Copilot AI review requested due to automatic review settings April 16, 2026 05:43
@peteonrails peteonrails marked this pull request as draft April 16, 2026 05:43
@peteonrails peteonrails marked this pull request as ready for review April 16, 2026 05:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures plocate indexes user home directories on Btrfs systems by disabling bind-mount pruning (PRUNE_BIND_MOUNTS="no") during install and via a migration for existing installs (fixing the previously reverted attempt due to a misnamed migration file).

Changes:

  • Add a migration to flip PRUNE_BIND_MOUNTS from "yes" to "no" in /etc/updatedb.conf.
  • Update the install-time localdb configuration to set PRUNE_BIND_MOUNTS to "no" before running updatedb.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
migrations/1776317254.sh Adds a migration to adjust updatedb.conf so plocate won’t prune Btrfs subvolume “bind mounts”.
install/config/localdb.sh Sets PRUNE_BIND_MOUNTS during install before running updatedb.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread migrations/1776317254.sh
echo "Allow plocate to index Btrfs subvolumes (including home)"

if grep -q '^PRUNE_BIND_MOUNTS.*=.*"yes"' /etc/updatedb.conf; then
sudo sed -i 's/^PRUNE_BIND_MOUNTS.*=.*"yes"/PRUNE_BIND_MOUNTS = "no"/' /etc/updatedb.conf
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replacement text writes PRUNE_BIND_MOUNTS = "no" with spaces around =, which is not valid shell assignment syntax. /etc/updatedb.conf is sourced by updatedb, so this can break updatedb (and therefore locate) entirely. Update the sed replacement to PRUNE_BIND_MOUNTS="no" (no spaces) and keep the match anchored to the intended assignment line.

Suggested change
sudo sed -i 's/^PRUNE_BIND_MOUNTS.*=.*"yes"/PRUNE_BIND_MOUNTS = "no"/' /etc/updatedb.conf
sudo sed -i 's/^PRUNE_BIND_MOUNTS.*=.*"yes"/PRUNE_BIND_MOUNTS="no"/' /etc/updatedb.conf

Copilot uses AI. Check for mistakes.
Comment thread install/config/localdb.sh
@@ -1,2 +1,3 @@
# Update localdb so that locate will find everything installed
# Ensure /home is indexed on Btrfs (subvolumes look like bind mounts)
sudo sed -i 's/PRUNE_BIND_MOUNTS.*=.*/PRUNE_BIND_MOUNTS = "no"/' /etc/updatedb.conf
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sed replacement also writes PRUNE_BIND_MOUNTS = "no" with spaces around =, which is invalid in /etc/updatedb.conf (it’s a shell-style config sourced by updatedb). This can cause sudo updatedb to fail after install. Replace with PRUNE_BIND_MOUNTS="no" (no spaces) and consider anchoring the pattern to ^PRUNE_BIND_MOUNTS= to avoid unintended edits.

Suggested change
sudo sed -i 's/PRUNE_BIND_MOUNTS.*=.*/PRUNE_BIND_MOUNTS = "no"/' /etc/updatedb.conf
sudo sed -i 's/^PRUNE_BIND_MOUNTS=.*/PRUNE_BIND_MOUNTS="no"/' /etc/updatedb.conf

Copilot uses AI. Check for mistakes.
@peteonrails
Copy link
Copy Markdown
Contributor Author

peteonrails commented Apr 16, 2026

Re: Copilot's suggestion to remove spaces around = in the sed replacement —

The Arch default updatedb.conf ships with spaces: PRUNE_BIND_MOUNTS = "yes". This file is read by plocate's own parser, not sourced as shell, so spaces around = are valid. The replacement preserves the existing format. This also matches the format used in the original fix (9f561e0).

That said, happy to apply copilots suggestion since it will not cause any harm.

@peteonrails peteonrails changed the base branch from master to dev April 16, 2026 18:29
Btrfs subvolumes appear as bind mounts to plocate. The default
PRUNE_BIND_MOUNTS="yes" in /etc/updatedb.conf causes plocate to
skip $HOME entirely, so `locate` returns no results for any file
in the user's home directory.

Set PRUNE_BIND_MOUNTS to "no" during install (in localdb.sh) and
add a migration for existing installs. This is the same fix DHH
merged in 9f561e0 and then reverted in 262fadd because the
migration file was missing the .sh extension, which prevented the
migration system from executing it. This re-applies the fix with
a correctly named migration.

Note: if this approach is no longer the right direction, the
underlying Btrfs/bind-mount behavior is by design in plocate and
won't change upstream, so basecamp#3744 may not be fixable another way.

Closes basecamp#3744

Co-authored-by: David Heinemeier Hansson <david@hey.com>
Co-authored-by: Jorge Campo <jorge-campo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plocate does not index $HOME on Btrfs subvolume setups unless PRUNE_BIND_MOUNTS="no"

2 participants