7

I have deliberately configured the file system of my RaspberryPi (Raspbian - Jessie) to be read only. One of the things that's not (yet) working is tab (aka auto) completion in bash, where I often get the following error:

bash: cannot create temp file for here-document: Read-only file system

Much on-line discussion focuses on how to fix file system problems manifesting themselves with this error. I'd like to adjust bash instead. Where is it trying to create this temp file and how can I redirect it to create that file in /tmp (which is mounted with tmpfs)?

  • 2
    you can try starting your bash with strace -e open,creat bash and it will show you all the system calls to open() and creat(). – meuh Mar 2 '16 at 7:52
  • 2
    Could be /var/tmp? – Celada Mar 2 '16 at 8:09
  • 2
    Bash normally creates its temporary files in $TMPDIR, defaulting to /tmp if unset, like most programs. Is TMPDIR set? If so make sure that location is on tmpfs as well, otherwise it'll break a lot more than bash completion. If that's not it, look under strace as meuh advises. – Gilles 'SO- stop being evil' Mar 2 '16 at 22:58
1

The first test you can do to see where is your tmp folder and if it is working is executing this command:

tempfile

The output should be something like this:

/tmp/fileupz962

If the folder /tmp exists and is working (has write permissions) but the temp folder is pointed to other directory like /var/tmp you can try to set the temp folder to point to /tmp using:

export TMPDIR=/tmp

If bash is saving the temporary file in /tmp and if for some reason the /tmp folder is not working you can try to unmount it (in case it is mounted). It may happen that the /tmp is mounted as read only. In both cases should be useful to try:

sudo umount /tmp

Then you can try using RAM storage for the /tmp directory:

sudo mount -t tmpfs -o size=128M tmpfs /tmp/ram/

You can set the amount of RAM (-o size=128M) to whatever value you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.