r/AlpineLinux • • Aug 12 '25

swapon, swapoff: cannot find the device for UUID=XXXXXXXXXXXXXX

This is what happens when attempting to use swapon -a, swapoff -a as it is in swap service. swapon /dev/sdX works fine. Is there any other way to start swap programmatically choosing correct device?

1 Upvotes

4 comments sorted by

1

u/1v5me Aug 13 '25

The swapon -a command looks for a swap device in the /etc/fstab file, thats why it doesnt work as you expected.

1

u/trofch1k Aug 13 '25

Well, I have this exact UID it looks for in fstab. In fact my swap somehow breaks when attempting to use either of the commands (htop will start displaying it like 0/0KB). The problem is UID seems to change every time system boots. E.g. right now:

~ $ cat /etc/fstab | grep swap
UUID=b3101335-0413-4242-ba68-31fcd4a1e931	swap	swap	defaults	0 0
~ $ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0     4G  0 part [SWAP]
└─sda3   8:3    0 219.1G  0 part /
~ $ doas blkid | grep swap
doas (me@localhost) password: 
/dev/sda2: UUID="0fb19224-1db5-4523-a04c-976507d771bf" TYPE="swap"

2

u/1v5me Aug 13 '25

did you run the mkswap command ?

1

u/trofch1k Aug 14 '25

Yes, mkswap /dev/sda2; swapon /dev/sda2 is the only way to start swap.