Tab completion errors: bash: cannot create temp file for here-document: No space left on device

When using the tab bar, I keep getting this error:

bash: cannot create temp file for here-document: No space left on device”

Any ideas?

I have been doing some research, and many people talk about the /tmp file, which might be having some overflow. When I execute df -h I get:

Filesystem      Size  Used Avail Use% Mounted on 
/dev/sda2       9.1G  8.7G     0 100% /
udev             10M     0   10M   0% /dev
tmpfs           618M  8.8M  609M   2% /run
tmpfs           1.6G     0  1.6G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.6G     0  1.6G   0% /sys/fs/cgroup
/dev/sda1       511M  132K  511M   1% /boot/efi
/dev/sda4       1.8T  623G  1.1T  37% /home
tmpfs           309M  4.0K  309M   1% /run/user/116
tmpfs           309M     0  309M   0% /run/user/1000

It looks like the /dev/data directory is about to explode, however if I tip:

$ du -sh /dev/sda2
0   /dev/sda2

It seems it’s empty.

I am new in Debian and I really don’t know how to proceed. I used to typically access this computer via ssh. Besides this problem I have several others with this computer, they might be related, for instance each time I want to enter my user using the GUI (with root it works) I get:

Xsession: warning: unable to write to /tmp: Xsession may exit with an error

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If anyone gets here with this error when their disk isn’t full, be sure to check not just df but also df -i. There are a fixed number of inodes on a filesystem, and every file needs one. If you have just tons of small files, it’s very easy for your filesystem to fill up with these small files while there’s still plenty of space left on the drive when you run df.

Method 2

Your root file system is full and hence your temp dir (/tmp, and /var/tmp for that matter) are also full. A lot of scripts and programs require some space for working files, even lock files. When /tmp is unwriteable bad things happen.

You need to work out how you’ve filled the filesystem up. Typically places this will happen is in /var/log (check that you’re cycling the log files). Or /tmp may be full. There’s many, many other ways that a disk can fill up, however.

du -hs /tmp /var/log

You may wish to re-partition to give /tmp it’s own partition (that’s the old school way of doing it, but if you have plenty of disk it’s fine), or map it into memory (which will make it very fast but start to cause swapping issues if you overdo the temporary files).

Method 3

You may also have lost write access to the /tmp/ directory.

It should look like that:

ls -l / |grep tmp
drwxrwxrwt   7 root root  4096 Nov  7 17:17 tmp

You can fix the permissions like that:

chmod a+rwxt /tmp

Method 4

The fastest way to locate your folders that are too full is by narrowing down the folder file size in levels from the root folder.
You start with the root folder by:

sudo du -h --max-depth=1 /

Then – EITHER you increase the depth, i.e. the levels below:

sudo du -h --max-depth=2 /

OR – quicker – you you look which folder has eaten up the most disk space, and do the same on this folder:

sudo du -h --max-depth=1 /home/<user>/<overfull-folder>

Once you found it, just remove that one:

rm -rf <path to overfull-folder>

Method 5

I was getting error, then I saw

[  672.995482] EXT4-fs (sda2): Remounting filesystem read-only
[  672.999802] EXT4-fs error (device sda2): ext4_journal_check_start:60: Detected aborted journal

I was able to confirm this,

mount | grep -i sda2
/dev/sda2 on / type ext4 (ro,relatime,errors=remount-ro,data=ordered)

Method 6

For my case of this same error, it was a cagefs issue as this server was on CloudLinux, addressed with cagefsctl --remount username

Method 7

If your using Docker:

Just to help any one using docker, just make sure you are deleting the “left over” images from the building process.

To see which images are currently on disk
$ docker images

It will give you a long list and you can start deleting images that you don’t need.

$ docker rmi <image id>.

This should restore your system back to normal.

This is what was causing my problem.

Method 8

I was getting the same error. In my case, the disk was filled up by /var/log/syslog and /var/log/kern.log echoing each other in a blizzard of repeated messages, in what was perhaps a kernel panic. 13 G each file. I couldn’t delete or resize in place with sed because I couldn’t even sudo or su -. I had to reboot in recovery mode and drop to a root shell to truncate the files, which I did with sed -i '10001,$ d' /var/log/syslog and sed -i '10001,$ d' /var/log/kern.log (the repeating messages started before the 10000th line in both files).

Method 9

People have written many things here.

But, I simply emptied the trash bin. It works fine for me now.

 rm -rf ~/.local/share/Trash/*

Method 10

Since reboots are very rare on my system , my /tmp had piled up a lot of junk ….Faced this problem recently and cleaned up my /tmp folder.

cd /tmp
sudo rm -rf *

Method 11

Below thing worked for me.

sudo apt-get autoclean

Method 12

This is because the disk space is not enough, you need to clean up large files or clean up the process that takes up space:

  1. df -h View hard disk space
  2. du -sh /* View which directory is the largest, step by step to find large files
  3. du -h --max-depth=1 find the largest file


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x