Keywords: Ubuntu | apt-get | 404 error | package management | old releases repository
Abstract: This article provides an in-depth analysis of the root causes behind 404 errors encountered with the apt-get command in Ubuntu systems, particularly focusing on end-of-life non-LTS versions. Through detailed examination of package management mechanisms and repository architecture, it offers a comprehensive solution for migrating from standard repositories to old releases repositories, including steps for backing up configuration files, modifying sources.list, and updating package indexes, while emphasizing the security importance of upgrading to LTS versions.
Problem Phenomenon and Error Analysis
In Ubuntu 13.10 (Saucy Salamander) systems, when users attempt to install packages via the sudo apt-get install command, the system returns a series of 404 errors. Specifically, the system fails to retrieve package files from official repositories such as http://us.archive.ubuntu.com/ubuntu/ and http://security.ubuntu.com/ubuntu/.
Error logs indicate that URLs like http://us.archive.ubuntu.com/ubuntu/pool/main/t/tmux/tmux_1.8-4_amd64.deb return 404 status codes, signifying that the requested resources do not exist on the server. This phenomenon occurs not only during individual package installations but also when executing sudo apt-get update to refresh package indexes, resulting in numerous 404 errors.
Root Cause: End-of-Life Ubuntu Versions
Ubuntu 13.10 is a non-LTS (Long-Term Support) version. According to Ubuntu's release cycle, non-LTS versions typically have only 9 months of support. When a version reaches its end of life, official maintenance of the corresponding software repositories ceases, and resources are removed from the main repositories.
From a technical architecture perspective, the APT package management system relies on software source addresses configured in the /etc/apt/sources.list file. When resources corresponding to these addresses are removed, any attempts to access them result in 404 errors. This phenomenon is not due to network connectivity issues or temporary server failures but is an inevitable consequence of version lifecycle management.
Solution: Migration to Old Releases Repository
For Ubuntu versions that have reached end-of-life, the most effective solution is to migrate the software source configuration from standard repositories to the old releases repository.
Step 1: Backup Current Configuration
Before making any modifications, first backup the current software sources configuration file:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backupThis step ensures quick restoration of the original configuration in case of unexpected issues.
Step 2: Modify Software Source Addresses
Open the /etc/apt/sources.list file with a text editor and replace all occurrences of standard repository addresses with old releases repository addresses.
Original address pattern:
http://us.archive.ubuntu.com/ubuntu/Replace with:
http://old-releases.ubuntu.com/ubuntu/Similarly, security update repositories need corresponding modifications:
http://security.ubuntu.com/ubuntu/Replace with:
http://old-releases.ubuntu.com/ubuntu/For users in non-US regions, adjust repository addresses according to localization settings. For example, French users may need to replace fr.archive.ubuntu.com with old-releases.ubuntu.com.
Step 3: Update Package Index
After completing address replacements, execute the package index update:
sudo apt-get updateThe system will now retrieve package information from old-releases.ubuntu.com, typically completing the update process successfully.
Additional Solutions and Considerations
Beyond the primary repository migration solution, other possible approaches include:
System Upgrade Solution: Executing the sudo do-release-upgrade command can upgrade the system to a supported version, though this method requires stable network connectivity and may involve significant system changes.
Docker Environment Special Handling: In Docker build environments, due to image caching mechanisms, it may be necessary to prefix each apt-get command with apt-get update to ensure retrieval of the latest repository information.
Security Warnings and Best Practices
It is crucial to emphasize that migrating software sources to the old releases repository is only a temporary solution. Using end-of-life operating system versions poses serious security risks:
• Inability to receive latest security patches and vulnerability fixes
• Potential exposure to known security threats
• Unsuitable for production environment deployment
Users are strongly advised to upgrade to current LTS versions, such as Ubuntu 20.04 LTS or newer. LTS versions provide 5 years of standard support and additional 5 years of extended security maintenance, ensuring long-term system stability and security.
In-Depth Technical Principles
Ubuntu's package management system employs a distributed repository architecture. When a version reaches end-of-life, the maintenance team migrates corresponding packages from main repositories to the dedicated old-releases.ubuntu.com server. This migration process includes:
• Ceasing updates and maintenance for old version packages
• Transferring existing package files to archive servers
• Updating repository metadata to reflect resource location changes
When the APT client requests packages, it first queries Sources and Packages index files, then downloads specific .deb package files based on information in the indexes. When resource locations pointed to by index files become invalid, 404 errors occur.
By modifying the sources.list configuration file, the APT client's query server address is effectively redirected to point to archive servers that still contain packages for the corresponding version, thereby resolving the resource not found issue.