14

I want to do updates, but it seems like my disk is full. I tried:

sudo apt-get install -f

but it gave me the following output:

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:
checkbox-ng fonts-inconsolata gir1.2-gconf-2.0 ko.tex-extra-hlfont
latex-sanskrit libarchive-extract-perl libboost-date-time1.54.0
libboost-system1.54.0 libcmis-0.4-4 libcolamd2.8.0 libept1.4.12 libglamor0
libglew1.10 libglewmx1.10 libgnome-desktop-3-7 libgphoto2-port10 libilmbase6
libimobiledevice4 libintl-perl libisl10 libllvm3.4 liblog-message-perl
liblog-message-simple-perl libmagick++5 libmagickcore5 libmagickcore5-extra
libmagickwand5 libmbim-glib0 libmodule-pluggable-perl libmodule-runtime-perl
libntdb1 libopenexr6 liborcus-0.6-0 libparams-classify-perl libpocketsphinx1
libpod-latex-perl libpoppler44 libprocps3 libprotobuf8 libprotoc8
libqmi-glib0 libqpdf13 libqt5qml-graphicaleffects libqt5sensors5
libqt5webkit5-qmlwebkitplugin libraw9 librhythmbox-core8 libsphinxbase1
libspice-server1 libsystemd-journal0 libsystemd-login0 libterm-ui-perl
libtext-soundex-perl libthumbnailer0 libunityvoice1 libupstart1 libxdelta2
libxtables10 linux-headers-3.13.0-29 linux-headers-3.13.0-29-generic
linux-headers-3.13.0-62 linux-headers-3.13.0-62-generic
linux-headers-3.13.0-95 linux-headers-3.13.0-95-generic
linux-headers-4.4.0-36 linux-headers-4.4.0-36-generic linux-headers-4.4.0-37
linux-headers-4.4.0-37-generic linux-headers-4.4.0-38
linux-headers-4.4.0-38-generic linux-headers-4.4.0-39
linux-headers-4.4.0-39-generic linux-headers-4.4.0-40
linux-headers-4.4.0-40-generic linux-headers-4.4.0-41
linux-headers-4.4.0-41-generic linux-headers-4.4.0-44
linux-headers-4.4.0-44-generic linux-headers-4.4.0-46
linux-headers-4.4.0-46-generic linux-headers-4.4.0-49
linux-headers-4.4.0-49-generic linux-headers-4.4.0-51
linux-headers-4.4.0-51-generic linux-headers-4.4.0-52
linux-headers-4.4.0-52-generic linux-headers-4.4.0-53
linux-image-3.11.0-19-generic linux-image-4.4.0-36-generic
linux-image-4.4.0-37-generic linux-image-4.4.0-38-generic
linux-image-4.4.0-39-generic linux-image-4.4.0-40-generic
linux-image-4.4.0-41-generic linux-image-4.4.0-44-generic
linux-image-4.4.0-46-generic linux-image-4.4.0-49-generic
linux-image-4.4.0-51-generic linux-image-4.4.0-52-generic
linux-image-extra-3.11.0-19-generic linux-image-extra-4.4.0-36-generic
linux-image-extra-4.4.0-37-generic linux-image-extra-4.4.0-38-generic
linux-image-extra-4.4.0-39-generic linux-image-extra-4.4.0-40-generic
linux-image-extra-4.4.0-41-generic linux-image-extra-4.4.0-44-generic
linux-image-extra-4.4.0-46-generic linux-image-extra-4.4.0-49-generic
linux-image-extra-4.4.0-51-generic linux-image-extra-4.4.0-52-generic m-tx
musixtex perlmagick pmx python-commandnotfound python-gdbm python-imaging-tk
python-ntdb python3-checkbox qml-module-qtquick-dialogs
qml-module-qtquick-localstorage qml-module-qtquick-privatewidgets
qml-module-ubuntu-ui-extras-browser qtdeclarative5-dialogs-plugin
qtdeclarative5-localstorage-plugin qtdeclarative5-privatewidgets-plugin
qtdeclarative5-qtfeedback-plugin
qtdeclarative5-ubuntu-ui-extras-browser-plugin
qtdeclarative5-ubuntu-ui-extras-browser-plugin-assets
qtdeclarative5-window-plugin sphinx-voxforge-hmm-en sphinx-voxforge-lm-en
swath ubuntu-core-launcher unity-scope-audacious unity-scope-clementine
unity-scope-gmusicbrowser unity-scope-gourmet unity-scope-guayadeque
unity-scope-musique unity-voice-service xdelta
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-headers-4.4.0-57 linux-headers-4.4.0-57-generic
The following NEW packages will be installed:
linux-headers-4.4.0-57 linux-headers-4.4.0-57-generic
0 upgraded, 2 newly installed, 0 to remove and 63 not upgraded.
2 not fully installed or removed.
Need to get 10,7 MB of archives.
After this operation, 77,8 MB of additional disk space will be used.
Do you want to continue? [O/n] o
Get:1 http://fr.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-57 all 4.4.0-57.78 [9 949 kB]
Get:2 http://fr.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-57-generic amd64 4.4.0-57.78 [779 kB]
Fetched 10,7 MB in 17s (610 kB/s)
(Reading database ... 1254217 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.4.0-57_4.4.0-57.78_all.deb ...
Unpacking linux-headers-4.4.0-57 (4.4.0-57.78) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers 4.4.0-57_4.4.0-57.78_all.deb (--unpack):
unable to create '/usr/src/linux-headers-4.4.0-57/include/linux/capability.h.dpkg-new' (while processing './usr/src/linux-headers-4.4.0-57/include/linux/capability.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-57-generic_4.4.0-57.78_amd64.deb ...
Unpacking linux-headers-4.4.0-57-generic (4.4.0-57.78) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-4.4.0-57-generic_4.4.0-57.78_amd64.deb (--unpack):
error creating directory './usr/src/linux-headers-4.4.0-57-generic/include/config/cross/memory': 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-57_4.4.0-57.78_all.deb
 /var/cache/apt/archives/linux-headers-4.4.0-57-generic_4.4.0-57.78_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

df gives this output:

 Filesystem     1K-blocks     Used Available Use% Mounted on
udev             1941224        0   1941224   0% /dev
tmpfs             392292     6416    385876   2% /run
/dev/sda5       20027728 17160304   1827020  91% /
tmpfs            1961444     2952   1958492   1% /dev/shm
tmpfs               5120        4      5116   1% /run/lock
tmpfs            1961444        0   1961444   0% /sys/fs/cgroup
/dev/sda6      139057128 45511572  86458812  35% /home
cgmfs                100        0       100   0% /run/cgmanager/fs
tmpfs             392292      108    392184   1% /run/user/1001

sudo fdisk -l gives this:

Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 (edit: 15 more ram devices with the same size)

Disk /dev/sda: 232,9 GiB, 250059350016 bytes, 488397168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe0a42c14

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1              63     80324     80262  39,2M de Dell Utility
/dev/sda2  *        81920   1622015   1540096   752M  7 HPFS/NTFS/exFAT
/dev/sda3         1622016 160710655 159088640  75,9G  7 HPFS/NTFS/exFAT
/dev/sda4       160712702 488394751 327682050 156,3G  5 Extended
/dev/sda5       160712704 201673641  40960938  19,5G 83 Linux
/dev/sda6       201674752 484489205 282814454 134,9G 83 Linux
/dev/sda7       484489216 488394751   3905536   1,9G 82 Linux swap / Solaris

ls /usr/src output:

bcmwl-6.30.223.248+bdcom         linux-headers-3.13.0-66-generic  linux-headers-3.13.0-86-generic  linux-headers-3.8.0-35          linux-headers-4.4.0-44-generic
linux-headers-3.13.0-29          linux-headers-3.13.0-67          linux-headers-3.13.0-87          linux-headers-4.4.0-36          linux-headers-4.4.0-46
linux-headers-3.13.0-29-generic  linux-headers-3.13.0-67-generic  linux-headers-3.13.0-87-generic  linux-headers-4.4.0-36-generic  linux-headers-4.4.0-46-generic
linux-headers-3.13.0-46          linux-headers-3.13.0-74          linux-headers-3.13.0-88          linux-headers-4.4.0-37          linux-headers-4.4.0-49
linux-headers-3.13.0-46-generic  linux-headers-3.13.0-74-generic  linux-headers-3.13.0-88-generic  linux-headers-4.4.0-37-generic  linux-headers-4.4.0-49-generic
linux-headers-3.13.0-62          linux-headers-3.13.0-78          linux-headers-3.13.0-93          linux-headers-4.4.0-38          linux-headers-4.4.0-51
linux-headers-3.13.0-62-generic  linux-headers-3.13.0-78-generic  linux-headers-3.13.0-93-generic  linux-headers-4.4.0-38-generic  linux-headers-4.4.0-51-generic
linux-headers-3.13.0-63          linux-headers-3.13.0-80          linux-headers-3.13.0-94          linux-headers-4.4.0-39          linux-headers-4.4.0-52
linux-headers-3.13.0-63-generic  linux-headers-3.13.0-80-generic  linux-headers-3.13.0-94-generic  linux-headers-4.4.0-39-generic  linux-headers-4.4.0-52-generic
linux-headers-3.13.0-64          linux-headers-3.13.0-82          linux-headers-3.13.0-95          linux-headers-4.4.0-40          linux-headers-4.4.0-53
linux-headers-3.13.0-64-generic  linux-headers-3.13.0-82-generic  linux-headers-3.13.0-95-generic  linux-headers-4.4.0-40-generic
linux-headers-3.13.0-65          linux-headers-3.13.0-85          linux-headers-3.8.0-19           linux-headers-4.4.0-41
linux-headers-3.13.0-65-generic  linux-headers-3.13.0-85-generic  linux-headers-3.8.0-32           linux-headers-4.4.0-41-generic
linux-headers-3.13.0-66          linux-headers-3.13.0-86          linux-headers-3.8.0-34           linux-headers-4.4.0-44

Edit: As suggested in comments and questions below, here is the df -i output:

Filesystem      Inodes   IUsed   IFree IUse% Mounted on
udev            485306     582  484724    1% /dev
tmpfs           490361     854  489507    1% /run
/dev/sda5      1281120 1278500    2620  100% /
tmpfs           490361      17  490344    1% /dev/shm
tmpfs           490361       6  490355    1% /run/lock
tmpfs           490361      18  490343    1% /sys/fs/cgroup
/dev/sda6      8839168   81878 8757290    1% /home
cgmfs           490361      14  490347    1% /run/cgmanager/fs
tmpfs           490361      45  490316    1% /run/user/1001
8
  • How do you know that your disk seems to be full? the du does not show any full partition.
    – wbad
    Dec 21, 2016 at 18:34
  • @wbad The kernel upgrade says so: No space left on device. Also, /dev/sda5 is 91% full. Kernel are big, unpacking them takes a lot of space, so this is quite likely where it failed. Since it failed, the files were removed, freeing the space again. Dec 21, 2016 at 18:37
  • 1
    Have you also tried du -i ? While it's very uncommon, it is possible to run-out of inodes (the slots in the filesystem where information about the files are stored). For example, a filesystem may have been set-up to accommodate a few very large files (few inodes), and instead have been used to store lots and lots of very small files (requires many inodes). Dec 21, 2016 at 18:43
  • People tell me Ubuntu 16.04 handles removing of old kernels automatically. I suppose you used Software Updater to install kernels. Am I right?
    – jarno
    Dec 21, 2016 at 20:18
  • 1
    The related bug report is here. It would help, if you login to the page, and mark that you are affected by the bug.
    – jarno
    Dec 21, 2016 at 20:28

6 Answers 6

23

You have a lot of kernels installed, they take up a lot of space (300 MiB per kernel). You also have a good number of other packages that were installed as dependencies and, for various reasons, are not needed anymore.

You can safely clean all that with the following command:

sudo apt autoremove

So, as you explained in comments, after doing just that, you got the following error:

The following packages have unmet dependencies:
 linux-headers-generic : Depends: linux-headers-4.4.0-57-generic but it is not installed
E: Unmet dependencies. Try using -f.

You are in a tight spot! Before cleaning packages, APT wants to repair the current ones, that is, install the missing packages. But there is no space for that!

What needs to be done in that case it to free disk space by others means. Maybe you have old files and temporary files you can remove. But since your command above helpfully listed many packages that are not needed anymore, we can remove some of them manually, using the dpkg command.

Note that using dpkg without thinking it through can be dangerous.

The linux-image and linux-image-extra take a lot of space, so let's take some from the list of not needed anymore and remove them with dpkg:

sudo dpkg --remove linux-image-extra-4.4.0-36-generic
sudo dpkg --remove linux-image-4.4.0-36-generic
sudo dpkg --remove linux-image-extra-4.4.0-37-generic
sudo dpkg --remove linux-image-4.4.0-37-generic
sudo dpkg --remove linux-image-extra-4.4.0-38-generic
sudo dpkg --remove linux-image-4.4.0-38-generic

Edit: It turns out that this did not solve the problem. After discussing in chat, and as suggested by others here, you ran df -i and discovered your partition can "only" store 1.2 million files, and all the slots were used.

The linux-headers packages are not as big as linux-image, but they contain a lot of files. So lets take some from the list of not needed anymore and remove them with dpkg:

sudo dpkg --remove linux-headers-4.4.0-36 linux-headers-4.4.0-36-generic
sudo dpkg --remove linux-headers-4.4.0-37 linux-headers-4.4.0-37-generic
sudo dpkg --remove linux-headers-4.4.0-38 linux-headers-4.4.0-38-generic

Now that disk space and inodes have been freed, the missing packages can be installed:

sudo apt install linux-headers-4.4.0-57 linux-headers-4.4.0-57-generic

And now that APT is happy that all package dependencies are installed and everything is well on the machine, we can tell it to automatically remove all packages that are not needed anymore:

sudo apt autoremove
10
  • 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 : Depends: linux-headers-4.4.0-57-generic but it is not installed E: Unmet dependencies. Try using -f.
    – gfat2016
    Dec 21, 2016 at 18:39
  • This is difficult to read in a comment. Can you update your question, and if you have a big log to show, post it to paste.ubuntu.com and give the URL here? Dec 21, 2016 at 18:43
  • ok, sorry there is the link paste.ubuntu.com/23665203
    – gfat2016
    Dec 21, 2016 at 18:45
  • Is this what you get when you run apt autoremove? Dec 21, 2016 at 18:48
  • 1
    Just an unrelated suggestion: Clean up the package cache first if you did not do this for a longer period of time: apt-get clean. Note that apt-get upgrade will then have to download the package files again. Otherwise, just uninstall the old kernel packages. Dec 22, 2016 at 9:38
4

You need to free up some space somehow.

Unfortunately with apt you have a bit of a catch 22, you can't use most apt features until "apt-get -f install" succeeds and "apt-get -f install" won't succeed until you free up some disk space. So despite what serveral other answers here say trying to remove packages with apt is a non-starter.

First try "apt-get clean". This will clean up the downloaded package files and it may free up enough space to make apt-get -f install succeed.

If that is not enough I would suggest removing some of the old kernels with dpkg e.g.

dpkg -r --force-depends linux-image-3.11.0-19-generic

Once you get "apt-get -f install" to run successfully you can then run "apt-get autoremove" as other people have suggested before continuing with your upgrade.

3

I will suggest you to install bleachbit. It will help you a great deal of space recovery.

1
  • 6
    He can't install anything.
    – ave
    Dec 21, 2016 at 23:34
2

If running out of inodes is not your issue, to free up disk space I would also first remove all those old kernels and headers. It is a good idea to keep your current kernel and one of the older kernels as a fallback.

To see a list of your currently installed kernels, have a look in /boot

ls -la /boot

Remove all the older kernels

sudo apt-get purge linux-image-<kernel number>

sudo apt-get purge linux-headers-<kernel number>

You can also clear your apt cache to free up some space.

sudo apt-get clean

Then try again

sudo apt-get update

sudo apt-get upgrade

And if you want

sudo apt-get dist-upgrade

If you want to see how much space each folder is taking up on the drive

du -sh *

Be aware that the results are not ordered by biggest/smallest first, so do scroll up/down the output to check folder sizes. Navigate around your file system to hunt down large folders.

2
  • hatterman can you please be more clear, i'm a beginner in ubuntu, what can i put instead of sudo apt-get purge linux-image-<kernel number> ls -la /boot output : paste.ubuntu.com/23665386
    – gfat2016
    Dec 21, 2016 at 19:42
  • For example. sudo apt-get purge linux-image-3.8.0-19-generic. Do it for each kernel shown in /boot, except for the one you are actually using. To find that out .... uname -a
    – hatterman
    Dec 21, 2016 at 20:00
1

As other's have mentioned, you should clean-up a bit - especially remove old kernels.

But on a more general note (in addition to my little comment about using up too many inodes), I'd like to add the following:

On Linux/Unix filesystems - like ext3 and ext4 - a percentage of the overall capacity of a partition is reserved for the root-user. This ensure there will (almost) always be room for important system-files and logs, as well as a bit of room to maneuver if (when!) root needs to do a spring-cleaning. By default, 5% of each filesystem are thus reserved. (This is one of the reasons why the df-command always seems to show less free space, than you think you ought to have...)

With today's large disks of 500GB or 1TB or more, 5% is actually a bit much. And it also depends on the filesystem... If you have separate partition for / (root), /home, /usr, /var and /tmp ; not all of them needs 5% for root-only use. It's recommended / - and it's probably a good idea for /var and maybe /tmp too - but for /home and /usr, you probably would need a lot less (maybe just 1% or none).

You can use the command dumpe2fs /dev/sd.. | grep "Reserved block count" to see how may "blocks" (kilobytes? - it depends) are reserved.

When you create a filesystem, you can specify the percentage of reserved blocks with the -m option. For just 1%, uses: mkfs.ext4 -v -m1 /dev/sd.. Don't just "try" this command, it's destructive and will format your partition!

You can use the tune2fs with the -m option to change the reserved percentage of an existing filessystem: tune2fs -m1 /dev/sd...

Instead of -m, the -r-option to specify the actual number of reserved blocks by count instead.

You can get quite a bit of extra space this way...

4
  • thank you for your answer but truly i didn't get it all, can you tell me exactly what command i should run to have more space ?
    – gfat2016
    Dec 21, 2016 at 19:12
  • Since you got an existing filesystem (not formatting a new one), use tune2fs... For example, try (in your case) tune2fs -m1 /dev/sda5 to reduce the reserved space on your / (root)-filesystem from 5% to only 1% (I wouldn't recommend going lower than that - especially on / ) . Use df -h before and after, to see how much you freed up... Dec 21, 2016 at 19:35
  • 1
    Since the disk is being filled while performing package installation as root, I believe changing the percentage reserved to root is irrelevant: root has already taken it all. (Otherwise, it is a good advice for non-root partitions.) Dec 21, 2016 at 19:37
  • @BaardKopperud i get this paste.ubuntu.com/23665418 but the mean pb is not resolved i still cannot do the update
    – gfat2016
    Dec 21, 2016 at 19:53
1

This is a known, solved problem - how does one delete ALL the bits and pieces of an old installed kernel, and no more? How does one end up with more disk space AND a working system? Use purge-old-kernels from the byobu package. Read man purge-old-kernels first.

If your disk is 100% depleted, pick the oldest (lowest version number) large file, rm Just That File, and try purge-old-kernels again.

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