Ensure /home is indexed by plocate on Btrfs#5320
Ensure /home is indexed by plocate on Btrfs#5320peteonrails wants to merge 1 commit intobasecamp:devfrom
Conversation
There was a problem hiding this comment.
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_MOUNTSfrom"yes"to"no"in/etc/updatedb.conf. - Update the install-time localdb configuration to set
PRUNE_BIND_MOUNTSto"no"before runningupdatedb.
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.
| 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 |
There was a problem hiding this comment.
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.
| 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 |
| @@ -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 | |||
There was a problem hiding this comment.
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.
| 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 |
|
Re: Copilot's suggestion to remove spaces around The Arch default That said, happy to apply copilots suggestion since it will not cause any harm. |
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>
0e86237 to
000ce4a
Compare
Summary
Btrfs subvolumes appear as bind mounts to plocate. The default
PRUNE_BIND_MOUNTS="yes"in/etc/updatedb.confcauses plocate to skip$HOMEentirely, solocatereturns no results for any file in the user's home directory.Sets
PRUNE_BIND_MOUNTSto"no"during install (inlocaldb.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
.shextension, 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
updatedbThe original commit (9f561e0) ran
sudo updatedbinside the migration. We intentionally omit that here —plocate-updatedb.timerhandles scheduled reindexing, so the next timer run picks up the config change without slowing down the update.Test Notes
locate ~/.bashrcreturns nothing on fresh Omarchy 3.5.0 VM (Btrfs)sed,sudo updatedb,locate ~/.bashrcreturns the correct pathgrepbeforesed)Test Evidence
BEFORE
AFTER
Fixes #3744
Co-authored-by: David Heinemeier Hansson david@hey.com
Co-authored-by: Jorge Campo jorge-campo@users.noreply.github.com