You are not logged in.

#1 2025-08-06 10:17:32

archdub
Member
From: Dublin, Ireland
Registered: 2018-03-04
Posts: 91

Unable to locate executable '/sbin/swapon'

For many years i have had the hooks array below in mkinitcpio.conf. Swap works well, no errors in dmes/journal. It uses busybox.
HOOKS=(base udev autodetect  microcode modconf kms keyboard keymap consolefont block filesystems resume fsck zfs)

I decided to try systemd instead of busybox, like so:
HOOKS=(base systemd shadowcopy microcode modconf kms keyboard keymap consolefont block filesystems resume fsck zfs)

With systemd there are two attempts at enabling swap, the first fails and the second succeeds as shown below. Swap is on at the end of boot.

The error message says“ Unable to locate executable '/sbin/swapon': No such file or directory”.

Any ideas why swapon cannot be found? /sbin is of course a symbolic link to /usr/bin, and there is swapon there. It seems that it is not in initramfs-linux-lts61.img though. I tried several permutations of the hooks array, for example, removing resume which in principle should not be needed, removing shadowcopy, with autodetect, etc, but it made no difference, swapon could not be found.

Any ideas how to fix this?

	~/ journalctl -b | grep -i swap
	Aug 05 17:09:56 archlinux kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-linux-lts61 root=UUID=94b2e777-6a16-47b1-b03a-de31c1ac50f7 rw loglevel=4 resume=LABEL=swap libata.noacpi=1 nvidia-drm.modeset=1
	Aug 05 17:09:56 archlinux kernel: Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux-lts61 root=UUID=94b2e777-6a16-47b1-b03a-de31c1ac50f7 rw loglevel=4 resume=LABEL=swap libata.noacpi=1 nvidia-drm.modeset=1
	Aug 05 17:09:56 archlinux kernel: Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization
	Aug 05 17:09:56 archlinux kernel: zswap: loaded using pool lz4/zbud
	Aug 05 17:09:56 archlinux systemd[1]: Expecting device /dev/disk/by-label/swap...
	Aug 05 17:09:56 archlinux systemd[1]: Found device ST2000DM001-9YN164 swap.
	Aug 05 17:09:56 archlinux systemd[1]: Found device ST2000DM001-9YN164 swap.
	Aug 05 17:09:56 archlinux systemd[1]: Activating swap /dev/disk/by-uuid/c45a54f3-1227-4047-8f0e-e570d48df4b7...
	Aug 05 17:09:56 archlinux (swapon)[285]: dev-disk-by\x2duuid-c45a54f3\x2d1227\x2d4047\x2d8f0e\x2de570d48df4b7.swap: Unable to locate executable '/sbin/swapon': No such file or directory
	Aug 05 17:09:56 archlinux (swapon)[285]: dev-disk-by\x2duuid-c45a54f3\x2d1227\x2d4047\x2d8f0e\x2de570d48df4b7.swap: Failed at step EXEC spawning /sbin/swapon: No such file or directory
	Aug 05 17:09:56 archlinux systemd[1]: dev-disk-by\x2duuid-c45a54f3\x2d1227\x2d4047\x2d8f0e\x2de570d48df4b7.swap: Swap process exited, code=exited, status=203/EXEC
	Aug 05 17:09:56 archlinux systemd[1]: dev-disk-by\x2duuid-c45a54f3\x2d1227\x2d4047\x2d8f0e\x2de570d48df4b7.swap: Failed with result 'exit-code'.
	Aug 05 17:09:56 archlinux systemd[1]: Failed to activate swap /dev/disk/by-uuid/c45a54f3-1227-4047-8f0e-e570d48df4b7.
	Aug 05 17:09:56 archlinux systemd[1]: Dependency failed for Swaps.
	Aug 05 17:09:56 archlinux systemd[1]: swap.target: Job swap.target/start failed with result 'dependency'.

	Aug 05 17:10:08 arch-tornado systemd[1]: Found device ST2000DM001-9YN164 swap.
	Aug 05 17:10:08 arch-tornado systemd[1]: Activating swap /dev/disk/by-uuid/c45a54f3-1227-4047-8f0e-e570d48df4b7...
	Aug 05 17:10:08 arch-tornado kernel: Adding 26213372k swap on /dev/sda1.  Priority:-2 extents:1 across:26213372k FS
	Aug 05 17:10:08 arch-tornado systemd[1]: Activated swap /dev/disk/by-uuid/c45a54f3-1227-4047-8f0e-e570d48df4b7.
	Aug 05 17:10:09 arch-tornado systemd[1]: Reached target Swaps.

Offline

#2 2025-08-06 10:32:28

StarWolf3000
Member
Registered: 2025-06-23
Posts: 32

Re: Unable to locate executable '/sbin/swapon'

Post output of

ls -l /sbin/swapon

Mainboard: GIGABYTE B550 AORUS ELITE V2 | CPU: Ryzen 7 5800X | RAM: 32 GB
GPU: GeForce RTX 4060 8 GB (575.64.05 proprietary) | Display: BenQ BL2405 1920x1080
Kernel: 6.15.9 stable | Boot Manager: GRUB2 | DE: KDE Plasma | Login Manager: SDDM | Window Manager: KWin (Wayland)

Offline

#3 2025-08-06 10:42:48

archdub
Member
From: Dublin, Ireland
Registered: 2018-03-04
Posts: 91

Re: Unable to locate executable '/sbin/swapon'

StarWolf3000 wrote:

Post output of

ls -l /sbin/swapon
~/ ls -l /sbin/swapon
-rwxr-xr-x 1 root root 43104 Jun 24 11:45 /sbin/swapon

Offline

#4 2025-08-06 12:14:19

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 69,157

Re: Unable to locate executable '/sbin/swapon'

The file is missing in the initramfs, not on disk.
This is a bit odd (never used systemd init) but you could add it to the FILES array.

Smells like a bug, though - are there any errors from "mkinitcpio -P"?

Offline

#5 2025-08-06 14:09:21

archdub
Member
From: Dublin, Ireland
Registered: 2018-03-04
Posts: 91

Re: Unable to locate executable '/sbin/swapon'

“are there any errors from "mkinitcpio -P"?” – No errors, only the bunch of usual warnings about missing firmware.

“Smells like a bug” – I did a quick search in systemd github issues and found nothing related to this. If it is a bug i would guess it is in mkinitcpio.

I followed your suggestion and added swapon to both BINARIES and FILES arrays. Strangely both had the same effect: a) swapon succeed at the first try; b) swap was indeed on at the end of boot, and c) there were about 100 lines of errors in the journal that appears after the successful enabling of swap.

I am pasting below just the beginning of this long list of errors, as they are repetitive.

~/ journalctl -b | grep -i swap
Aug 06 14:39:17 archlinux kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-linux-lts61 root=UUID=94b2e777-6a16-47b1-b03a-de31c1ac50f7 rw loglevel=4 resume=LABEL=swap libata.noacpi=1 nvidia-drm.modeset=1
Aug 06 14:39:17 archlinux kernel: Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux-lts61 root=UUID=94b2e777-6a16-47b1-b03a-de31c1ac50f7 rw loglevel=4 resume=LABEL=swap libata.noacpi=1 nvidia-drm.modeset=1
Aug 06 14:39:17 archlinux kernel: Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization
Aug 06 14:39:17 archlinux kernel: zswap: loaded using pool lz4/zbud
Aug 06 14:39:17 archlinux systemd[1]: Expecting device /dev/disk/by-label/swap...
Aug 06 14:39:17 archlinux systemd[1]: Found device ST2000DM001-9YN164 swap.
Aug 06 14:39:17 archlinux systemd[1]: Found device ST2000DM001-9YN164 swap.
Aug 06 14:39:17 archlinux systemd[1]: Activating swap /dev/disk/by-uuid/c45a54f3-1227-4047-8f0e-e570d48df4b7...
Aug 06 14:39:17 archlinux kernel: Adding 26213372k swap on /dev/sda1.  Priority:-2 extents:1 across:26213372k FS
Aug 06 14:39:17 archlinux systemd[1]: Activated swap /dev/disk/by-uuid/c45a54f3-1227-4047-8f0e-e570d48df4b7.
Aug 06 14:39:17 archlinux systemd[1]: Reached target Swaps.
Aug 06 14:39:18 archlinux systemd[1]: Stopped target Swaps.
Aug 06 14:39:24 arch-tornado systemd[1]: Reached target Swaps.
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2ddiskseq-1\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dlabel-swap.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2did-ata\x2dST2000DM001\x2d9YN164_W1E2296R\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart-by\x2dpartnum-1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-sda1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart-by\x2dpartuuid-000402a7\x2d01.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart-by\x2dlabel-swap.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart-by\x2duuid-c45a54f3\x2d1227\x2d4047\x2d8f0e\x2de570d48df4b7.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2did-wwn\x2d0x5000c5005b598e90\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpartuuid-000402a7\x2d01.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2ddiskseq-1\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2did-ata\x2dST2000DM001\x2d9YN164_W1E2296R\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart-by\x2dpartnum-1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2did-wwn\x2d0x5000c5005b598e90\x2dpart1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart-by\x2duuid-c45a54f3\x2d1227\x2d4047\x2d8f0e\x2de570d48df4b7.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dlabel-swap.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-sda1.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpartuuid-000402a7\x2d01.swap: Cannot add dependency job, ignoring: No such file or directory
Aug 06 14:39:33 arch-tornado systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:1f.2\x2data\x2d1.0\x2dpart-by\x2dlabel-swap.swap: Cannot add dependency job, ignoring: No such file or directory

Offline

#6 2025-08-06 14:24:31

archdub
Member
From: Dublin, Ireland
Registered: 2018-03-04
Posts: 91

Re: Unable to locate executable '/sbin/swapon'

These errors are on my main PC, a very old one. I also have a 2019 Thinkpad, that I use only on my rare travels, where I have mkinitcpio with systemd. In the laptop there is no error with swap, however the configuration is different: on the desktop it is bios with unencrypted partition, whereas on the laptop it is EFI with encrypted partition.

Offline

#7 2025-08-06 16:36:02

archdub
Member
From: Dublin, Ireland
Registered: 2018-03-04
Posts: 91

Re: Unable to locate executable '/sbin/swapon'

In another experiment, I returned the FILES and BINARIES arrays to their original state, that is, empty. I then hacked the systemd hook as follows (last line in the excerpt):

build() {
    local rules unit

    map add_module 'crypto-lzo' 'crypto-lz4'

    add_binary /usr/bin/kmod /usr/bin/modprobe
    add_binary /usr/bin/mount
    add_binary /usr/bin/sulogin
    add_binary /usr/bin/umount
    add_binary /usr/lib/systemd/systemd /init

    #mine
    add_binary /usr/bin/swapon /sbin/swapon

The result of adding swapon to the systemd hook was the same as adding it to FILES or BINARIES arrays, namely the swap target succeeded the first time, but failed the second time, but with even more errors, about 200 lines of errors.

So although adding swapon to the systemd hook is trivial and it seems consistent with the rest of the existing systemd hook code, I have no idea why the swap target is triggered twice.

Offline

#8 2025-08-06 16:47:27

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 69,157

Re: Unable to locate executable '/sbin/swapon'

Please don't bump.
Edit you previous post to mend it if nobody has yet replied.

I'm pretty sure that this would be a bug in mkinitcpio since systemd isn't responsible for creating that wink
You'd probably want

map add_systemd_unit
…
swap.target \
…

to do the right thing, but

[Unit]
Description=Swaps
Documentation=man:systemd.special(7)

won't trigger anything in that function.
The next question is, wtf would one enable swap in the initramfs anyway - if you're swapping at this point you need more RAM wink

Offline

#9 2025-08-06 16:58:21

archdub
Member
From: Dublin, Ireland
Registered: 2018-03-04
Posts: 91

Re: Unable to locate executable '/sbin/swapon'

"You'd probably want"
what you suggest, adding swap.target, is already in the original code of the hook, line 108.

"The next question is, wtf would one enable swap in the initramfs anyway - if you're swapping at this point you need more RAM"
Because of hibernate, I guess. I have in the kernel command line "resume=LABEL=swap". Perhaps the first attempt at turning swap on might be caused not by the swap target but by systemd taking an action on the kernel command line parameters, that would explain why it appears to try to turn swap on twice.

Offline

#10 2025-08-06 20:13:16

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 69,157

Re: Unable to locate executable '/sbin/swapon'

what you suggest, adding swap.target, is

not what I suggested at all -

seth wrote:

You'd probably want [foo] to do the right thing

ie add_systemd_unit for swap.target should™ include all relevant files and binaries.

Because of hibernate, I guess.

Hibernation uses swap partitions/files but does absolutely not require them to be swapon'd or used as swap.

https://gitlab.archlinux.org/archlinux/ … o/-/issues but it frankly seems wild that this is broken, either nobody uses the systemd mode or nobody uses swap space.
Do you list the swap in your /etc/fstab?

Offline

#11 2025-08-06 21:13:38

archdub
Member
From: Dublin, Ireland
Registered: 2018-03-04
Posts: 91

Re: Unable to locate executable '/sbin/swapon'

“Do you list the swap in your /etc/fstab?”
Yes

“but it frankly seems wild that this is broken, either nobody uses the systemd mode or nobody uses swap space.”
Indeed, it seems odd, however since enabling swap succeeds on the second attempt, people would notice the oddity of failing in the first attempt only if they check the journal, which not everyone does on a regular basis, I guess.

Although this is a minor issue I have just reported it, we will see what the experts say:
https://gitlab.archlinux.org/archlinux/ … issues/287

Seth, thanks a lot for your help.

Offline

Board footer

Powered by FluxBB