How to (temporarily) prevent yum / dnf from updating repositories?
I know this question is a little old (and this option might be new) but this just worked for me:
-C, --cacheonly
Run entirely from system cache, don't update the cache and use it even in case it is expired.
So dnf -C install ...
worked for me
p.s. in my case I was installing RPMs that I downloaded elsewhere and transferred over sneakernet because my networking is busted and I did not want to subvert dnf
by installing directly with the rpm
executable
If you look in the various dnf and yum repo config files you should find several explicit metadata expiry times, eg:
/etc/yum.repos.d/fedora-updates.repo
metadata_expire=6h
/etc/dnf/dnf.conf
metadata_expire=86400
You can override these on the dnf
command line using --setopt=
, but you must explicitly do it for every enabled repository, as well as the dnf main configuration. So you end up with something like
sudo dnf --setopt=metadata_expire=-1 \
--setopt=fedora.metadata_expire=-1 \
--setopt=fedora-update.metadata_expire=-1 \
--setopt=rpmfusion-free.metadata_expire=-1 \
search abcdef
Note the use of sudo to avoid dnf creating a separate cache for the user.