1

My machine has got into a state where I cannot apt-get anything.

When I run apt-get upgrade I get

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-generic-lts-xenial : Depends: linux-headers-4.4.0-124-generic but it is not installed
E: Unmet dependencies. Try using -f.

So I do apt-get -f install:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-headers-4.4.0-124 linux-headers-4.4.0-124-generic
The following NEW packages will be installed
  linux-headers-4.4.0-124 linux-headers-4.4.0-124-generic
0 to upgrade, 2 to newly install, 0 to remove and 67 not to upgrade.
8 not fully installed or removed.
Need to get 0 B/10.8 MB of archives.
After this operation, 87.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 1218968 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.4.0-124_4.4.0-124.148~14.04.1_all.deb ...
Unpacking linux-headers-4.4.0-124 (4.4.0-124.148~14.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0-124_4.4.0-124.148~14.04.1_all.deb (--unpack):
 unable to create `/usr/src/linux-headers-4.4.0-124/include/net/irda/irqueue.h.dpkg-new' (while processing `./usr/src/linux-headers-4.4.0-124/include/net/irda/irqueue.h'): No space left on device
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../linux-headers-4.4.0-124-generic_4.4.0-124.148~14.04.1_amd64.deb ...
Unpacking linux-headers-4.4.0-124-generic (4.4.0-124.148~14.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0-124-generic_4.4.0-124.148~14.04.1_amd64.deb (--unpack):
 error creating directory `./usr/src/linux-headers-4.4.0-124-generic/include/config/altera': No space left on device
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/linux-headers-4.4.0-124_4.4.0-124.148~14.04.1_all.deb
 /var/cache/apt/archives/linux-headers-4.4.0-124-generic_4.4.0-124.148~14.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Indicates the disk is full. It has about 3GB and 3.7k inodes free so I don't know if I believe that's really the problem:

root@laptop15:/tmp# df -h
Filesystem           Size  Used Avail Use% Mounted on
udev                 3.9G  4.0K  3.9G   1% /dev
tmpfs                788M  2.3M  786M   1% /run
/dev/sda5             20G   17G  2.0G  90% /
none                 4.0K     0  4.0K   0% /sys/fs/cgroup
none                 5.0M     0  5.0M   0% /run/lock
none                 3.9G   31M  3.9G   1% /run/shm
none                 100M   40K  100M   1% /run/user
/dev/sda1             47M  3.2M   44M   7% /boot/efi
/dev/sda4            200G  119G   72G  63% /home
/dev/sda2            880M   12M  802M   2% /scratch
/dev/loop0            87M   87M     0 100% /snap/core/4571
/dev/loop1            87M   87M     0 100% /snap/core/4407
/dev/loop2            87M   87M     0 100% /snap/core/4486

root@laptop15:/tmp# df -i
Filesystem            Inodes   IUsed    IFree IUse% Mounted on
udev                 1005270     496  1004774    1% /dev
tmpfs                1008404     592  1007812    1% /run
/dev/sda5            1305600 1301852     3748  100% /
none                 1008404      15  1008389    1% /sys/fs/cgroup
none                 1008404       5  1008399    1% /run/lock
none                 1008404     385  1008019    1% /run/shm
none                 1008404      33  1008371    1% /run/user
/dev/sda1                  0       0        0     - /boot/efi
/dev/sda4           13279232  321559 12957673    3% /home
/dev/sda2              65408      14    65394    1% /scratch
/dev/loop0             12831   12831        0  100% /snap/core/4571
/dev/loop1             12817   12817        0  100% /snap/core/4407
/dev/loop2             12819   12819        0  100% /snap/core/4486

I have freed up a load of space already, but it has not helped. A huge amount of the space and inodes are used by old linux-headers, linux-image and linux-image-extra packages which never get deleted. /usr/share contains 4.3GB / 960,871 files pertaining to linux-headers, for example.

apt-get autoremove and apt-get autoremove -f both fail in similar ways. I am stuck being told to free up space, but the thing using up the space doesn't work because (it says) there is no space, even though there is.

How can I get out of this cycle please?

4
  • Have you tried to sudo apt remove --purge the old header installations etc.? Just make sure you're not removing your actual kernel. Running a sudo apt clean afterwards is as well not a bad idea as it looks like you're simply running out of inodes while doing your changes.
    – Videonauth
    May 15, 2018 at 21:17
  • Yes I have tried. apt-get remove --purge fails, prompting me to use -f, like the other apt-get commands. However I think you're right about the inodes - there are 25,000 of them per linux-headers version so 4k is probably not going to be enough even to fix one broken package. Working on it now...
    – Mark Smith
    May 15, 2018 at 21:22
  • Possible duplicate of How do I resize root partition and How to resize partitions?
    – karel
    May 15, 2018 at 21:26
  • No, resizing root partition neither necessary nor sufficient here. Lack of inodes, not space, was the problem
    – Mark Smith
    May 15, 2018 at 21:28

1 Answer 1

1

In such cases I tend to just manually delete some old kernel headers in /usr/src/. In my experience this does not lead to errors when removing the header package later on.

On my machine headers of one kernel are more than 10k files, so 3.7k free inodes don't get you far when installing kernel headers. The low amount of free inodes is definitely a problem on your machine and can often be solved by apt-get autoremove to remove old kernels and their headers.

5
  • 2
    Thanks. apt-get autoremove doesn't work when you're in the unmet-dependencies state unfortunately, but I did basically this -- moved some linux-headers off onto another drive, ran apt-get -f to fix up apt, and now I'll tidy up.
    – Mark Smith
    May 15, 2018 at 21:27
  • How did you manage to use up all the inodes, presumably that means you've got lots of files and a large block size, or millions of little files. My inodes is at 3% with the disk 75% full.
    – pbhj
    May 15, 2018 at 21:54
  • Using up all inodes can happen quite easily if you have a small file system (like 10 GB) and several old kernels lying around. Kernel headers are a lot of small files and if you have 20 kernels or the like lying around you need half a million inodes just for these... May 15, 2018 at 21:59
  • 1
    @pbhj The clue is in the question, which several people seem not to have read to the end :-) Yes there were nearly a million files in linux-headers alone.
    – Mark Smith
    May 16, 2018 at 6:27
  • I assume you're sorted now, askubuntu.com/a/712988/29073 describes fixing a very similar situation. You could boot from a live usb drive if the system is struggling with low space.
    – pbhj
    May 16, 2018 at 9:30

You must log in to answer this question.

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