5

My cat walked over my keyboard and pressed "magical" SysRq u, doing an Emergency Remount R/O. How do I reverse this?

On How do I remount a filesystem as read/write?, SirCharlo claims

The correct syntax is:

sudo mount -o remount,rw /partition/identifier /mount/point

but that just yields another error,

mount: you must specify the filesystem type

and if I supply it, e.g.,

$ sudo mount -t ext4 -o remount,rw /dev/sda7 /

I'm back at the error message the OP reported,

mount: / not mounted or bad option

That diagnostic begs the question, which? Not mounted, or bad option? The exit status is 32, and man mount provides this key:

  mount has the following return codes (the bits can be ORed):
  0      success
  1      incorrect invocation or permissions
  2      system error (out of memory, cannot fork, no more loop devices)
  4      internal mount bug
  8      user interrupt
  16     problems writing or locking /etc/mtab
  32     mount failure
  64     some mount succeeded

OK, looks like a mount failure. ;-)
What can I do about it?

BTW, in response to Alkthree's question "How do I remount", SirCharlo also suggest not a remount but umount followed by mount. Why?

Quigi
  • 95
  • I deleted my answer; on a second thought, that's probably just not reversible. What if a process tries to remount the system read/write after you remounted everything with an emergency remount? I think that's just actively inhibited to forbid any process to go against the emergency remount. Nevertheless +1 for the good question, and I'll research this a bit and post again if I find something since this intrigued me. – kos Dec 22 '15 at 17:14
  • Bummer. Thanks kos. Meanwhile, the failing system call is mount("/dev/sda7", "/", 0x1fa8590, MS_MGC_VAL|MS_REMOUNT, "errors=remount-ro") = -1 EINVAL (Invalid argument) as reported by strace. – Quigi Dec 22 '15 at 17:17
  • Try to execute sudo mount -o remount,rw /. – Hi-Angel Dec 22 '15 at 17:42
  • @Hi-Angel : that's exactly what kos suggested (and what I had tried before asking), and what yields mount: / not mounted or bad option because the system call mount(...) fails -- see above. – Quigi Dec 22 '15 at 18:18
  • @Quigi the command I asked is with removed partition identifier — just for the safe case: you know, like, perhaps could be that "remount" option doesn't expect both partition and the path, or something alike… I just know that this command works for sure. But if that still won't work, it would be great if you would post output of mount, without options. – Hi-Angel Dec 22 '15 at 18:27
  • 1
    @Hi-Angel: Yes, kos and I did exactly that, with removed partition identifier. When I (as root) run mount -o remount,rw /, that program (/bin/mount) figures out the partition identifier by itself, and attempts the system call mount("/dev/sda7", "/", 0x19f6590, MS_MGC_VAL|MS_REMOUNT, "errors=remount-ro"), which returns -1 EINVAL (Invalid argument), and then it prints mount: / not mounted or bad option. – Quigi Dec 22 '15 at 19:13
  • 1
    mount without options produces this output that's too long by 900 or so characters, and ends with this crucial note about its staleness: mount: warning: /etc/mtab is not writable (e.g. read-only filesystem). It's possible that information reported by mount(8) is not up to date. For actual information about system mount points check the /proc/mounts file. – Quigi Dec 22 '15 at 19:20
  • 1
    The first (stale!) row reports a partition mounted on "/", namely /dev/sda7 on / type ext4 (rw,errors=remount-ro,commit=0). In contrast, the up-to-date /proc/mounts has two, rootfs / rootfs rw 0 0 and /dev/disk/by-uuid/3a1bce3b-90fa-423f-9bee-69874fd7a9c1 / ext4 ro,relatime,errors=remount-ro,data=ordered 0 0 – Quigi Dec 22 '15 at 19:26
  • 1
    Okay, I don't know what to do, but a couple of thoughts of what I'd do here: try to look at the /var/log/syslog and dmesg for anything file system related, especially for the moment when the filesystem was remounted, and anything related to /dev/sda7. Run tail -f /var/log/syslog, and try to run the mount -o remount,rw / again, also try to press again the Alt+SysRq+u — and see if there would be any prints. – Hi-Angel Dec 22 '15 at 20:06
  • I asked about fixing, and that may be impossible. But it may be preventable. My /proc/sys/kernel/sysrq contains 176. According to https://www.kernel.org/doc/Documentation/sysrq.txt, that bitmask allows 3 functions: 16 = 0x10 - enable sync command; 32 = 0x20 - enable remount read-only; 128 = 0x80 - allow reboot/poweroff. To disable remount read-only, I can change it to 0x10 | 0x80:
    echo 144 | sudo tee /proc/sys/kernel/sysrq
    – Quigi Dec 25 '15 at 02:51

0 Answers0