Issue
I recently encountered the problem with my VM running Ubuntu 18.04. I have been using the same VM for months and was working fine and then all of a sudden when I tried to use tab
to auto complete I got the error,
-bash: cannot create temp file for here-document: Read-only file system
I decided to reboot my VM, actually I ended up quitting virtual box and restarted it, and when the VM restarts I got the error shown below.
mktemp: failed to create file via template ‘/tmp/virtualenvwrapper-initialize-hook-XXXXXXXXXX’: Read-only file system
touch: cannot touch '': No such file or directory
ERROR: virtualenvwrapper could not create a temporary file name.
┌────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /home/mark/.config │
└────────────────────────────────────────────────────────┘
I ended up running the sudo chown
command as suggested but the same problem remains.
I've been searching for a solution and the closest I've found is
https://www.digitalocean.com/community/questions/tmp-folder-deleted. However I have verified the /temp
folder's permission and it appears to be fine.
drwxrwxrwt 10 root root 4096 Dec 30 17:01 /tmp
Does anyone have any suggestions? Is there something wrong with my virtualenvwrapper?
Side Note:
I've seen some people talking about running out of disk space but I've only used 21%.
Filesystem Size Used Avail Use% Mounted on
udev 967M 0 967M 0% /dev
tmpfs 200M 5.9M 194M 3% /run
/dev/sda2 98G 19G 75G 21% /
tmpfs 997M 0 997M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 997M 0 997M 0% /sys/fs/cgroup
/dev/loop0 90M 90M 0 100% /snap/core/8268
/dev/loop1 90M 90M 0 100% /snap/core/8213
tmpfs 200M 0 200M 0% /run/user/1000
mount
output:
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=989248k,nr_inodes=247312,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=204132k,mode=755)
/dev/sda2 on / type ext4 (ro,relatime,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=44,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=14041)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
configfs on /sys/kernel/config type configfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/var/lib/snapd/snaps/core_8268.snap on /snap/core/8268 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/core_8213.snap on /snap/core/8213 type squashfs (ro,nodev,relatime,x-gdu.hide)
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=204132k,mode=700,uid=1000,gid=1000)
Solution
The error you're getting indicates that you're trying to write on a file system that's read only. If you look at the mount
output for /
, then the ro
mount option indicates that it's read only.
There are usually a couple reasons that your file system is read only, but in this case, it's likely the behavior of an ext4 file system when it encounters a file system error. The default is to remount the file system read only to avoid further damage but allow the system to continue. The alternatives in this case are to ignore the error and panic, both of which are generally less desirable.
You can verify this by running dmesg
in order to see whether the kernel has reported any file system errors and remounted the file system. If so, you can generally reboot the system and an fsck
will occur automatically. You may need to boot from a different medium (such as a live CD) to perform the fsck
(by running e2fsck -f /dev/sda2
) in some cases, since not all errors can be fixed when the file system is mounted.
Answered By - bk2204 Answer Checked By - Katrina (WPSolving Volunteer)