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.

  • Short question: Is your problem still existing? I have a possible solution that could work for you. – Neni Jul 4 '16 at 19:38
  • Yes. this problem still exists. – huijing Jul 5 '16 at 3:21
  • I added some alternatives in the answer, give it another try... – Neni Jul 6 '16 at 12:42

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
  • sudo apt-get autoremove cannot proceed because of the same error as listed above. I did not have deborphan installed so I tried sudo apt-get install deborphan but it couldn't complete because dpkg errored out trying to process mdadm – huijing Jun 13 '16 at 16:14
  • what happens when you run: sudo apt-get --reinstall install mdadm – Neni Jun 13 '16 at 16:25
  • E: Internal Error, No file name for mdadm:amd64 is the error message – huijing Jun 13 '16 at 16:27
  • and 'sudo apt-get -f install mdadm'? – Neni Jun 13 '16 at 17:07
  • the original error message 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) – huijing Jun 13 '16 at 17:23

The 'clean-up' commands in previous answer include some things which are potentially dangerous, especially piping to xargs dpkg --purge without inspecting the packages to be removed.

In any case, this whole 'clean-up' is not going to help. Look in /var/lib/dpkg/info/mdadm.postinst. I'm afraid you'll have to examine the script, potentially running segments of it manually, to see how it is failing. Often, these scripts just stop a service or remove a few files, which you can do manually. If you think all the scripts actions are avoidable, you can remove the script and try to reinstall the package again.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.