5

I have this fstab entry :

LABEL=cloudimg-rootfs / ext4 defaults,noatime,nobarrier,data=writeback,rw 0 0

I added rw to see if would fix my issue but it wont. After boot I get a read-only file system that I can't fix either using common results found on google.

Useful output. There are no errors with dmesg | grep error

root@w2:~# dmesg | grep EXT4
[    8.372564] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts:                                                                                                                      (null)
[    8.892244] EXT4-fs (sda1): Cannot change data mode on remount
Freedo
  • 1,255

2 Answers2

8

Instead of setting it late in the fstab, why not use tune2fs to make it the default for that filesystem:

tune2fs -o journal_data_writeback /dev/sdXY

Do this once then reboot.

meuh
  • 51,383
  • Good point! My instinct would be to set rootflags= on the kernel command line, but tune2fs seems like a more reliable way to work around this issue. – sourcejedi Nov 10 '17 at 21:14
  • Thanks. It did work, is this safe? And it's permanent too? How can I check if worked? – Freedo Nov 11 '17 at 06:11
  • 2
    tune2fs is not a "hack", if that is what you are worried about. It is permanent, though you can still override these defaults by an explicit mount option. You can see the result with tune2fs -l which will list it as Default mount options: journal_data_writeback .... And of course after the mount you can use findmnt /dev/sdXY to list the mount options in use where you should see data=writeback. – meuh Nov 11 '17 at 07:49
1

When you try to remount the filesystem read-write, try this command

mount LABEL=cloudimg-rootfs / -oremount,rw

Explanation: when you pass both the device and the mount point to mount, it doesn't read options from /etc/fstab. But when you only pass one or the other, it will read the data=writeback option from /etc/fstab.

Then you can edit /etc/fstab back, to regain permanent read-write access to your system.

sourcejedi
  • 50,249