On 2017-11-28 07:31, Cristian wrote:
Hello,
Report in:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1723449
dmesg:
[ 3.782191] swapon: swapfile has holes
As mentioned in the linked bug report, this is a known issue. To use a
swap file on BTRFS, you need to:
1. Create an empty file.
2. Mark it NOCOW with `chattr +C`
3. Use fallocate to pre-allocate to the appropriate size.
4. Hook it up to a loop device.
5. Use the loop device for swap.
This is because the kernel needs a consistent block mapping for a swap
file, since it bypasses the filesystem and accesses the block device
directly. However, since BTRFS has copy-on-write semantics, blocks move
around on each write, which violates the requirement for a consistent
block mapping, you can't use a file on a BTRFS filesystem directly as a
swap file.
Of the above steps, you technically don't need to mark the file NOCOW or
pre-allocate it, but those are good practice to remove random latency.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html