Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The manual page says about the barrier option for ext4:

Write barriers enforce proper on-disk ordering of journal commits, making volatile disk write caches safe to use, at some performance penalty. If your disks are battery-backed in one way or another, disabling barriers may safely improve performance.

Does a laptop with a battery (and an SSD) count as having a battery-backed disk? So, is barrier=0 for ext4 safe on a laptop?

share|improve this question
up vote 14 down vote accepted

No, it doesn't. The issue isn't with the type of disk (spinning/non-spinning), it's with committing disk buffers from RAM to disk. If the power goes out suddenly, some of these buffers may never get committed to disk, and having barriers enabled improves your chances of recovering the filesystem.

There's also an additional issue with the disk's on-board cache never getting committed to the disk (or flash chips). That only applies if you have write caching enabled on the disk (write-back), and can bite you regardless of the setting of barriers.

A battery backed-up disk is usually taken to mean a disk unit run by a controller with a battery backup unit (BBU). They have batteries that can store uncommitted data for months, so a crash or black-out won't lose filesystem consistency. BBUs are typically options on server-grade RAID systems.

Often, a machine with a UPS guaranteed to be working properly (or other guaranteed power source) can be safe too.

I wouldn't do this on a laptop. I've never had ext[234] filesystems mess up on me, even in the ext2 days, but your mileage may vary. You're trading off some performance improvement over the cost (personal/monetary) of data loss. My suggestion: mount the filesystem with and without barriers, run benchmarks, and get an idea of the performance gain. If it's negligible or not worth the risk (which you'll have to assess yourself), leave the mount options as they are.

Addendum: Isn't a laptop battery the same as a UPS? In this case yes, a laptop battery is very similar to a UPS, but a laptop battery isn't as carefully monitored and conditioned as a UPS, because it isn't really designed as a means of redundancy. You buy a UPS for added security, so the design reflects this: the battery is conditioned, checked and monitored. All but the cheapest UPS units have ‘battery failed’ lights, alarms and even send SNMP traps to notify the administrator of the issue.

This isn't the case with laptop batteries. Your laptop battery will age and die without the laptop being aware. Mine's on its second battery, and it's failing: on occasion it just loses a lot of charge in a very short time, and the laptop is none the wiser (when the power goes out, the battery runtime indicator still says ‘30 minutes left’).

My point is that a UPS is more reliable than a laptop batter, but a better question would be...

Isn't a UPS or laptop battery the same as a disk controller BBU? And the answer to that is a resounding no. Your UPS will continue to power a computer that's just been hard-reset, but when the disk is reset, any uncommitted writeback sectors will be lost forever. With a BBU, you can unceremoniously unplug the server, store it for six months, move it to a different country, plug it back in, and the moment you hit the power on button, the uncommitted buffers are (finally) written to disk. Since this may amount to a few gigs of data, the BBU is a pretty essential piece of kit for server hardware. The controller conditions the battery backup much better than the average UPS. On our Dell servers, it runs discharge simulations every week and can send you IM/SMS/Email/SNMP traps/buzz your ears off when it detects that the charge/discharge cycle or expected battery life go out of tolerance. It'll also disable write-caching when the BBU is in a less than optimal condition. It's this sort of environment that gains something from disabling barriers.

In practice, though, any systems manager who insists on battery-backed host adaptors is unlikely to disable a filesystem safety measure. :) (I know I don't)

share|improve this answer
(Thanks for the explanation and the advice! Probably, I won't turn off barriers on a laptop, because the performance gain might be not as important. But I have a question which I just want to understand better: ) Isn't a laptop with battery similar to a machine with a UPS? Would additional configuration of the system be needed for it to be similar to a machine with a UPS? – imz -- Ivan Zakharyaschev May 2 '12 at 11:28
You're welcome. I modified the answer with a rather long-winded explanation. :) – Alexios May 2 '12 at 12:10
+1 for measuring the actual performance difference. – Burhan Ali May 28 '12 at 5:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.