So some time ago, I dual booted my computer with Windows 10 and Linux Mint 18:Sarah. Windows 10 created a hiberfil.sys file by default (to save system snapshots or whatever?) as I used Windows reboot feature. The problem that that created was that it made it so that my computer did not recognize grub which manages my system partitions and immediately booted into Windows.

I resolved this issue by using "Boot-Repair", so now I can access both system partitions. But then THAT broke apt-get so now I can't install ANY software with sudo apt-get install ___ or perform a sudo apt-get upgrade

What's broken is my grub, or well, the system expects another version of grub known as grub2-common, but instead it has 2.02~beta2-36ubuntu3.1 version of grub installed.

So now then I will show you the output of when I run a few commands:

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 grub-pc : Depends: grub2-common (= 2.02~beta2-36ubuntu3.2) but 2.02~beta2-36ubuntu3.1 is installed
 grub2-common : Depends: grub-common (= 2.02~beta2-36ubuntu3.1) but 2.02~beta2-36ubuntu3.2 is installed
E: Unmet dependencies. Try using -f.

So I will try that recommended command:

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  grub2-common
The following packages will be upgraded:
  grub2-common
1 upgraded, 0 newly installed, 0 to remove and 244 not upgraded.
3 not fully installed or removed.
Need to get 0 B/511 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] yes
(Reading database ... 288732 files and directories currently installed.)
Preparing to unpack .../grub2-common_2.02~beta2-36ubuntu3.2_amd64.deb ...
Unpacking grub2-common (2.02~beta2-36ubuntu3.2) over (2.02~beta2-36ubuntu3.1) ...
dpkg: error processing archive /var/cache/apt/archives/grub2-common_2.02~beta2-36ubuntu3.2_amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/grub-install', which is also in package lupin-support 0.57
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/grub2-common_2.02~beta2-36ubuntu3.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

How about when I try to install software? I'm trying to install an anti-virus software.

sudo apt-get install clamav
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 clamav : Depends: clamav-freshclam (>= 0.99.2+dfsg) but it is not going to be installed or
                   clamav-data
          Depends: libclamav7 (>= 0.99~rc1) but it is not going to be installed
 grub-pc : Depends: grub2-common (= 2.02~beta2-36ubuntu3.2) but 2.02~beta2-36ubuntu3.1 is to be installed
 grub2-common : Depends: grub-common (= 2.02~beta2-36ubuntu3.1) but 2.02~beta2-36ubuntu3.2 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Again, the same issue with grub.

Finally, one more comment I'd like to make: I cannot use sudo apt-get to install anything ... which includes updating grub repositories!

Perhaps, you wonder what the state of aptitude is?

sudo aptitude install clamav
The following NEW packages will be installed:
  clamav clamav-base{a} clamav-freshclam{a} libclamav7{a} libllvm3.6v5{ab} 
The following partially installed packages will be configured:
  grub-pc{b} python-pyaudio python-simplejson 
0 packages upgraded, 5 newly installed, 0 to remove and 245 not upgraded.
Need to get 9,109 kB of archives. After unpacking 36.8 MB will be used.
The following packages have unmet dependencies:
 grub2-common : Depends: grub-common (= 2.02~beta2-36ubuntu3.1) but 2.02~beta2-36ubuntu3.2 is installed.
 grub-pc : Depends: grub2-common (= 2.02~beta2-36ubuntu3.2) but 2.02~beta2-36ubuntu3.1 is installed and it is kept back.
 libllvm3.6v5 : Conflicts: libllvm3.6 but 1:3.6-2ubuntu1~trusty1 is installed.
                Conflicts: libllvm3.6:i386 but 1:3.6-2ubuntu1~trusty1 is installed.
The following actions will resolve these dependencies:

     Remove the following packages:
1)     grub-gfxpayload-lists       
2)     grub-pc                     
3)     grub2-common                
4)     libllvm3.6                  
5)     libllvm3.6:i386             



Accept this solution? [Y/n/q/?] Y
The following NEW packages will be installed:
  clamav clamav-base{a} clamav-freshclam{a} libclamav7{a} libllvm3.6v5{a} 
The following packages will be REMOVED:
  grub-gfxpayload-lists{a} grub-pc{a} grub2-common{a} libllvm3.6{a} libllvm3.6:i386{a} 
The following partially installed packages will be configured:
  python-pyaudio python-simplejson 
0 packages upgraded, 5 newly installed, 5 to remove and 244 not upgraded.
Need to get 9,109 kB of archives. After unpacking 29.9 MB will be freed.
Do you want to continue? [Y/n/?] Y
[ ERR] Writing extended state information
E: Failed to execute process to save dpkg selections, dpkg or trying to execute it exited with status/errno: 2
E: failed to save selections to dpkg database

Aptitude seems to get a little further. But after selecting yes twice, it still fails to install my software.

How can I sort out the mess?

  • Welcome to U&L SE. Less is more, dumping lots of output does not necessarily serve to find the answer. Anyway: a reliable and easy to follow (but not the best) way to get out of this is to save your personal data and to repair the distribution installation (the installation media of most distributions provide an according function). Or you re-install the distribution from scratch, this will re-establish grub as boot loader. – countermode Oct 13 '16 at 20:55
  • sudo apt-get update does it solves your problem? – Rui F Ribeiro Oct 15 '16 at 3:29
  • No, it does not. What it does is collect and read some packages from Linux Mint. That is all it does. – xyz123 Oct 15 '16 at 4:43
  • The command sudo apt-get -f install faild, because of /usr/sbin/grub-install being also in package lupin-support. So I suggest to try removing lupin-support, then fixing the system and finally reinstalling lupin-support. But I don't use Linux Mint, so I can't guarantee that it works. – David Nov 8 '17 at 16:30

Had this error too:

E: Failed to execute process to save dpkg selections, dpkg or 
trying to execute it exited with status/errno: 2

Ok, this is necroposting but I solved it the following way:

  1. create backup of current apt state (too keep it around).
  2. copy backup copy to current.
  3. apt-get update
  4. remove above created backup.

command listing:

root@host# cd /var/lib/dpkg
root@host# cp status status.backup
root@host# cp status-old status-old.backup
root@host# cp status-old status
root@host# apt-get update
root@host# apt-get upgrade
root@host# rm status.backup
root@host# rm status-old.backup

Why the heck the apt database got corrupted is beyond my knowledge, some chars appeared to have been mangled (i.e. a "c" became "@" and the like). I guess some bad RAM module might cause this but they all tested ok.

  • I don't think it's a corrupted database in this case. The problem of xyz123 is about unmet dependencies. – David Nov 8 '17 at 16:00
  • The error [ ERR] Writing extended state information is usually because of broken database. See his last line in the console log. – xtra Nov 8 '17 at 16:59

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.