4

I have a server where a partition (/var) switched to read-only. So I try to reproduce this problem on another server with the following command.

mount -o remount,ro /var/ -f

When I check our application log on that same partition I remounted ro I see entries recently added.

tail -f /var/log/httpd/*

CentOS 6.7

Apache: 2.2.15

uname -r: 2.6.32-573.7.1.el6.x86_64

2
  • 2
    which filesystem? Are you sure that /var/log is in the same partition as /var? If you use mount without the -f flag, what error do you encounter? – Giacomo Catenazzi Oct 18 '16 at 15:47
  • I agree with @GiacomoCatenazzi. /var/log/ is occasionally given its own partition. (check output of df). If it is not a separate partition, I would try umounting, then doing a fresh mount to test whether remount is working. – Xalorous Oct 18 '16 at 15:52
15

It is the correct behaviour.

You use the -f flag, which mean:

-f, --fake: Causes everything to be done except for the actual system call; if it's not obvious, this ``fakes'' mounting the filesystem. This option is useful in conjunction with the -v flag to determine what the mount command is trying to do. It can also be used to add entries for devices that were mounted earlier with the -n option. The -f option checks for an existing record in /etc/mtab and fails when the record already exists (with a regular non- fake mount, this check is done by the kernel).

See also Remount a busy disk to read-only mode.

3
  • 8
    BTW I'm surprised that -f means fake and not force. – Giacomo Catenazzi Oct 18 '16 at 15:59
  • 6
    ... and that's why we have man pages – roaima Oct 18 '16 at 17:50
  • 4
    A bit confusingly, -f means force when used with the umount command. – Mark Plotnick Oct 18 '16 at 19:14
0

I agree with @GiacomoCatenazzi. /var/log/ is occasionally given its own partition. (Check output of df). If it is not a separate partition, I would try umounting, then doing a fresh mount to test whether remount is working. editing the mount options in /etc/fstab then rebooting. (only way to get a known fresh mount with /var).

Also, check results of mount (no options) (or cat /etc/mtab). mount with no options displays a version of /etc/mtab. Look to see how /var (and possibly /var/log) are actually mounted. /etc/mtab shows the actual parameters in use (including the defaults that were not overridden.)

4
  • 1
    Good luck unmounting /var on a running system. – jordanm Oct 18 '16 at 16:53
  • Oh, there is that. – Xalorous Oct 18 '16 at 17:13
  • @jordanm Or rather, good luck having a running system after unmounting /var – cat Oct 18 '16 at 18:53
  • You could even mount some other partition on /var, like if you wanted to modify the original partition to add space. But it'd be easier to do offline using alternate boot media. You could even design the OS to not use /var at all, but it would be so different from the norm, the only person who could administer or troubleshoot it would be the person who built it. – Xalorous Oct 19 '16 at 14:57
0

As pointed out above, the -f is probably why you're not seeing your changes on your test box.

However, that said.... in general linux will put partitions in read only mode when it encounters i/o errors. If the system who suddenly went read only is still up, you may wish to consider checking the logs for i/o errors. You may not be able to duplicate the issue on 'good' hardware. Check dmesg, as well as the system logs on the affected system. Odds are decent this is a degraded hardware issue you will need to address.

1
  • It will also be remounted read only if you ask for it to be remounted read-only like the asker is trying to do here. – user253751 Oct 19 '16 at 4:17

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.