How to fix E: Unable to locate package linux-image-$(uname -r) in APT
This error occurs when apt cannot find a linux-image package matching your current kernel version. It commonly happens after a fresh Ubuntu installation, inside containers, or on systems with custom kernels. The fix requires updating your package cache and verifying the correct package exists for your kernel variant.
Quick fix
Fixes E: Unable to locate package linux-image-$(uname -r)
sudo apt-get update- Update your package cache
- Verify your kernel variant and available packages
- Install linux-modules-extra if linux-image-extra doesn't exist
- Enable the Universe repository if needed
sudo apt-get updateE: Unable to locate package linux-image-$(uname -r)
What this error means
When you run a command like `sudo apt-get install -y linux-image-extra-$(uname -r)`, apt expands `$(uname -r)` to your current kernel version (e.g., `5.15.0-47-generic`), then searches for `linux-image-extra-5.15.0-47-generic` in the configured repositories. The error means that specific package doesn't exist in any enabled repository, or the repository metadata is outdated. This typically indicates a mismatch between your running kernel and available packages in the repository, or that you're running a custom/specialized kernel for which kernel-extra packages were never published.
Typical symptoms
- Package installation fails with E: Unable to locate package linux-image-*
- Error appears after running apt-get install with kernel image packages
- Works fine for other packages, but fails specifically for linux-image variants
- Occurs during Docker installation on Ubuntu 16.04 or WSL environments
- Installation commands succeed on some systems but fail on others
Common causes
- Package cache is outdated and needs to be refreshed with apt update
- Your running kernel is a custom variant (AWS, KVM, Microsoft kernel) that doesn't have published linux-image-extra packages
- You're installing inside a container or WSL where the host kernel version doesn't match repository packages
- The package exists but is in a disabled repository (universe, multiverse) that isn't enabled
- The package is no longer maintained for your specific Ubuntu version or kernel variant
- You're on an older Ubuntu version where the kernel is no longer available in the default repositories
How to fix "E: Unable to locate package linux-image-$(uname -r)"
Start by refreshing the apt package lists. This is essential because the error might be due to stale repository metadata:
sudo apt-get updateThen retry your original installation:
sudo apt-get install -y linux-image-$(uname -r)If the error persists, proceed to the next step. The package cache update resolves about 40% of these errors, especially on freshly installed systems or inside containers.
Check what kernel you're running and whether linux-image packages exist for it:
# See your current kernel version
uname -r
# Search for available linux-image packages matching your kernel
apt-cache search linux-image | grep $(uname -r)
# For linux-image-extra specifically
apt-cache search linux-image-extra | grep $(uname -r)If no results appear, your kernel variant doesn't have published packages. Proceed to step 3.
If results appear but the exact package is missing (e.g., you see linux-image-5.15.0-47 but need linux-image-extra-5.15.0-47-generic), your repository might be incomplete or you're on a specialized system.
Modern Ubuntu systems often use linux-modules-extra instead of linux-image-extra. Try this alternative:
sudo apt-get install -y linux-modules-extra-$(uname -r)This package provides the kernel modules that linux-image-extra previously provided and is the recommended approach for newer Ubuntu versions. It has better compatibility and is actively maintained.
Some kernel packages live in the universe repository, which isn't enabled by default. Enable it and try again:
# Enable universe repository
sudo add-apt-repository universe
# Update package lists
sudo apt-get update
# Try installing again
sudo apt-get install -y linux-image-extra-$(uname -r)Verify the repository is enabled by checking:
grep "^deb.*universe" /etc/apt/sources.list /etc/apt/sources.list.d/*If you're installing Docker and the error persists, the linux-image-extra package is often not strictly required on modern systems. Docker documentation states that on newer Ubuntu versions, these packages are optional.
If you need to proceed without it:
# Continue with Docker installation without linux-image-extra
# (Skip the line that installs linux-image-extra)
# Or manually install just what you need
sudo apt-get install -y docker.ioOnly skip this if you're certain the extra modules aren't needed for your specific use case.
Advanced notes
For specialized kernel environments (AWS, Proxmox, KVM, WSL): These platforms often use custom kernel builds that don't have corresponding linux-image-extra packages in Ubuntu repositories. In these cases, the packages simply aren't available and cannot be installed. Instead, use linux-modules-extra if available, or install the package from source if absolutely necessary.
For Docker specifically: Modern Docker versions (20.10+) support running without the linux-image-extra package on most systems. The package was critical for older Docker versions to enable the AUFS storage driver, but newer versions use overlay2 by default, which doesn't require these extra packages.
For container and WSL environments: When building Docker containers or running in Windows Subsystem for Linux, the expanded kernel version might not match any published packages because you're using the host's kernel. The best practice is to skip installing kernel packages inside containers and rely on the host system to have necessary kernel modules.
Frequently asked questions
- What does "E: Unable to locate package linux-image-$(uname -r)" mean?
- 0-47-generic in the configured repositories. The error means that specific package doesn't exist in any enabled repository, or the repository metadata is outdated. This typically indicates a mismatch between your running kernel and available packages in the repository, or that you're running a custom/specialized kernel for which kernel-extra packages were never published.
- How do I fix "E: Unable to locate package linux-image-$(uname -r)"?
- This error occurs when apt cannot find a linux-image package matching your current kernel version. It commonly happens after a fresh Ubuntu installation, inside containers, or on systems with custom kernels. The fix requires updating your package cache and verifying the correct package exists for your kernel variant.
- What causes "E: Unable to locate package linux-image-$(uname -r)"?
- Package cache is outdated and needs to be refreshed with apt update Your running kernel is a custom variant (AWS, KVM, Microsoft kernel) that doesn't have published linux-image-extra packages You're installing inside a container or WSL where the host kernel version doesn't match repository packages
- Is the "E: Unable to locate package linux-image-$(uname -r)" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐APT Official Documentation
- ๐Ubuntu Kernel FAQ - Frequently asked questions about kernels(Official Docs)
- ๐