`Read-only file system` error using tab completion, and terminal window closing randomly

102,463

Solution 1

I rebooted in recovery mode and followed the instructions the system gave me. I ran fsck on /dev/sda2, and that fixed the problem.

Solution 2

The Read-only file system error is the major clue here. I would guess that your home directory, where bash tries to store your command history and so forth, is inside a read-only partition.

I would guess that it tries to update your recent command history on disk once every 32 commands, which is why it's failing on the 32nd command you type in a session.

Now, a partition may be mounted as read-only if you do it deliberately, but it may also be mounted as read-only if there was an error - this latter behaviour is usually the default for the root partition.

I'd be surprised if you weren't experiencing other problems if your root partition is mounted read-only.

You can try rebooting and checking the disk from the recovery menu. Press and hold shift as the computer boots, right after the BIOS screen disappears and right before the Ubuntu logo appears.

Solution 3

This exact issue happened to me too.

It occurs intermittently.

So I finally had enough with it and decided to reinstall OS - ubuntu-gnome 14.04 (clean).

It fixed it! At least for a few days.. Then that exact same problem occurred again...

So I went to Fry's and got a new hdd (Seagate).

So far so good ( 6 months & counting ).

side note: stock hdd was Toshiba

Solution 4

As others have pointed out, a read-only /tmp filesystem causes further problems.

As for the 31 lines, it's related to gnome-terminal's internals.

It keeps a certain amount of lines in memory, in a so-called "ring". The rest, lines that scroll out of this ring are placed in a "stream". In older versions of gnome-terminal the stream was pretty much directly written into a file under /tmp, in newer versions there's buffering, compression and encryption before it's written out. (I can't remember off the top of my head whether the file under /tmp is opened when the first chunk of data is written into the stream, or when the stream first tries to actually write to /tmp; it's a minor implementation detail.)

The size of the ring is always a power of two (each slot containing 1 line of the terminal; except for 1 slot is not used due to technical reasons), and is doubled every time it's required due to the growth of the terminal height (but never shrinks back). E.g., with the default height of 24 lines the ring contains the last 31 lines of output, the rest goes to the stream (eventually to /tmp). If you increase the window's height to let's say 40 lines, the in-memory ring will grow to accommodate at most 63 entries at a time.

What you experience is that gnome-terminal tries to open a file in /tmp to store the stream, and exits because of the unexpected failure here. Try with a taller window than the default; it'll crash after pressing Enter 63 (or maybe 127) times.

That being said, /tmp should be fixed to be writable (with permissions 1777).

Solution 5

My problem was that a process was running with 100% CPU and probably took all disk resources (Some backup process: Ur-Backup).

Once i killed it, all went well. So I would think that a bottle-neck on the IO could cause this error even if there is enough space and you have write permission.

(Raspberry Pi with Jessy 18/03/16)

Share:
102,463

Related videos on Youtube

Takamuffin
Author by

Takamuffin

Updated on September 18, 2022

Comments

  • Takamuffin
    Takamuffin almost 2 years

    First is simply an oddity with the command cd. If I type in cd, then a space, then press Tab to view the available directories, I get this error message:

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

    The more troublesome issue has been random closings of the terminal window. It has happened while testing the cd oddity, and also while ssh'd into another server doing simple things like git status and such. [Edit] It seems if I press enter exactly 31 times it triggers the auto closing of the terminal window (verified 3 times now).

    I recently upgraded from 12.04 to 14.04 late last week, and this behavior did not occur the entire day I used it after upgrading. This is the first time attempting anything on this computer since that day.

    Please advise any other information I can provide, and what I need to do to resolve this.

  • phtn458
    phtn458 over 8 years
    That's my answer. What's your answer?
  • Archisman Panigrahi
    Archisman Panigrahi over 8 years
    What I wanted to say is that reinstalling OS or buying a new hard disk is not a proper solution. You may want to comment on other posts and you will be able to comment when you have enough reputation (15).
  • web.learner
    web.learner over 8 years
    @ArchismanPanigrahi "the disk is bad, get a new one" is an answer.
  • Magellan
    Magellan over 8 years
    Truly. Only time I've ever seen this come up is when the storage for a host has become unavailable while the host is still up. Annoying for one host, very problematic when it's a few hundred because the storage sub-system disappeared for awhile.
  • whitehat
    whitehat about 8 years
    Had the same problem. Rebooting worked. Thanks.
  • Pawan
    Pawan over 7 years
    wow. So all those upvoted the answer went and bought new hdd (?)
  • Admin
    Admin almost 2 years
    How do you reboot into recovery mode without a live-cd?