
September 11, 2026
12 min read
By Kokil Thapa | Last reviewed: September 2026
Choosing between Btrfs vs ext4 vs XFS is one of those decisions that looks minor until a disk fills up or a backup fails at 2 a.m. All three ship on modern Linux, but they behave differently under real workloads. On Ubuntu production servers I maintain for Laravel apps, WordPress shops, and legal-tech portals, the filesystem choice affects snapshot strategy, recovery time, and how safely you can grow storage without downtime.
What is the difference between Btrfs vs ext4 vs XFS?
All three are journaled or copy-on-write filesystems for block storage on Linux. They differ in design age, feature set, and operational maturity. Understanding that design gap matters more than chasing synthetic benchmark scores.
ext4 (fourth extended filesystem) evolved from ext2/ext3. It is the default on many Ubuntu installs. It uses extent-based allocation, journal metadata (or full data journaling optionally), and supports volumes up to 1 exbibyte. It is boring, well understood, and hard to break accidentally.
XFS came from Silicon Graphics and excels at parallel I/O on large files. Red Hat and many enterprise distros default to it for data partitions. XFS uses allocation groups to reduce lock contention. Online grow works well; shrink is not supported in place.
Btrfs (B-tree filesystem) is copy-on-write with built-in checksums, subvolumes, snapshots, compression, and optional RAID profiles at the filesystem layer. It targets flexible storage management but carries a longer list of operational caveats on certain workloads.
| Criterion | ext4 | XFS | Btrfs |
|---|---|---|---|
| Design model | Journaled, extent-based | Journaled, allocation groups | Copy-on-write B-trees |
| Default on Ubuntu Server | Root/data common | Optional, popular for /var | Optional (needs explicit choice) |
| Online grow | Yes | Yes | Yes |
| Online shrink | Limited/risky | No | Yes (with planning) |
| Built-in snapshots | No | No (use LVM) | Yes (subvolumes) |
| Data checksums | No (device may) | No (device may) | Yes |
| Small random writes | Strong | Good | Heavier CoW cost |
| Large sequential I/O | Good | Excellent | Good with tuning |
| Operational maturity | Highest | Very high | Good, workload-dependent |
| Typical web-server pick | Safe default | DB/log heavy hosts | When snapshots justify ops |
The kernel treats all three through the same virtual filesystem layer. Your app sees files and directories. Underneath, write patterns, fsync behaviour, and allocator choices differ. That is why server provisioning playbooks should document the filesystem choice per mount point, not only per server.
Which filesystem should you use for a web server?
Most PHP/Laravel and WordPress stacks on Ubuntu 22.04 or 24.04 run fine on ext4. I have deployed dozens of sites on ext4 root plus ext4 or XFS for /var without filesystem-related incidents. The decision splits by workload shape and how you run backups.
When ext4 is the right call
Pick ext4 when you want the path of least surprise. Shared hosting patterns, modest traffic law-firm portals, WooCommerce shops, and typical custom Laravel applications fit here. ext4 handles many small files reasonably well. Recovery tools and community knowledge are deep.
Typical layout on a single-disk VPS:
/— ext4, 20–40 GB, OS and application code/var— ext4 or XFS, logs, MySQL/PostgreSQL data, uploads- Separate backup target — object storage or another server, not same-disk snapshots alone
When XFS earns its place
Choose XFS when the server stores large media libraries, heavy log volume, or database files that grow big and fast. On booking systems and eCommerce platforms with substantial product images, XFS on a dedicated data mount often scales more smoothly. XFS performs well when many threads write concurrently.
Important constraint: you cannot shrink an XFS filesystem in place. Plan partition sizes up front. Growing online is straightforward:
sudo xfs_growfs /var/lib/mysql
For ext4 growth after expanding the underlying volume:
sudo resize2fs /dev/vg0/data
When Btrfs makes sense
Btrfs shines when you want cheap local snapshots before deployments or package upgrades. On sister sites I maintain with Deployer 7 and GitLab CI, a pre-deploy snapshot can shorten rollback time when opcache or permissions go wrong. Btrfs is not a substitute for off-site backups though.
Enable compression for read-heavy static assets if CPU headroom exists:
sudo mount -o compress=zstd:3 /dev/sdb1 /srv/backups
Avoid Btrfs for database data directories unless you understand CoW overhead and disable copy-on-write on those paths:
sudo chattr +C /var/lib/mysql
The +C flag sets the NOCOW attribute before files are created. Applying it after data exists requires migration.
How do you benchmark Btrfs vs ext4 vs XFS before choosing?
Do not pick a filesystem from a single blog benchmark. Test your actual workload on staging hardware that matches production. A Nepal VPS with 2 vCPU and NVMe behaves differently from a bare-metal RAID10 box.
Tools that produce useful signal
- fio — synthetic I/O with configurable block sizes and fsync patterns. Mimic database and upload behaviour.
- ioping — quick latency check for random small writes. Relevant for heavy session or cache files.
- Real app smoke test — import a MySQL dump, run Laravel migrations, warm opcache, then measure deploy time.
- Disk space drill — fill
/varto 90% and observe behaviour. Some filesystems degrade gracefully; others stall hard.
Example fio job simulating mixed web workload:
fio --name=webmix --directory=/mnt/test --rw=randrw --rwmixread=70 \
--bs=4k --size=2G --numjobs=4 --iodepth=32 --runtime=120 --group_reporting
Run the same job on each candidate filesystem after a clean mkfs. Record IOPS, latency p99, and CPU usage. Btrfs often shows higher CPU on small random writes due to checksums and CoW. XFS frequently leads on large sequential throughput. ext4 sits in the middle for mixed small-file work.
Interpreting results for PHP stacks
Laravel and WordPress spend significant time in the database, not raw filesystem throughput. MySQL 9.7 or PostgreSQL 18 on a properly sized innodb_buffer_pool or shared_buffers cache reduces disk pressure. Filesystem choice matters most for logs, uploads, backup windows, and full-table scans.
On production booking platforms with Livewire and frequent writes, I watch fsync latency more than peak MB/s. A filesystem that spikes latency under fsync load hurts checkout flows more than a lower sequential score.
Use the JSON formatter to inspect benchmark output exported from monitoring agents if you pipe results into JSON logs. Consistent formatting speeds comparison across test runs.
How do snapshots and backups differ across Btrfs vs ext4 vs XFS?
Backups and snapshots solve different problems. Snapshots are fast, local, and point-in-time. Backups are off-site and survive fire, theft, ransomware, and operator error. Your filesystem choice affects snapshot ergonomics, not backup replacement.
ext4 and XFS snapshot options
Neither ext4 nor XFS provides native per-directory snapshots. You typically use LVM thin snapshots, hardware RAID snapshots, or hypervisor-level snapshots on cloud VPS platforms. LVM snapshots on ext4/XFS are proven but need free space in the volume group. Long-lived snapshots hurt write performance as copy-on-write accumulates.
sudo lvcreate -L 10G -s -n www_snap /vg0/www_data
Btrfs native snapshots
Btrfs snapshots are subvolume-level and cheap at creation time. They fit pre-deploy hooks:
sudo btrfs subvolume snapshot / /snapshots/pre-deploy-$(date +%F-%H%M)
Send/receive supports incremental off-site replication to another Btrfs volume:
sudo btrfs send -p /snapshots/base /snapshots/incr1 | ssh backuphost btrfs receive /backups/host1
Schedule btrfs scrub monthly on production arrays to verify checksums. Scrub reads every block and repairs from RAID mirrors when possible. Document scrub windows in your maintenance runbook.
For server migrations, filesystem choice affects dump-and-restore time. XFS-to-XFS block copy via rsync or LVM move is routine. Converting ext4 to Btrfs in place is possible with btrfs-convert but plan a maintenance window and verify boot loader support.
When should you avoid Btrfs on production Linux servers?
Btrfs is production-ready for many workloads on current kernels. Still, certain patterns cause pain. I treat Btrfs as a deliberate opt-in, not the default for client VPS instances unless snapshots are a stated requirement.
Workloads that fight Btrfs
- Database directories without NOCOW — MySQL, PostgreSQL, and Redis AOF files on CoW paths can fragment and slow down under sustained random writes.
- Very small VPS disks — Btrfs metadata overhead and the need for free space for balance operations hurt on 20 GB root volumes.
- Nested RAID5/6 Btrfs profiles — write hole issues historically plagued RAID5/6; mirror or RAID10 at hardware level is safer for critical data.
- Heavy swap on Btrfs — disable CoW on swap files or use a dedicated swap partition formatted ext4.
- Teams without scrub/monitor discipline — checksums help only if you act on scrub results and monitor
btrfs device stats.
Check filesystem health regularly:
sudo btrfs filesystem show
sudo btrfs device stats /
sudo dmesg | grep -i btrfs
ext4 and XFS also need monitoring. Run e2fsck after unclean shutdown. Watch XFS for XFS error messages in dmesg after power loss. No filesystem removes the need for disk and inode alerting.
Cloud and hosting realities in Nepal
Many Nepal businesses run on budget VPS plans from local or regional providers. Disks are often single NVMe without hardware RAID. In that world, ext4 or XFS plus automated off-site backups beats exotic filesystem features. Rs 1,500–3,000/month (~USD 11–22) VPS tiers rarely include snapshot APIs; you build your own with restic or Borg.
When clients ask about hosting and domain setup, I document mount layout in the handover notes. The next developer should know whether /var/www shares root or lives on a separate volume and which filesystem backs it.
Kernel and distro alignment
Ubuntu 24.04 LTS and current RHEL-family releases ship mature XFS and Btrfs tooling. Always match documentation to your kernel line. The official kernel documentation at docs.kernel.org filesystem index is the authoritative feature reference. For Btrfs administration detail, the wiki at btrfs.readthedocs.io covers subvolumes, balance, and device management. Red Hat documents XFS capacity and repair at Red Hat file system overview.
After a web stack migration, revalidate mount options. noatime remains a sensible default on all three filesystems for web roots. Avoid aggressive tuning until metrics justify it.
Key Takeaways
- Default to ext4 for general-purpose Ubuntu web servers unless metrics or features push you elsewhere.
- Put large MySQL data, media stores, and heavy log volumes on XFS when you can size partitions without needing shrink.
- Choose Btrfs when local snapshots and checksums justify extra operational overhead and you will run scrubs.
- Benchmark with fio and real app tests; fsync latency often matters more than peak throughput for PHP stacks.
- Never treat filesystem snapshots as backups—schedule off-site copies regardless of Btrfs vs ext4 vs XFS.
- Document mount layout and filesystem type in provisioning docs so migrations and disaster recovery stay predictable.
People Also Ask
Is Btrfs stable enough for production in 2026?
Yes, for many Linux server workloads on current kernels and when you follow documented best practices. Facebook and several distros use Btrfs at scale. Still, teams that will not run scrubs or configure NOCOW on database paths should prefer ext4 or XFS for lower operational risk.
Is XFS faster than ext4?
XFS often leads on large-file sequential I/O and highly parallel writes. ext4 frequently matches or wins on small random file workloads typical of PHP codebases and WordPress installs. The gap narrows on SSD and NVMe hardware with adequate RAM for caching.
Can you convert ext4 to Btrfs without losing data?
The btrfs-convert utility can convert ext4 in place on unmounted or carefully prepared volumes. Always take a full backup first. Boot loader and snapshot layout need review after conversion. For production, a clean mkfs plus rsync migration is usually cleaner.
Which filesystem does Ubuntu Server use by default?
Ubuntu Server installs ext4 on the root filesystem by default. You can choose manual partitioning and select XFS or Btrfs during install. Cloud images from major providers may differ; check with findmnt -no FSTYPE / on first login.
Pick the filesystem your ops team can support
The honest summary for Btrfs vs ext4 vs XFS on web servers: ext4 is the default because it is predictable. XFS is the performance choice for big data mounts. Btrfs is the feature-rich option when snapshots and checksums match your runbook. None of them replace backups, monitoring, or correct mount sizing.
If you are provisioning a new server, migrating hosts, or unsure whether your current disk layout will survive the next deploy, I can review your stack and recommend a layout that fits Laravel, WordPress, or custom app workloads. See Linux system administration services, browse the portfolio for production examples, or contact us to discuss your hosting setup.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

