# Ubuntu – How to fix dpkg error [2]

aptdpkg

Every time I try to install or remove a package, I get this error. I thought maybe it was the hard disk, but a disk check gave me a clean bill of health.

dpkg: unrecoverable fatal error, aborting:
E: Sub-process /usr/bin/dpkg returned an error code (2)
A package failed to install.  Trying to recover:


I tried the solution of removing the listing for this file from the dpkg status file, but to no avail. I tried purging the package but no use. I'm stuck at this point as nothing I can find on Google helps.

### Update:

This is now what the error says:

dpkg: unrecoverable fatal error, aborting:
E: Sub-process /usr/bin/dpkg returned an error code (2)
A package failed to install.  Trying to recover:


### Update2:

Seems the drive has bad sectors, but the reallocated sector count is 0. The drive is relatively old, however, so I expect some issues. I won't be able to replace it immediately, and until then I would still like to be able to keep the system up to date (especially for security reasons).

I noted that there was an issue with coping some md5 checksums related to the package mentioned in the error, but I don't know what to do with those, such as if clearing them would allow dpkg to continue.

• pkexec gedit /var/lib/dpkg/status
• run sudo dpkg --configure -a
• run sudo apt-get -f install just in case.