LinuxCommandLibrary

dnf-versionlock

Lock package versions from updating

TLDR

List the current versionlock entries

$ dnf versionlock
copy

Add a versionlock for all available packages matching the spec
$ dnf versionlock add [package]
copy

Add an exclude (within versionlock) for the available packages matching the spec
$ dnf versionlock exclude [package]
copy

Remove any matching versionlock entries
$ dnf versionlock delete [package]
copy

Remove all versionlock entries
$ dnf versionlock clear
copy

SYNOPSIS

dnf versionlock [options] action [spec…]

PARAMETERS

add
    Add specified packages to the versionlock list (by name or NEVRA).

delete, remove
    Remove specified packages from the versionlock list.

list
    Display all currently locked packages.

clear
    Remove all versionlock entries.

--arch
    Match or lock by architecture (for add/delete/remove).

--nevra
    Show full NEVRA details when listing (default is name-version-release-arch).

--help, -h
    Display help.

--version
    Show version information.

DESCRIPTION

The dnf versionlock plugin for the DNF package manager enables users to pin specific package versions, preventing automatic updates via dnf update. This ensures system stability by excluding newer versions of locked packages from installation or upgrades.

It maintains a database of locked entries, typically in /etc/dnf/versionlock.list (text format) or /var/lib/dnf/versionlock.sqlite (SQLite backend, configurable). Locks can target packages by name, NEVRA (Name, Epoch, Version, Release, Architecture), or file paths.

Ideal for scenarios like preserving working drivers, kernels, or dependencies during testing. When DNF resolves dependencies, it respects locks by selecting available alternatives or failing if no match exists. Locks do not block manual downgrades, removals, or installations of explicitly specified newer versions.

Usage integrates seamlessly with DNF workflows; run dnf versionlock list to review locks before updates.

CAVEATS

Locks prevent updates but not downgrades, uninstalls, or explicit installs. May cause dependency resolution failures if newer versions are required elsewhere. Review list regularly; uses excludepkgs internally, which can conflict with repo configs.

FILES

/etc/dnf/versionlock.list: Text file of locks (format: pkgname-version-release.arch).
/var/lib/dnf/versionlock.sqlite: Optional SQLite database (set versionlock_backend=sqlite in config).

EXAMPLES

dnf versionlock add httpd
Locks current httpd version.

dnf versionlock add kernel-5.14.0
Locks specific kernel NEVRA.

dnf versionlock list --nevra
Lists with full details.

dnf versionlock clear
Removes all locks.

HISTORY

Introduced in dnf-plugins-extras for Fedora 22 (2015); moved to dnf-plugins-core in Fedora 24. Evolved with DNF 4+ to support SQLite backend and better NEVRA handling.

SEE ALSO

dnf(8), dnf-plugins-core(7), dnf.conf(5)

Copied to clipboard