Broken package, but cannot purge or reinstall it!

My mdadm package is not fully installed, when I run sudo apt-get upgrade, I see the following error message:

Setting up mdadm (3.3-2ubuntu7.1) ...
dpkg: error processing package mdadm (--configure):
subprocess installed post-installation script returned error exit status 20
Errors were encountered while processing:
 mdadm
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried to purge mdadm with dpkg --purge mdadm to reinstall it later, but the system tells me: ubuntu-server is dependent on mdadm.

I already tried the solutions suggested by http://www.iasptk.com/ubuntu-fix-broken-package-best-solution/

sudo apt-get update –fix-missing
sudo dpkg –configure -a
sudo apt-get -f install

I also tried to edit the dpkg-status-file manually and removed the block of information about mdadm, the error still remains.

Any help is very appreciated...


I'm running Ubuntu 16.04 LTS with Linux 4.4.0-24-generic on x86_64.


Alternative 1: Try to reinstall mdadm with apt-get:

sudo apt-get --reinstall install mdadm

Alternative 2: If apt-get doesn't work, install Synaptic with the Software Center.

Go to the search section and type mdadm, right-click and mark it for reinstallation (or try all the other options) and apply the execution.


Alternative 3: If no luck so far, try to reinstall mdadm from the .deb-file directly:

sudo dpkg -i /var/cache/apt/archives/mdadm_version.deb

Use tab-completion, because the .deb-file is additionally named with a version number!

Is there no such package in /var/cache/apt/archives, you may need to download it manually. Take care that you choose the correct Ubuntu Release and the correct Package Version!

sudo dpkg -i path-to-downloaded-package/package-name-version.deb

In case that dpkg doesn't work either, install GDebiPackageInstaller with the Software Center and reinstall the downloaded .deb-file with this program.


In the end, clean-up and update your system:

sudo apt-get autoremove
sudo apt-get autoclean
sudo deborphan | xargs sudo apt-get -y remove --purge
dpkg -l | awk '/^rc/ {print $2}' | xargs sudo dpkg --purge
sudo apt-get clean

sudo apt-get update
sudo apt-get upgrade