Saturday, June 10, 2017

updates - Error while updating Ubuntu - The package system is broken



This is for Ubuntu 16.04 LTS
I got a prompt:





Updated software is available for this computer. Do you want to
install it now?




When I go ahead with update it gives me an error:



The package system is broken -
Check if you are using third party repositories. If so disable them, since they are a common source of problems.
Furthermore run the following command in a Terminal: apt-get install -f



How can I find out which third party repositories am I using?



Based on inputs provided below, I tried below commands. Also mentioned the output -



sudo apt -f install




dpkg: error: reading package info file '/var/lib/dpkg/status': Input/output error
E: Sub-process /usr/bin/dpkg returned an error code (2)





sudo dpkg --configure -a




dpkg: error: reading package info file '/var/lib/dpkg/status': Input/output error




sudo apt update





Reading package lists... Error!
E: Read error - read (5: Input/output error)
W: You may want to run apt-get update to correct these problems
E: The package cache file is corrupted




Finally after much troubleshooting I found the issue and the solution to resolve it. Writing all findings here so that it can help others and may not need to do the lengthy troubleshooting that I had to do.



Root cause:




Issue, if I am not wrong, was with the disk space. During one of the recent upgrades my disk space got full and 0% was available for upgrades. Because of this /var/lib/dpkg/status is corrupted. And after that it just refuse to upgrade, install or remove any application and gave the error mentioned above.



Steps to resolve the issue:




  1. First, fix the reason behind mess. Cleaned up few old and unwanted files to free up disk space. Now I have almost 5% available disk space which should be sufficient for normal behaviour and complete the original upgrade which failed because of insufficient disk space.

  2. Now, repair the damage it caused. Correct file /var/lib/dpkg/status. Here, as usual, experts and their contribution on this forum helped me to get the previous known good status file from /var/backups. Every time you do an install or a update, the status file is saved to a gzipped backup under /var/backups. Refer here for complete details on this. Below are the commands that I used -





~$ sudo mv /var/lib/dpkg/status /var/lib/dpkg/status_bkup



~$ sudo cp /var/backups/dpkg.status.2.gz /var/lib/dpkg/



~$ sudo gunzip -d /var/lib/dpkg/dpkg.status.2.gz



~$ mv /var/lib/dpkg/dpkg.status.2 /var/lib/dpkg/status



~$ sudo apt-get update





voila!! it completed the update without errors faced earlier.




  1. Now, to complete the update and ensure that the problem is resolved; try update or installing a new application-




~$ sudo apt-get -f install




Fetched 14.3 MB in 15s (935 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
dpkg: error: parsing file '/var/lib/dpkg/status' near line 18299 package >'libgdk-pixbuf2.0-common':
end of file during value of field 'Original-Maintainer' (missing final >newline)
E: Sub-process /usr/bin/dpkg returned an error code (2)





  1. Somehow, status file was again modified and a new error was introduced. Since now I know what is status file and how to troubleshoot is, I understood that this is because of a syntax error in status file. It was easy to identify that '>' is missing for one of the packages at end. Corrected the status file to include '>' at end.



  2. Try again and it was successful this time!




Cheers,



Anirudha


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...