From 03956b26c46c61c72554222fd0c69c99a50384ef Mon Sep 17 00:00:00 2001
From: Felix Tenley <dev@felschr.com>
Date: Wed, 9 Feb 2022 21:04:01 +0100
Subject: [PATCH] fix(scripts): fix creation of swapfile with holes

---
 scripts/setup-partitions | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/setup-partitions b/scripts/setup-partitions
index 9104e5d..d00421a 100755
--- a/scripts/setup-partitions
+++ b/scripts/setup-partitions
@@ -75,7 +75,7 @@ mount -o subvol=@,compress-force=zstd,noatime /dev/mapper/enc /mnt
 mkdir /mnt/home
 mount -o subvol=@home,compress-force=zstd,noatime /dev/mapper/enc /mnt/home
 mkdir /mnt/.swap
-mount -o subvol=@swap,noatime /dev/mapper/enc /mnt/swap
+mount -o subvol=@swap,noatime /dev/mapper/enc /mnt/.swap
 mkdir /mnt/.snapshots
 mount -o subvol=@snapshots,compress-force=zstd,noatime /dev/mapper/enc /mnt/.snapshots
 mkdir /mnt/boot
@@ -84,7 +84,8 @@ mount "$boot" /mnt/boot
 # setup swap file
 truncate -s 0 /mnt/.swap/swapfile
 chattr +C /mnt/.swap/swapfile
-fallocate -l 8G /mnt/.swap/swapfile
+btrfs property set /mnt/.swap/swapfile compression none
+dd if=/dev/zero of=/mnt/.swap/swapfile bs=1M count=8192 status=progress
 chmod 600 /mnt/.swap/swapfile
 mkswap /mnt/.swap/swapfile
 swapon /mnt/.swap/swapfile