Frequently Asked Question
The dnf-makecache service is normally started by the dnf-makecache.timer. To prevent both scheduled and manual systemd starts, stop, disable and mask both units.
Run:
sudo systemctl stop dnf-makecache.timer dnf-makecache.service
sudo systemctl disable dnf-makecache.timer dnf-makecache.service
sudo systemctl mask dnf-makecache.timer dnf-makecache.service
sudo systemctl reset-failed dnf-makecache.timer dnf-makecache.service
sudo systemctl daemon-reload
Masking is the important step. It creates a systemd mask so that the units cannot be started manually, by a timer, or as a dependency. The mask remains in place after a reboot.
Verify the units are disabled
Check their state:
systemctl is-enabled dnf-makecache.timer
systemctl is-enabled dnf-makecache.service
Both commands should report:
masked
Check that neither unit is running:
systemctl is-active dnf-makecache.timer
systemctl is-active dnf-makecache.service
Both should report:
inactive
The timer should no longer appear as an active scheduled task:
systemctl list-timers --all | grep dnf-makecache
No output is expected.
Confirm the mask files
The mask normally appears as a symbolic link to /dev/null:
ls -l /etc/systemd/system/dnf-makecache.timer
ls -l /etc/systemd/system/dnf-makecache.service
Expected output includes:
-> /dev/null
Removing the systemd mask
If the service needs to be restored later, remove the masks and reload systemd:
sudo systemctl unmask dnf-makecache.timer dnf-makecache.service
sudo systemctl daemon-reload
The timer can then be enabled and started again:
sudo systemctl enable --now dnf-makecache.timer
Do not manually delete the vendor unit files
The original unit files are usually installed under a system directory such as:
/usr/lib/systemd/system/
They are managed by the DNF or distribution package and should not be manually deleted. Removing them can cause package verification problems and the files may reappear during a package update.
Masking both units is the supported method for permanently preventing systemd from using them.
Removing DNF itself
dnf-makecache is part of the DNF package set rather than a normally independent package. Removing DNF can also remove essential package-management components and dependencies, so it is not recommended merely to stop metadata caching.
Disabling and masking the units prevents the scheduled cache refresh while retaining the ability to run DNF commands manually.
Other software can still refresh package metadata independently. For example, check for the optional automatic update timer:
systemctl list-timers --all | grep -E 'dnf|packagekit|update'
If dnf-automatic.timer is enabled and automatic DNF activity is also unwanted, disable and mask it separately:
sudo systemctl disable --now dnf-automatic.timer
sudo systemctl mask dnf-automatic.timer
