How to enable data=writeback in ext4

If none of the more specific forums is the right place to ask

How to enable data=writeback in ext4

Postby ManilaTux » 2010-12-19 18:29

What I've done so far:

1. Edit ext4 entry in /etc/fstab
/dev/sda2 / ext4 noatime,barrier=0,data=writeback,nobh,commit=90,errors=remount-ro 0 1

2. Add this line in /etc/default/grub
GRUB_CMDLINE_LINUX="rootflags=data=writeback"

3. Run update-grub

4. Reboot to recovery mode and run: tune2fs -o journal_data_writeback /dev/sda2 (did not work)
Reboot to a LiveCD and run: tune2fs -o journal_data_writeback /dev/sda2 (did not work)

So what did I miss? Thanks for any help.

BTW, I have kernel 2.6.32-5-686
I use Debian, therefore I am.
User avatar
ManilaTux
 
Posts: 113
Joined: 2010-12-19 12:10
Location: In your mom's bedroom

Re: How to enable data=writeback in ext4

Postby bugsbunny » 2010-12-19 19:18

What makes you think it didn't work? Either 1 or 4 (4 is better) should have worked.

What exactly are you trying to do? You may be better off simply turning of journaling (writeback mode isn't very safe in any case, and if you're more worried about performance than data safety just turn of journaling).
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: How to enable data=writeback in ext4

Postby ManilaTux » 2010-12-19 19:46

What makes you think it didn't work? Either 1 or 4 (4 is better) should have worked.
It didn't work because the root partition was mounted read-only and I cannot log in.

What exactly are you trying to do? You may be better off simply turning of journaling (writeback mode isn't very safe in any case, and if you're more worried about performance than data safety just turn of journaling).
Yes I'm trying to tweak my box for performance and I'm not worried about data safety as insured by journaling. BTW, journaling is turned off by default in ext4 (data=ordered).
I use Debian, therefore I am.
User avatar
ManilaTux
 
Posts: 113
Joined: 2010-12-19 12:10
Location: In your mom's bedroom

Re: How to enable data=writeback in ext4

Postby bugsbunny » 2010-12-19 20:47

ManilaTux wrote:
What makes you think it didn't work? Either 1 or 4 (4 is better) should have worked.
It didn't work because the root partition was mounted read-only and I cannot log in.

What exactly are you trying to do? You may be better off simply turning of journaling (writeback mode isn't very safe in any case, and if you're more worried about performance than data safety just turn of journaling).
Yes I'm trying to tweak my box for performance and I'm not worried about data safety as insured by journaling. BTW, journaling is turned off by default in ext4 (data=ordered).


Journaling is NOT turned off by default in ext4. data=ordered refers to the type of journaling (as does data and writeback).

ext4 (and ext3) have 3 modes of writing to the journal (as explained in the tune2fs man page, among other places)
Code: Select all
journal_data
  When  the  filesystem  is  mounted  with journalling
  enabled, all data (not just metadata)  is  committed
  into  the  journal  prior  to being written into the
  main filesystem.

journal_data_ordered
  When the  filesystem  is  mounted  with  journalling
  enabled, all data is forced directly out to the main
  file system prior to its metadata being committed to
  the journal.

journal_data_writeback
  When  the  filesystem  is  mounted  with journalling
  enabled, data may be written into the main  filesys-
  tem  after  its  metadata  has been committed to the
  journal.  This may increase throughput, however,  it
  may  allow old data to appear in files after a crash
  and journal recovery.


If the root partition was mounted read only and you can't log in that doesn't mean it didn't work, it means something else is wrong and the system probably wants you to run fsck to fix it. You need to look at the boot messages and see what it says.
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: How to enable data=writeback in ext4

Postby ManilaTux » 2010-12-19 21:59

So you think If I examine the boot messages, somehow I'll get a hint of what's wrong other than the procedure itself (and the mount options) that I'm using, which resulted to a read-only filesystem? I don't have the time right now to go through the motions: Image > Experiment > Fail > Restore. Yes, Debian is my main OS.

I was just hoping that somebody did this already with his debian.

When I said journaling being off by default, I meant data journaling. Metadata is always journaled whatever the mode is, so in essence you really can't turn off journaling.
I use Debian, therefore I am.
User avatar
ManilaTux
 
Posts: 113
Joined: 2010-12-19 12:10
Location: In your mom's bedroom

Re: How to enable data=writeback in ext4

Postby ManilaTux » 2010-12-19 22:20

I will try this command (later) that is supposed to turn off journaling (I stand corrected) and see what happens.

tune2fs -O ^has_journal /dev/sda2

If anybody will advise me against this or why this is stupid :lol: please do. Thanks
I use Debian, therefore I am.
User avatar
ManilaTux
 
Posts: 113
Joined: 2010-12-19 12:10
Location: In your mom's bedroom

Re: How to enable data=writeback in ext4

Postby BioTube » 2010-12-20 00:36

ext4 defaults to writeback; newer kernels have the default default for ext3 as the same.
Image
Ludwig von Mises wrote:The elite should be supreme by virtue of persuasion, not by the assistance of firing squads.
User avatar
BioTube
 
Posts: 7551
Joined: 2007-06-01 04:34

Re: How to enable data=writeback in ext4

Postby bugsbunny » 2010-12-20 03:14

BioTube wrote:ext4 defaults to writeback; newer kernels have the default default for ext3 as the same.


No, ext4 defaults to ordered mode. From the kernel documentation for ext4 in 2.6.36.1
Code: Select all
3. Options
==========

When mounting an ext4 filesystem, the following option are accepted:
(*) == default
. . .
data=journal      All data are committed into the journal prior to being
         written into the main file system.

data=ordered   (*)   All data are forced directly out to the main file
         system prior to its metadata being committed to the
         journal.

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.
. . .


With ext3 newer kernels default to writeback, but there is a kernel option to have the default be ordered. Quoting from the config help for the option
Default to 'data=ordered' in ext3
Code: Select all
CONFIG_EXT3_DEFAULTS_TO_ORDERED:
 
 The journal mode options for ext3 have different tradeoffs
 between when data is guaranteed to be on disk and
 performance.   The use of "data=writeback" can cause
 unwritten data to appear in files after an system crash or
 power failure, which can be a security issue.   However,
 "data=ordered" mode can also result in major performance
 problems, including seconds-long delays before an fsync()
 call returns.   For details, see:

 http://ext4.wiki.kernel.org/index.php/Ext3_data_mode_tradeoffs

 If you have been historically happy with ext3's performance,
 data=ordered mode will be a safe choice and you should
 answer 'y' here.  If you understand the reliability and data
 privacy issues of data=writeback and are willing to make
 that trade off, answer 'n'.

 Symbol: EXT3_DEFAULTS_TO_ORDERED [=y]
 Type  : boolean
 Prompt: Default to 'data=ordered' in ext3
   Defined at fs/ext3/Kconfig:31
   Depends on: BLOCK [=y] && EXT3_FS [=y]
   Location:
     -> File systems
       -> Ext3 journalling file system support (EXT3_FS [=y])
 


As far as the OP turning off journaling - I wouldn't do it (I also wouldn't use writeback) on a root partition. I may on some partitions, depending on what they're used for and what kind of backups I have. If you'd explain exactly why you want to do this you might get some better feedback. Personally I would tend to go to the other extreme, use a very large journal and use data=journal mode, but it still depends on the usage of the partition. Something like root, which doesn't get written to that often (depending on your exact partitioning scheme) I would opt for data=journal since I prefer safety in that case. (Note that data=journal also turns off delayed allocation)
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: How to enable data=writeback in ext4

Postby ManilaTux » 2010-12-20 04:50

Yeah, I think I'll lay off this filesystem tweaking for now and just stick with the super awesome "noatime". When I have the time I'll do a proper partition scheme with separate boot and all.

I've been (seriously) using Linux for only two months. Although I've played with several distros in the past, Linux Mint Debian was the one that really got my attention because of the big difference in performance compared to its ubuntu version. After a few days of using Linux Mint Debian I decided to go for the real thing (Debian), which ultimately made me a Linux convert, happily relegating my previous OS as the "plaything".
I use Debian, therefore I am.
User avatar
ManilaTux
 
Posts: 113
Joined: 2010-12-19 12:10
Location: In your mom's bedroom

Re: How to enable data=writeback in ext4

Postby ladoga » 2011-01-05 06:23

ManilaTux wrote: After a few days of using Linux Mint Debian I decided to go for the real thing (Debian), which ultimately made me a Linux convert, happily relegating my previous OS as the "plaything".


I understand completely what you mean.

I made the same choice switching from Ubuntu back in 2004 when I was new to linux. Derivates like Ubuntu or Mint with all their automation are quite complex, thus harder to understand and less suited for tweaking. Debian in it's simplicity is actually very newbie friendly and it's meant to be tailored to ones needs. Possibility for rolling updates (as when using 'testing') makes it less prone to breaking since there's no need for one step upgrade to new release.

It's good there are so many flavors of linux that almost everybody can find one suited for her/himself.
ladoga
 
Posts: 3
Joined: 2006-12-09 00:05
Location: Helsinki, Finland


Return to General Questions

Who is online

Users browsing this forum: sunrat and 10 guests

fashionable