20

btrfs (often pronounced "better fs") has quite a few features that ext4 lacks.

However, comparing the functionality of btrfs vs ext4, what is lacking in btrfs?1

In other words, what can I do with ext4 that I can't with btrfs?

1 Ignoring the lesser battle-ground testing of btrfs given ext4 is so widely used

Tom Hale
  • 28,728
  • 32
  • 139
  • 229
  • 3
    "Better" and "worse" are always relative to a purpose. So, from what point of view do you want to compare them? – Satō Katsura May 10 '17 at 11:12
  • I would argue also at which point btrfs is mature enough and if it is a wise decision SuSE using it on production systems as the default, but them we are entering the off-topic realm; nevertheless, both answers to this question are pretty interesting. Tom, could you somewhat try to rework the question for it not to be closed as too broad or off-topic? – Rui F Ribeiro May 10 '17 at 12:38
  • 1
    My first thought is "swap files" – anna328p May 10 '17 at 15:48
  • I think you meant that ext4 is "widely", not "wildly" used. But I like "wildly" better. – Alex D May 11 '17 at 09:53
  • A reliable fsck. – Martin Schröder May 18 '17 at 22:48
  • @MartinSchröder btrfs is [fairly self-healing and does have fsck](https://btrfs.wiki.kernel.org/index.php/FAQ#When_will_Btrfs_have_a_fsck_like_tool.3F), what leads you to believe it is unreliable? – Tom Hale May 19 '17 at 05:16

2 Answers2

32

Disadvantages of btrfs compared to ext4:

  1. btrfs doesn't support badblocks

    This means that if you've run out of spare non-addressable sectors that the HDD firmware keeps to cover for a limited number of failures, there is no way to mark blocks bad and avoid them at the filesystem level.

  2. Swap files are only supported via a loopback device, which complicates things because it seems impossible to resume from suspend using this method

  3. It's quite tricky to calculate free space, so much so that...

  4. You can get "No space left on device" errors even though btrfs' own tools say there is space

Tom Hale
  • 28,728
  • 32
  • 139
  • 229
  • 1
    I put btrfs on my daughter's computer and number 4 has been a real pain. I do not recommend btrfs for anyone that doesn't know what they are getting in to. – David Baucum May 11 '17 at 00:11
  • Why would you want to use it on a computer? – Freedo May 11 '17 at 09:13
  • @DavidBaucum Fully agree on "look before you leap". My preference is to use compression and store more data and run the occasional `btrfs balance`. One can always do `dd if=/dev/urandom of=file; ls -lh file; rm file` to know what's usable, if you can wear a momentary `No space left on device`. – Tom Hale May 11 '17 at 13:31
  • swap file has been supported since kernel 5.0, no need for a loopback device anymore – phuclv Sep 02 '22 at 09:58
16

As pointed out in the comments there is support for swap files as of kernel 5.0. albeit with some limitations, as listed at https://btrfs.readthedocs.io/en/latest/btrfs-man5.html:

SWAPFILE SUPPORT

A swapfile is file-backed memory that the system uses to temporarily offload the RAM. It is supported since kernel 5.0. Use swapon(8) to activate the swapfile. There are some limitations of the implementation in BTRFS and linux swap subsystem:

  • filesystem - must be only single device
  • filesystem - must have only single data profile
  • swapfile - the containing subvolume cannot be snapshotted
  • swapfile - must be preallocated
  • swapfile - must be nodatacow (ie. also nodatasum)
  • swapfile - must not be compressed

Previous answer:

A major disadvantage (especially in regards to Ubuntu switching to swap files on new installations) is that butter FS (as I like to pronounce it) does not support swapping files, see FAQ - Does btrfs support swap files? | btrfs Wiki :

Does btrfs support swap files?

Currently no. Just making a file NOCOW does not help, swap file support relies on one function that btrfs intentionally does not implement due to potential corruptions. The swap implementation used to rely on some assumptions which may not hold in btrfs, like block numbers in the swap file while btrfs has a different block number mapping in case of multiple devices. There is a new API that could be used to port swap to btrfs; for more details have a look at project ideas#Swap file support.

A workaround, albeit with poor performance, is to mount a swap file via a loop device.

phk
  • 5,893
  • 7
  • 41
  • 70
  • 1
    this is [outdated](https://btrfs.wiki.kernel.org/index.php/FAQ#Does_Btrfs_support_swap_files.3F). Btrfs already has [swapfile support](https://btrfs.readthedocs.io/en/latest/btrfs-man5.html#swapfile-support) long ago, since kernel 5.0 – phuclv Sep 02 '22 at 09:57