Ubuntu – No space left on device even though there is

aptdiskdisk-usage

A laptop with broken screen that I access via SSH. The sudo apt-get autoremove command gives me the following errors

cp: error writing ‘/tmp/mkinitramfs_zN6ZvT//lib/x86_64-linux-gnu/libpthread.so.0’: No space left on device
cp: failed to extend ‘/tmp/mkinitramfs_zN6ZvT//lib/x86_64-linux-gnu/libpthread.so.0’: No space left on device
cp: error writing ‘/tmp/mkinitramfs_zN6ZvT//sbin/modprobe’: No space left on device
cp: failed to extend ‘/tmp/mkinitramfs_zN6ZvT//sbin/modprobe’: No space left on device
cp: error writing ‘/tmp/mkinitramfs_zN6ZvT//sbin/rmmod’: No space left on device
cp: failed to extend ‘/tmp/mkinitramfs_zN6ZvT//sbin/rmmod’: No space left on device

I get similar errors from various other commands but gparted tells me there is more than 20GB space left on the (single) partition on the laptop. Here is the output of df

$ df -i
Filesystem      Inodes  IUsed   IFree IUse% Mounted on
udev            502644    484  502160    1% /dev
tmpfs           505433    503  504930    1% /run
/dev/sda1      7331840 214087 7117753    3% /
none            505433      2  505431    1% /sys/fs/cgroup
none            505433      3  505430    1% /run/lock
none            505433      4  505429    1% /run/shm
none            505433     16  505417    1% /run/user
overflow        505433    401  505032    1% /tmp

And:

$ df -k
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             2010576       12   2010564   1% /dev
tmpfs             404348     1284    403064   1% /run
/dev/sda1      115247656 83994028  25809372  77% /
none                   4        0         4   0% /sys/fs/cgroup
none                5120        0      5120   0% /run/lock
none             2021732      204   2021528   1% /run/shm
none              102400       16    102384   1% /run/user
overflow            1024     1024         0 100% /tmp

Error started after I ran sudo apt-get upgrade.

Best Answer

At some point in the past, your root filesystem filled up, and a small, temporary /tmp was created to allow boot to succeed. This small /tmp was never deleted, so now, even though you have room on /, you still are filling up the small /tmp and seeing your problem. Simply unmount it:

sudo umount /tmp

and of course, try to ensure your / is as clean as possible.


Normally, /tmp is just a part of the root (/) filesystem, no separate mount is needed, unless there are special circumstances, like running out of root filespace (when some daemon creates the one you see), or maybe you have / on a very slow media (like an USB flash stick) and want /tmp in ram for performance, even with limited space.

Related Question