Read only / filesystem after power loss

Hi all,

Virtual machine x86 builded with image builder and
version 21.02.0-rc3 with package softethervpn-server - 4.34-9745-1

suddenly occurs with read only filesystem /

root@OpenWrt:/# mount
/dev/root on / type ext4 (ro,noatime)
.
.

after check and random errors in fs (mostly related with softether vpn server):

root@OpenWrt:/# mount
/dev/root on / type ext4 (rw,noatime)
.
.
free space is:
root@OpenWrt:/# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 220.5M 31.7M 184.3M 15% /
.
.

In working old 15 version:

root@OpenWrt:/# cat /etc/openwrt_version
15.05.1
root@OpenWrt:/# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext4 (rw,noatime,data=ordered)
.
.

Do I have to make it data=ordered to prevent data and fs problems and how?

Thanks in advance.

not sure if it's related but maybe 6 months ago... i started getting these on first-reboot of vm..

is it the first time the vm was rebooted?

No, there is no problems with reboot, ro / emerges only if power loss or after about 10 times hard reset (virsh destroy VM_OpenWrt).

1 Like

well... just a guess... but you can try setting up your rootfs as a 'ext-rootfs' ( i.e. mountpoint '/' ) in fstab...

hopefully that would allow for a block-mount filesystem check (may need e2fsprogs) on each mount...

with check fs i.e.;

config global
	option check_fs '1'

config mount
	option target '/'
	option uuid 'aa8fca3f-7077-4f41-a289-ca04fc22470d'
	option enabled '1'
	option enabled_fsck '1'
1 Like

I have created a image with journal option
CONFIG_TARGET_EXT4_JOURNAL=y

root@OpenWrt:/# tune2fs -l /dev/vda2
...
Filesystem features: has_journal ext_attr resize_inode filetype needs_recovery extent sparse_super large_file uninit_bg
...

and tried to mount with data=ordered in with /etc/config/fstab:

config global
option anon_swap '0'
option anon_mount '0'
option auto_swap '1'
option auto_mount '1'
option delay_root '5'
option check_fs '1'

config mount
option target '/'
option device '/dev/vda2'
option options 'rw,noatime,data=ordered'
option fstype 'ext4'
option enabled '1'
option enabled_fsck '1'

but result is

root@OpenWrt:/# mount
/dev/root on /rom type ext4 (ro,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/vda2 on / type ext4 (ro,noatime)
/dev/vda1 on /boot type ext4 (rw,noatime)
/dev/vda1 on /boot type ext4 (rw,noatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)

and / becomes ro - read only- /dev/vda2 on / type ext4 (ro,noatime)
without fstab file / was rw - read write - /dev/root on / type ext4 (rw,noatime):

before fstab:
/dev/root on / type ext4 (rw,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/vda1 on /boot type ext4 (rw,noatime)
/dev/vda1 on /boot type ext4 (rw,noatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)

How to mount / as rw,data=ordered?

From my point of view - I have to have journaled ext4 (to prevent data losses - as logs of vpn) and second check disk to prevent mount in ro mode because of errrors.

block.c

enjoy
	do {
		p = strchr(p, ',');

		if (p)
			*p++ = 0;

		for (i = 0, is_flag = false; i < ARRAY_SIZE(mount_flags); i++) {
			if (!strcmp(last, mount_flags[i].name)) {
				if (mount_flags[i].flag < 0)
					m->flags &= (uint32_t)mount_flags[i].flag;
				else
					m->flags |= (uint32_t)mount_flags[i].flag;
				is_flag = true;
				break;
			}
		}

		if (!is_flag)
			opts += sprintf(opts, "%s%s", (opts > m->options) ? "," : "", last);

		last = p;

	} while (p);