🌊

Timeshift and Swapfile on Btrfs FileSystem

2023/11/29に公開

Btrfsファイルシステムでswapfileを用いている場合に、Timeshiftでバックアップしようとするとエラーが出る場合があります。
SwapfileがBusy状態扱いで、excludeで例外指定しても、うまくいきませんでした。
そこで、Github issue[1]を参考にして、btrfsのサブボリューム上に、swapfileを配置したところ、無事にTimeshiftのsnapshotが作成できるようになりました。

以下、手順の概略です。

mount -t btrfs /dev/sXY /mnt
btrfs subvolume create /mnt/@swap
chattr -R +C /mnt/@swap
truncate -s 0 /mnt/@swap/swapfile
fallocate -l 8G /mnt/@swap/swapfile
chmod 600 /mnt/@swap/swapfile
mkswap /mnt/@swap/swapfile
mkdir -p /swap

/etc/fstabに@swapサブボリュームを加え、/swapにマウントします。

/etc/fstab
UUID    /swap  btrfs    subvol=@swap,defaults
/swap/swapfile  none    swap    defaults,pri=0 0 0
脚注
  1. Swapfile on Btrfs error: Text file busy / btrfs returned an error: 256 / Failed to create snapshot · Issue #629 · teejee2008/timeshift ↩︎

Discussion