"dpkg: unrecoverable fatal error" when trying to update monitoring agent

October 13, 2019 337 views
Monitoring Linux Commands Ubuntu


I’m following the guide to upgrade the monitoring agent https://www.digitalocean.com/docs/monitoring/how-to/upgrade-legacy-agent/

However when I run

sudo apt-get purge do-agent

I get

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

I run the command as instructed and then re-run the first command but that results in

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
The following packages will be REMOVED:
  do-agent* letsencrypt
The following packages will be upgraded:
1 upgraded, 0 newly installed, 2 to remove and 213 not upgraded.
3 not fully installed or removed.
Need to get 0 B/10.2 MB of archives.
After this operation, 63.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 870640 files and directories currently installed.)
Removing letsencrypt (0.19.0-1+ubuntu16.04.1+certbot+1) ...
dpkg: unrecoverable fatal error, aborting:
 fork failed: Cannot allocate memory
E: Sub-process /usr/bin/dpkg returned an error code (2)

Can anyone help?

3 Answers

Hi @Workshed,

You get the error as there is no memory for the process to allocate

dpkg: unrecoverable fatal error, aborting:
 fork failed: Cannot allocate memory
E: Sub-process /usr/bin/dpkg returned an error code (2)

This happens when your server does not have enough memoryor SWAP configured.

Do you by any chance have SWAP configured for these cases? If not, let’s configure it and see if the issue would still appear.

First see if you have swap

sudo swapon --show

If the output is empty, it means that your system does not have swap space enabled.

Creating a Swap File

Start by creating a file which will be used for swap:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

Set the correct permissions by typing so that only the root user can write to the file:

sudo chmod 600 /swapfile

Use the mkswap utility to set up a Linux swap area on the file:

sudo mkswap /swapfile

Activate the swap file:

sudo swapon /swapfile

Now, if you wish for the SWAP file to be there even if you reboot the droplet open the /etc/fstab file:

sudo nano /etc/fstab

and paste the following line:

/swapfile swap swap defaults 0 0

Once you have SWAP configured, please try again to run the command.

Please note this takes 1GB of your droplet’s Disk Space.


Hi @KDSys

Thanks very much for your answer. I didn’t have swap enabled and it gets me further but still hitting errors unfortunately.

The new one is:

dpkg: error processing package debconf-i18n (--configure):
 package debconf-i18n is not ready for configuration
 cannot configure (current status 'half-installed')
E: Sub-process /usr/bin/dpkg returned an error code (1)

Any ideas?

  • Hi @Workshed,

    Okay, so we are making progress, that’s good!

    Please try the following

    sudo dpkg --remove --force-remove-reinstreq --dry-run debconf-i18n

    That’s just a dry-run. I’m not sure what removing debconf-i18n will take with it but run that and see. Assuming it’s not going to screw the whole droplet, run it again without the –dry-run and then you can sudo apt-get install … the packages you need back.


@KDSys unfortunately the dry-run gives us another error:

dpkg: dependency problems prevent removal of debconf-i18n:
 ubuntu-minimal depends on debconf-i18n.

dpkg: error processing package debconf-i18n (--remove):
 dependency problems - not removing
Errors were encountered while processing:
  • Hi @Workshed,

    I see, thanks for coming back.

    Please try with the following

    vi /etc/apt/sources.list

    and add the following bellow

    deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
    # Uncomment line below then 'apt-get update' to enable 'apt-get source'
    deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi

    It’s likely that adding the source back, then apt-get update, then apt-get install -f will be sufficient to fix it


Have another answer? Share your knowledge.