You are not logged in.

#1 2023-10-15 18:26:07

malonn
Member
Registered: 2023-09-28
Posts: 49

Trouble getting btrfs swap file to work

I am trying to set up a btrfs swap file.  I have a subvolume like here "/@swap".  I followed the wiki closely, except one thing, as I want my subvolume to be separate so it's not included in snapshots.
Here's the relevant entries in my fstab

# /dev/nvme0n1p2
UUID=cea5a1ce-d366-4569-a5c7-beb127742c6d	/swap       btrfs	rw,ssd,nodatacow,subvol=/@swap  0 0
/swap/swapfile								none 	  swap 	defaults  0 0

The partition is not a dedicated swap partition.  My boot process has an error which is

Oct 15 13:48:30 archlinux systemd[1]: Failed to activate swap /swap/swapfile.
Oct 15 13:48:30 archlinux systemd[1]: Dependency failed for Swaps.
Oct 15 13:48:30 archlinux systemd[1]: swap.target: Job swap.target/start failed with result 'dependency'.

What have I done wrong?  I'm pretty new to btrfs, brand new to btrfs swap files.


AMD Ryzen 5 5600X
XFX Swift Radeon RX 6800
16GB G.Skill Trident Z Neo
ASRock B550 PG Velocita

Offline

#2 2023-10-15 18:40:46

malonn
Member
Registered: 2023-09-28
Posts: 49

Re: Trouble getting btrfs swap file to work

I figured it out.  The wiki is somewhat misleading, I believe (at least, it was not clear to me).
This is what I had to do:

1) create the appropriate fstab entries (as seen in original post) and copy to /etc
2) mount the chosen directory (/swap in my case).  This reads from fstab.  Or skip #1 and just mount the subvolume.
3) follow the wiki page for btrfs swap creation

I say the wiki is "misleading" because they mention mounting the subvolume as a tip, not a required step.  That's how I took it—a helpful thing, yet not necessary.  That could merely be how I took it, but I think it could still stand to be more clear.
Should I propose an edit?  I'm going to, and it can always be rejected.

Last edited by malonn (2023-10-16 09:08:34)


AMD Ryzen 5 5600X
XFX Swift Radeon RX 6800
16GB G.Skill Trident Z Neo
ASRock B550 PG Velocita

Offline

#3 2023-10-16 09:07:23

malonn
Member
Registered: 2023-09-28
Posts: 49

Re: Trouble getting btrfs swap file to work

Turns out, top-level subvolumes must be mounted prior to generating the swap file.  Nested subvolumes do not need to be mounted.  All of my manually created subvolumes are top-level.

Of course, my way of editing fstab first is not the only way of doing it (the mount command can be used too), that's just where my searching lead me.  I'm pretty green to Linux in general, and definitely Arch.

Maybe this post will assist someone in the future.


AMD Ryzen 5 5600X
XFX Swift Radeon RX 6800
16GB G.Skill Trident Z Neo
ASRock B550 PG Velocita

Offline

Board footer

Powered by FluxBB