LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   "data=writeback" in fstab mounts root partition as "read-only" (https://www.linuxquestions.org/questions/linux-general-1/data%3Dwriteback-in-fstab-mounts-root-partition-as-read-only-916031/)

holister 11-28-2011 12:04 PM

"data=writeback" in fstab mounts root partition as "read-only"
 
Goal: Use ext4 (faster than ext2) but completely remove "journaling" (not secure for sensitive data destruction - shred/wipe, etc...)

Exact same fresh install on Debian Squeeze works perfectly. On fresh Wheezy install (kernel 3.0), including "data=writeback" for the / partition causes it to mount read-only, which prevents mounting of other partitions, causing loss of Xserver (drops to shell).

Taking "data=writeback" off the / partition but leaving it in for /boot and /home partitions and everything mounts just fine. Put the option back on / = read-only. Take it off = mounts fine.

Steps taken:

1. (live CD) Use cfdisk to cut up the drive
2. do: mke2fs -t ext4 -O ^has_journal /dev/sdaX (root)
3. do: tune2fs -O ^has_journal /dev/sdX
4. do: tune2fs -o journal_data_writeback /dev/sdX
5. in /etc/default/grub: GRUB_CMDLINE_LINUX="rootflags=data=writeback" -> update-grub2
6. edit /etc/fstab (for all partitions). ( / options) errors=remount-ro,noatime,nodiratime,data=writeback,barrier=0 (mounts "read-only")

I've read dozens of threads and everything points to "tune2fs -o journal_data_writeback /dev/sdX" solving the issue. I believe I've done all the steps correctly, yet still unable to mount root. Thank you for the help

salasi 11-28-2011 12:28 PM

Quote:

Originally Posted by holister (Post 4536512)
Goal: Use ext4 (faster than ext2) but completely remove "journaling" (not secure for sensitive data destruction - shred/wipe, etc...)

  1. Probably true (ext2 vs ext4) in most workloads, not clear if true in yours
  2. Untrue, if you are careful enough (which probably isn't very); and not really different because of journalling.


Quote:

Originally Posted by holister (Post 4536512)
Exact same fresh install on Debian Squeeze works perfectly. On fresh Wheezy install (kernel 3.0), including "data=writeback" for the / partition causes it to mount read-only, which prevents mounting of other partitions, causing loss of Xserver (drops to shell).

So, in order to avoid journalling completely, you have decided to change from one journalling mode to another journalling mode.

Code:

data=writeback                Data ordering is not preserved, data may be written
                        into the main file system after its metadata has been
                        committed to the journal.

I wonder if you are getting caught by this:

Code:

errors=remount-ro        Remount the filesystem read-only on an error.
errors=continue                Keep going on a filesystem error.
errors=panic                Panic and halt the machine if an error occurs.
                        (These mount options override the errors behavior
                        specified in the superblock, which can be configured
                        using tune2fs)

That is (and this is speculation), there is an error, and the filesystem is being remounted ro as a consequence.

holister 11-28-2011 03:51 PM

Quote:

Originally Posted by salasi (Post 4536538)
So, in order to avoid journalling completely, you have decided to change from one journalling mode to another journalling mode.

I have 6 pages of notes on this research and still not clear. I was under the impression that formatting the partition using -O ^has_journal and including "data=writeback" in fstab mounts the partition without journal. In addition, this part of 'dmesg' made me believe that "data=writeback" is, in fact the right option (suggesting that data=writeback results in sda3/sda4 being mounted "...without journal"):

Code:

] EXT4-fs (sda2): Cannot change data mode on remount
] EXT4-fs (sda2): Cannot change data mode on remount
] EXT4-fs (sda3): mounted filesystem without journal. Opts: data=writeback,errors=remount-ro
] EXT4-fs (sda4): mounted filesystem without journal. Opts: data=writeback,errors=remount-ro

sda2 = root -> mounts read only
sda3 = home -> mounts fine with data=writeback (if same option is taken out of 'root' but left in for these two.
sda4 = Vbox -> mounts fine with data=writeback

Maybe that's where the conflict is?!? Formatting with mke2fs -O ^has_journal followed by tune2fs -O ^has_journal accomplishes removing the journalling option and then 'data=writeback' conflicts in fstab??? Is there a command to see / verify if ext4 is journaling or not?

jthill 11-28-2011 04:11 PM

This bit me awhile ago. Change the default filesystem mount options in the filesystem itself.
Code:

# tune2fs /dev/sda2 -o journal_data_writeback
. Remount will no longer accept different journaling options even if the old mount was readonly.

holister 11-28-2011 04:21 PM

Quote:

Originally Posted by jthill (Post 4536712)
Change the default filesystem mount options in the filesystem itself.

So, you're saying that in /etc/fstab I should remove data=writeback and barrier=0. Right? But I can leave noatime.

With all the try-this and try-that, now I can't reproduce EXT4-fs (sda3): mounted filesystem without journal in 'dmesg'. Is there a way to verify that the system is mounted and is, in fact, running without journaling? Thanks.

jthill 11-28-2011 06:01 PM

Make fstab and the superblock match. You can tune2fs -l to check whether the filesystem features include has_journal.

holister 11-28-2011 08:48 PM

conclusion...
 
I just want to clarify a few things (for my sake) before marking the thread "solved".

From tune2fs manpages: -O [features] tune2fs -O ^has_journal /dev/sdX -> Turns journalling OFF

journal_data_writeback - This mount option does write to journal. "When the filesystem is mounted with journalling enabled..." (Therefore, if journalling is turned off using the -O switch, then this mount option does not apply)

/etc/fstab - "Default mount options can be overridden by mount options specified in /etc/fstab..." (Putting journalling options in /etc/fstab (in this case - simply turning journaling off) is not necessary)

Conclusion:
To completely turn off journalling in ext4, all that's required is command: tune2fs -O ^has_journal /dev/sdX
Using tune2fs -o journalling_data_writeback (mount option) and using "data=writeback" option in /etc/fstab as reported in so many threads regarding this issue is simply not required and might, in fact, be erroneous (correct?)

To verify whether journalling is turned off do: tune2fs -l /dev/sdX. Next to "Filesystem Features" - if 'has_journal' does not appear, then journalling has been turned off

Please let me know if anything here is incorrect or missing and I will update it, so there is no more confusion. Thank you all for your help.

jthill 11-28-2011 09:47 PM

In my experience, for something like this, "correct" is what works, the man pages tell you what to try. The man pages didn't warn you about the superblock-consistency requirement for ext4, for instance.

Frankly, a no-journal filesystem scares the crap out of me. Why Do That? Just run data=writeback,commit=600

(edit: should have been more explicit - only data=journal journals your data. nothing else does. my source on that: the filesystem author's documentation on it in the kernel source, Documentation/fs/ext4.txt. Anyway I wonder what kind of hardware and workload make zero-before-rm cheaper or safer than encrypt-it-in-the-first-place.


All times are GMT -5. The time now is 07:18 PM.