26

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.

  • Just a friendly reminder to make the question title more descriptive, which helps get better responses: "odd terminal behaviour" is not very descriptive. – thomasrutter Aug 26 '14 at 3:41
  • I appreciate it. – Takamuffin Aug 26 '14 at 3:43
  • In order to better diagnose your problem, can you tell me if you are using the default partitioning that Ubuntu set up, are you using whole disk encryption or LVM, and have you done anything to your fstab? What is the output of the mount command? – thomasrutter Aug 26 '14 at 3:47
  • mount output: gist.github.com/anonymous/74dc62ccd5602d1e9742 – Takamuffin Aug 27 '14 at 4:31
  • Thanks for providing that - it looks like no issue with the way the mounts are configured and no problems at mount time but maybe errors with the / (root) mount encountered since then? The remount-ro specifies that the root partition will be remounted as read-only in the event of certain filesystem errors. Doing a fsck from recovery or a Live CD would be good. – thomasrutter Aug 27 '14 at 5:15
14

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

13

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.

  • 1
    Had the same problem. Rebooting worked. Thanks. – whitehat Jun 27 '16 at 14:29
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

  • Welcome to Ask Ubuntu. Since this is not a proper answer to the question, please delete it. – Archisman Panigrahi Oct 9 '15 at 8:55
  • 1
    That's my answer. What's your answer? – phtn458 Oct 9 '15 at 9:36
  • 2
    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). – Archisman Panigrahi Oct 10 '15 at 13:23
  • 9
    @ArchismanPanigrahi "the disk is bad, get a new one" is an answer. – Seth Dec 12 '15 at 19:44
  • 1
    wow. So all those upvoted the answer went and bought new hdd (?) – Pawan Jan 10 '17 at 12:38
2

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).

1

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)

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.