web-dev-qa-db-fra.com

apt-get ne peut pas supprimer automatiquement les paquets remplissant les inodes

Un ancien serveur Ubuntu 10.04 se plaint de dépendances non satisfaites. Quand je lance apt-get -f install Je reçois un message "Il n'y a plus d'espace sur l'appareil":

$ Sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-2.6.32-61-server linux-headers-2.6.32-56-server linux-headers-2.6.32-44-server
  linux-headers-2.6.32-65-server linux-headers-2.6.32-53-server linux-headers-2.6.32-48-server
  linux-headers-2.6.32-62-server linux-headers-2.6.32-57-server linux-headers-2.6.32-50-server
  linux-headers-2.6.32-45-server linux-headers-2.6.32-66-server linux-headers-2.6.32-54-server
  linux-headers-2.6.32-49-server linux-headers-2.6.32-43 linux-headers-2.6.32-44 linux-headers-2.6.32-50
  linux-headers-2.6.32-45 linux-headers-2.6.32-51 linux-headers-2.6.32-46 linux-headers-2.6.32-52 linux-headers-2.6.32-47
  linux-headers-2.6.32-53 linux-headers-2.6.32-48 linux-headers-2.6.32-54 linux-headers-2.6.32-49 linux-headers-2.6.32-60
  linux-headers-2.6.32-55 linux-headers-2.6.32-61 linux-headers-2.6.32-56 linux-headers-2.6.32-62 linux-headers-2.6.32-57
  linux-headers-2.6.32-58 linux-headers-2.6.32-64 linux-headers-2.6.32-65 linux-headers-2.6.32-66 linux-headers-2.6.32-67
  linux-headers-2.6.32-58-server linux-headers-2.6.32-51-server linux-headers-2.6.32-46-server
  linux-headers-2.6.32-67-server linux-headers-2.6.32-60-server linux-headers-2.6.32-55-server
  linux-headers-2.6.32-43-server linux-headers-2.6.32-64-server linux-headers-2.6.32-52-server
  linux-headers-2.6.32-47-server
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-headers-2.6.32-71 linux-headers-2.6.32-71-server
The following NEW packages will be installed:
  linux-headers-2.6.32-71 linux-headers-2.6.32-71-server
0 upgraded, 2 newly installed, 0 to remove and 43 not upgraded.
4 not fully installed or removed.
Need to get 0B/11.0MB of archives.
After this operation, 85.3MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
(Reading database ... 469386 files and directories currently installed.)
Unpacking linux-headers-2.6.32-71 (from .../linux-headers-2.6.32-71_2.6.32-71.138_all.deb) ...
dpkg: error processing /var/cache/apt/archives/linux-headers-2.6.32-71_2.6.32-71.138_all.deb (--unpack):
 unable to create `/usr/src/linux-headers-2.6.32-71/Arch/arm/include/asm/limits.h.dpkg-new' (while processing `./usr/src/linux-headers-2.6.32-71/Arch/arm/include/asm/limits.h'): No space left on device
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: subprocess paste killed by signal (Broken pipe)
Unpacking linux-headers-2.6.32-71-server (from .../linux-headers-2.6.32-71-server_2.6.32-71.138_AMD64.deb) ...
dpkg: error processing /var/cache/apt/archives/linux-headers-2.6.32-71-server_2.6.32-71.138_AMD64.deb (--unpack):
 unable to create `/usr/src/linux-headers-2.6.32-71-server/include/config/dummy/console.h.dpkg-new' (while processing `./usr/src/linux-headers-2.6.32-71-server/include/config/dummy/console.h'): No space left on device
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/linux-headers-2.6.32-71_2.6.32-71.138_all.deb
 /var/cache/apt/archives/linux-headers-2.6.32-71-server_2.6.32-71.138_AMD64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

En fait, les systèmes semblent manquer d'Inodes:

$ df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/sda1             498736  493560    5176   99% /
none                   62559     587   61972    1% /dev
none                   63152       1   63151    1% /dev/shm
none                   63152      23   63129    1% /var/run
none                   63152       3   63149    1% /var/lock
none                   63152       1   63151    1% /lib/init/rw
none                  498736  493560    5176   99% /var/lib/ureadahead/debugfs

Après quelques recherches, j'ai trouvé un nombre excessif de fichiers dans /usr/src:

$ Sudo find /usr/src -type f | wc -l
317741

Ce sont tous les contenus de linux-headers-* paquets:

$ ls -la /usr/src
total 192
drwxrwsr-x 48 root src  4096 2015-01-20 15:15 .
drwxr-xr-x 10 root root 4096 2011-03-02 17:11 ..
drwxr-xr-x 24 root root 4096 2012-09-26 11:33 linux-headers-2.6.32-43
drwxr-xr-x  7 root root 4096 2012-09-26 11:33 linux-headers-2.6.32-43-server
drwxr-xr-x 24 root root 4096 2012-10-12 06:38 linux-headers-2.6.32-44
drwxr-xr-x  7 root root 4096 2012-10-12 06:39 linux-headers-2.6.32-44-server
drwxr-xr-x 24 root root 4096 2013-02-22 06:51 linux-headers-2.6.32-45
drwxr-xr-x  7 root root 4096 2013-02-22 06:52 linux-headers-2.6.32-45-server
drwxr-xr-x 24 root root 4096 2013-04-19 06:30 linux-headers-2.6.32-46
drwxr-xr-x  7 root root 4096 2013-04-19 06:30 linux-headers-2.6.32-46-server
drwxr-xr-x 24 root root 4096 2013-05-15 06:42 linux-headers-2.6.32-47
drwxr-xr-x  7 root root 4096 2013-05-15 06:42 linux-headers-2.6.32-47-server
drwxr-xr-x 24 root root 4096 2013-06-14 06:34 linux-headers-2.6.32-48
drwxr-xr-x  7 root root 4096 2013-06-14 06:34 linux-headers-2.6.32-48-server
drwxr-xr-x 24 root root 4096 2013-07-04 06:39 linux-headers-2.6.32-49
drwxr-xr-x  7 root root 4096 2013-07-04 06:39 linux-headers-2.6.32-49-server
drwxr-xr-x 24 root root 4096 2013-07-30 06:29 linux-headers-2.6.32-50
drwxr-xr-x  7 root root 4096 2013-07-30 06:29 linux-headers-2.6.32-50-server
drwxr-xr-x 24 root root 4096 2013-09-07 06:28 linux-headers-2.6.32-51
drwxr-xr-x  7 root root 4096 2013-09-07 06:28 linux-headers-2.6.32-51-server
drwxr-xr-x 24 root root 4096 2013-09-30 06:41 linux-headers-2.6.32-52
drwxr-xr-x  7 root root 4096 2013-09-30 06:41 linux-headers-2.6.32-52-server
drwxr-xr-x 24 root root 4096 2013-11-08 06:46 linux-headers-2.6.32-53
drwxr-xr-x  7 root root 4096 2013-11-08 06:46 linux-headers-2.6.32-53-server
drwxr-xr-x 24 root root 4096 2013-12-03 06:47 linux-headers-2.6.32-54
drwxr-xr-x  7 root root 4096 2013-12-03 06:47 linux-headers-2.6.32-54-server
drwxr-xr-x 24 root root 4096 2014-01-03 06:47 linux-headers-2.6.32-55
drwxr-xr-x  7 root root 4096 2014-01-03 06:47 linux-headers-2.6.32-55-server
drwxr-xr-x 24 root root 4096 2014-02-19 06:40 linux-headers-2.6.32-56
drwxr-xr-x  7 root root 4096 2014-02-19 06:40 linux-headers-2.6.32-56-server
drwxr-xr-x 24 root root 4096 2014-03-05 06:34 linux-headers-2.6.32-57
drwxr-xr-x  7 root root 4096 2014-03-05 06:34 linux-headers-2.6.32-57-server
drwxr-xr-x 24 root root 4096 2014-05-06 06:45 linux-headers-2.6.32-58
drwxr-xr-x  7 root root 4096 2014-05-06 06:46 linux-headers-2.6.32-58-server
drwxr-xr-x 24 root root 4096 2014-05-27 06:54 linux-headers-2.6.32-60
drwxr-xr-x  7 root root 4096 2014-05-27 06:54 linux-headers-2.6.32-60-server
drwxr-xr-x 24 root root 4096 2014-06-06 06:47 linux-headers-2.6.32-61
drwxr-xr-x  7 root root 4096 2014-06-06 06:47 linux-headers-2.6.32-61-server
drwxr-xr-x 24 root root 4096 2014-07-06 06:28 linux-headers-2.6.32-62
drwxr-xr-x  7 root root 4096 2014-07-06 06:28 linux-headers-2.6.32-62-server
drwxr-xr-x 24 root root 4096 2014-07-18 06:29 linux-headers-2.6.32-64
drwxr-xr-x  7 root root 4096 2014-07-18 06:29 linux-headers-2.6.32-64-server
drwxr-xr-x 24 root root 4096 2014-08-29 06:49 linux-headers-2.6.32-65
drwxr-xr-x  7 root root 4096 2014-08-29 06:49 linux-headers-2.6.32-65-server
drwxr-xr-x 24 root root 4096 2014-09-23 06:40 linux-headers-2.6.32-66
drwxr-xr-x  7 root root 4096 2014-09-23 06:40 linux-headers-2.6.32-66-server
drwxr-xr-x 24 root root 4096 2014-10-09 06:48 linux-headers-2.6.32-67
drwxr-xr-x  7 root root 4096 2014-10-09 06:48 linux-headers-2.6.32-67-server

Mais si je demande leur retrait:

$ Sudo apt-get autoremove
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:
  linux-headers-virtual: Depends: linux-headers-2.6.32-71-server but it is not installed or
                                  linux-headers-2.6.32-71-generic-pae but it is not installable
E: Unmet dependencies. Try using -f.

Ou supprimer un package spécifique:

$ Sudo apt-get remove linux-headers-2.6.32-43
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:
  linux-headers-2.6.32-43-server: Depends: linux-headers-2.6.32-43 but it is not going to be installed
  linux-headers-virtual: Depends: linux-headers-2.6.32-71-server but it is not going to be installed or
                                  linux-headers-2.6.32-71-generic-pae but it is not installable
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Ce qui me ramène à la case départ. Comment rompre ce cycle? Comment puis-je supprimer ces anciens fichiers afin que apt-get peut faire son travail?

Mise à jour : psusi suggère la suppression directe de ces paquets avec dpkg. Voici le résultat:

$ Sudo dpkg -r linux-headers-2.6.32-43
dpkg: dependency problems prevent removal of linux-headers-2.6.32-43:
 linux-headers-2.6.32-43-server depends on linux-headers-2.6.32-43.
dpkg: error processing linux-headers-2.6.32-43 (--remove):
 dependency problems - not removing
Errors were encountered while processing:
 linux-headers-2.6.32-43
1
Luís de Sousa

apt-get insiste pour réparer tout paquet cassé avant de faire quoi que ce soit d'autre. Utilisation dpkg -r pkgname pour supprimer directement les packages. Après les avoir effacés, la course apt-get install -f pour réparer les paquets cassés.

3
psusi