So, it would appear that following the official MongoDB installation instructions when installing on Debian - you're heading for a world of pain. Firstly, it didn't install correctly so now - i'm trying to remove all installed MongoDB packages so that I can start from scratch.

Frustratingly, because it didn't install cleanly (presumably), it won't uninstall.

Originally, I installed using the instructions here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/

Currently, i've managed to remove every package apart from mongodb-org-server which, just won't go.

An attempted removal results in the following:

user@host:/$ sudo apt-get remove mongodb-org-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 23.9 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 31030 files and directories currently installed.)
Removing mongodb-org-server ...
invoke-rc.d: unknown initscript, /etc/init.d/mongod not found.
dpkg: error processing mongodb-org-server (--remove):
 subprocess installed pre-removal script returned error exit status 100
invoke-rc.d: unknown initscript, /etc/init.d/mongod not found.
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 100
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

This is causing me untold problems, any ideas how I can properly and cleanly get rid of MongoDB now?

Contents of /var/lib/dpkg/info/mongodb-org-server.prerm:

set -e
# Automatically added by dh_installinit
if [ -e "/etc/init/mongod.conf" ]; then
        invoke-rc.d mongod stop || exit $?
# End automatically added section


  • 1
    This is probably best done interactively (based on past experience). Care to hop into the chat room? You can ping me from there. Though, actually, a simple workaround might be to create an empty /etc/init.d/mongod. Try that first. Commented Feb 28, 2015 at 23:59
  • 1
    Also, post the prerm script for mongodb-org-server, namely /var/lib/dpkg/info/mongodb-org-server.prerm. Commented Mar 1, 2015 at 0:15

1 Answer 1


The mongodb-org-server package appears to be broken. The prerm script mongodb-org-server.prerm is trying to run the script /etc/init.d/mongod as part of invoke-rc.d. As the name suggests, the prerm script is run by dpkg prior to removal of the mongodb-org-server package.

The poster said the server was not running, so the prerm script is therefore a no-op.

So, the obvious thing to do is to comment out the relevant part of mongodb-org-server.prerm, namely:

if [ -e "/etc/init/mongod.conf" ]; then
        invoke-rc.d mongod stop || exit $?

and then run the removal again. Though I would recommend

apt-get purge mongodb-org-server

and report a bug against this package if possible.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .