Disable file indexing in disposable qubes

File indexing (e.g. via tracker3 on Debian) uses quite a few resources and is pretty useless in a DVM qube, such as sys-usb, or other disposables that storage devices are attached to, as the tracker will have to start over every time the qube is started and it’s activity may block certain operations, e.g. dismounting veracrypt volumes. Therefore it may be useful to just turn file indexing off for those qubes:

In your DVM-template (e.g. debian-12-dvm, fedora-38-dvm etc.; I tested this for Debian 12 and Fedora-38) start a terminal and run the following commands:

systemctl --user mask tracker-extract-3.service tracker-miner-fs-3.service tracker-miner-rss-3.service tracker-writeback-3.service tracker-xdg-portal-3.service tracker-miner-fs-control-3.service

and then

tracker3 reset -s -r

and then shut down the DVM-template. Be sure that you did this in the DVM-template, e.g. debian-12-dvm, and not in the base template, e.g. debian-12!

The next time a DVM-based qube, e.g. sys-usb starts, it won’t have tracker3 running (you can verify this by running tracker3 status inside a disposable qube after shutting down the DVM-template). Note that from QubesOS 4.2 onward file-indexing will be disabled by default in all serviceVMs, such as sys-usb and sys-firewall, but not in “normal” disposable qubes.

Important caveat: tracker3 does more than just file indexing, e.g. it helps with search and rename, but so far for me normal search, including in nautilus still works, so I guess it just impedes faster search for lots of data, which is not a typical use case for a DVM qube, since that qube would realistically have to run for a long time in order for this to have productivity enhancing effects.

3 Likes

Related:

1 Like

I found this shell script with the various options to control Tracker

If masking the service has negative side effects, then disabling the crawler is the official recommended way of disabling Tracker.

gsettings set org.freedesktop.Tracker3.Miner.Files crawling-interval -2
#!/usr/bin/env bash

# make tracker3 daemon non workable & idompotent
# this script will reset its settings, and configure tracker3 daemon, to not let it do anyting.
# if other code has dependency on this tracker, then it will not break, but we also do achieve our goal.

# interpretation  for org.freedesktop.Tracker3.Miner.Files enable-monitor from this file 
# https://gitlab.gnome.org/GNOME/tracker-miners/-/blob/master/src/miners/fs/tracker-config.c

#Time in seconds before crawling filesystem (0->1000)
# looking at source code https://gitlab.gnome.org/GNOME/tracker-miners/-/blob/master/src/miners/fs/tracker-main.c#L406
# it seems like -ve value will starts it right away, so giving max value will make it to wait max before failing
gsettings set org.freedesktop.Tracker3.Miner.Files initial-sleep 1000

# Set to false to completely disable any monitoring
gsettings set org.freedesktop.Tracker3.Miner.Files enable-monitors false

# Sets the indexing speed (0->20, where 20=slowest speed)
gsettings set org.freedesktop.Tracker3.Miner.Files throttle 20

# Set to true to index while running on battery
gsettings set org.freedesktop.Tracker3.Miner.Files index-on-battery false

# Set to true to index while running on battery for the first time only
gsettings set org.freedesktop.Tracker3.Miner.Files index-on-battery-first-time false

#Set to true to enable traversing mounted directories for removable devices (this includes optical discs)
gsettings set org.freedesktop.Tracker3.Miner.Files index-removable-devices false

# Set to true to enable traversing CDs, DVDs, and generally optical media 
# (if removable devices are not indexed, optical discs won't be either)
gsettings set org.freedesktop.Tracker3.Miner.Files index-optical-discs false

# Pause indexer when disk space is <= this value
# (0->100, value is in % of $HOME file system, -1=disable pausing)
# hmm, seems like this line https://gitlab.gnome.org/GNOME/tracker-miners/-/blob/master/src/miners/fs/tracker-main.c#L124
# is misleading, as used by some blog, -ve value disable pausing of tracker, rather then tracker itself,
# and 100 will make it idompotent as any other value is always < 100%
gsettings set org.freedesktop.Tracker3.Miner.Files low-disk-space-limit 100

#  List of directories to crawl recursively for indexing (separator=;)
# Special values include: (see /etc/xdg/user-dirs.defaults & $HOME/.config/user-dirs.default)
#   &DESKTOP\n"
#   &DOCUMENTS\n"
#   &DOWNLOAD\n"
#   &MUSIC\n"
#   &PICTURES\n"
#   &PUBLIC_SH
#   &TEMPLATES\n"
#   &VIDEOS\n"
# If $HOME is the default below, it is because $HOME/.config/user-dirs.default was missing.

# hmm, i think emptying its value will make it work on all dirs, i probably seen that check somewhere
# anyways, redirecting to nonexistent directory will mislead and stop its loop furthur
gsettings set org.freedesktop.Tracker3.Miner.Files index-recursive-directories "['nonexistentdir1']"

# List of directories to index but not sub-directories for changes (separator=;)\n"
# Special values used for IndexRecursiveDirectories can also be used here"

# same with this, as was with index-recursive-directories, but these dirs are removed from index-recursive-directories
# so giving it diff value will be more idompotent to this
gsettings set org.freedesktop.Tracker3.Miner.Files index-single-directories "['nonexixtentdir2']"

# List of directories to NOT crawl for indexing (separator=;)"
# this uses regex, patterns so * will match to everything
gsettings set org.freedesktop.Tracker3.Miner.Files ignored-directories "['*']"

# List of directories to NOT crawl for indexing based on child files (separator=;)"
# this uses regex, patterns so *, *.*, .* will matches to everything
gsettings set org.freedesktop.Tracker3.Miner.Files ignored-directories-with-content "['*', '*.*', '.*']"

# List of files to NOT index (separator=;)"
# this uses regex, patterns so *, *.*, .* will matches to everything
gsettings set org.freedesktop.Tracker3.Miner.Files ignored-files "['*','*.*','.*']"

# Interval in days to check the filesystem is up to date in the database,
# maximum is 365, default is -1.
#   -2 = crawling is disabled entirely
#   -1 = crawling *may* occur on startup (if not cleanly shutdown)
#    0 = crawling is forced
gsettings set org.freedesktop.Tracker3.Miner.Files crawling-interval -2

# Threshold in days after which files from removables devices
# will be removed from database if not mounted. 
#  0 means never, 
#  maximum is 365.
# so, 1 will clear everything, if its stored, daily
gsettings set org.freedesktop.Tracker3.Miner.Files removable-days-threshold  1

# hmm, it didn't explain this key behaviour, so i think making it false will be better, 
# then its default true, As this will disable application indexing
gsettings set org.freedesktop.Tracker3.Miner.Files index-applications false


# explaination based on this file: 
# https://gitlab.gnome.org/GNOME/tracker-miners/-/blob/master/src/libtracker-miners-common/tracker-fts-config.c

# Flag to enable word stemming utility (default=FALSE)
gsettings set  org.freedesktop.Tracker3.FTS enable-stemmer false

# Flag to enable word unaccenting (default=TRUE)
gsettings set  org.freedesktop.Tracker3.FTS enable-unaccent false

# Flag to ignore numbers in FTS (default=TRUE)
gsettings set  org.freedesktop.Tracker3.FTS ignore-numbers true

# Flag to ignore stop words in FTS (default=TRUE)
gsettings set  org.freedesktop.Tracker3.FTS ignore-stop-words true


# explaination based on this file: 
# https://gitlab.gnome.org/GNOME/tracker-miners/-/blob/master/src/tracker-extract/tracker-config.c

# Maximum number of UTF-8 bytes to extract per file [0->10485760]
# min ==> 0 ==> 0b
# max ==> 1024 * 1024 * 10 ==>  10 Mb
# default ==> 1024 * 1024  ==> 1Mb
gsettings set org.freedesktop.Tracker3.Extract  max-bytes 0

# Filename patterns for plain text documents that should be indexed
# empty, as these are whitelisting pattern, or maybe never existent filename pattern
# will also work, like filename that contains new line in it, will make it to never match
# to anything.
gsettings set org.freedesktop.Tracker3.Extract  text-allowlist '[]'

# Wait for FS miner to be done before extracting
# %TRUE to wait for tracker-miner-fs is done before extracting. %FAlSE otherwise
# hmm, true will make it less aggressive, as it will wait for miner to finish which
# itself has 1000s initial delay.
gsettings set org.freedesktop.Tracker3.Extract  wait-for-miner-fs true


# disable its settings in gnome settings also
# populate disable list, disable all apps, and location
gsettings set org.gnome.desktop.search-providers disabled "['org.gnome.Terminal.desktop', 'org.gnome.Settings.desktop', 'org.gnome.Photos.desktop', 'org.gnome.clocks.desktop', 'org.gnome.Calendar.desktop', 'org.gnome.Calculator.desktop', 'org.gnome.Nautilus.desktop']"

# clear enable list
gsettings set org.gnome.desktop.search-providers enabled "[]"

# search path setting is already cleared in "index-recursive-directories"

# disable gnome search indexing itself
gsettings set org.gnome.desktop.search-providers disable-external true


# and finally,
# Application Options:
#  -s, --filesystem     Remove filesystem indexer database
#  -r, --rss            Remove RSS indexer database

tracker3 reset -s -r

# and kill it brutally
tracker3 daemon --kill

IIUC you mean the upper code box with the one-liner is the official way and the lower code box with the script is not the official way but a script that you found to be effective.

The reason why I posted my way is because I’ve found lots of reports about the official way not working, and so far my way works without side effects that I detected, but that could change, of course.

I tested this same method (OP) with the two commands in fedora-38-dvm and it works there, too, for dispVMs based on it.

I still have not encountered any negative side effects of this method of disabling.

This will be of great interest to anyone who mostly runs disposables (like me). Especially when a lot of times I do indeed mount veracrypt volumes, and I’ve occasionally just had the things refuse to dismount for no apparent reason. (Normal behavior is to not dismount if there’s a terminal window open with a current working directory in the container somewhere (which is legitmately “busy”), but sometimes it happens even when no terminal window at all is open in the VM.)

I’m curious why you’re mounting veracrypt volumes in sys-usb? Or are you talking about other disposables?

I was in a hurry, but it happens also if mounting in dvms that are not sys-usb.

As I understand in Q4.2 service qubes will no longer have tracker running, but I think this guide will still be useful, as I really don’t see the point of having it running in any dispVM, even if it’s not a service qube, and the instructions work for the most up to date main templates, or, should I say, their respective dvm templates (debian-12-dvm and fedora-38-dvm).

I’ve found that especially on debian based dispVMs tracker can be quite annoying with Veracrypt, as killing the process didn’t always immediately release the resource, while on fedora-based dvms it worked better, but I now have tracker3 disabled in both dvm templates, so that also solves the problem.

OK, I figured you were probably referring to other DVMs. As for the rest I think we are in absolute agreement; this thing is pointless in any DVM and quite likely to be downright bothersome with Veracrypt. Or perhaps even when you have something not encrypted mounted in your dvm (such as any partition not part of your qubes os setup).

The only difference in my case is I don’t base my dvms off of debian-12-dvm but rather from a chain of clones originating from debian-12-minimal (and there are many, many dvm templates on my system.) But that just means I need to run this shutoff procedure where I construct the dvm templates. Should be easy.

@mods

I would like to edit my OP to include that this method also works for fedora-38-based dvm templates, not just debian-12-based ones.

But I see that it has been made into a wiki and barred from editing, even for me.

It would also make sense to change the title to reflect that this turns off file indexing for DVMs in general, not just sys-usb.

@Sven why has the OP been locked? I would like to edit it and its title in order to generalize and update the info. I see lots of other wiki posts that have not been locked.

Looking into it.

I have unlocked it now. It might have been by moderator mistake. Sorry about that!! (I didn’t even know it was possible to lock a single topic)

2 Likes