Test5: // How many times do "dphys-swapfile setup" run
# nano -w /usr/local/bin/swapsetup.cmd
#!/bin/bash
if output=$("/sbin/dphys-swapfile" "setup"); then
    printf 'SwapSetupTrue «%s»\n' "$output"
    logger SwapSetupLogTrue $output
else
    printf 'SwapSetupFailed «%s»\n' "$output"
    logger SwapSetupLogFailed $output
fi
exit $output

# chmod +x /usr/local/bin/swapsetup.cmd
# nano -w /lib/systemd/system/dphys-swapfile.service
ExecStart=/usr/local/bin/swapsetup.cmd        // Old:
ExecStart=/sbin/dphys-swapfile setup

Restart

# journalctl|grep SwapSetup
Aug 22 19:08:21 irena swapsetup.cmd[391]: SwapSetupFailed ?want
/var/swap=1024MByte?
Aug 22 19:08:21 irena root[425]: SwapSetupLogFailed want /var/swap=1024MByte
# journalctl|grep -i swap
Aug 22 19:08:14 irena kernel: Kernel command line:
bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1080 bcm2708_fb.fbswap=1
dma.dmachans=0x7f35 bcm2709.boardrev=0xa01041
bcm2709.serial=0xfc2d2698 bcm2709.uart_clock=48000000
bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0
smsc95xx.macaddr=B8:27:EB:2D:26:98 vc_mem.mem_base=0x3ec00000
vc_mem.mem_size=0x40000000  dwc_otg.lpm_enable=0 console=tty0
console=${serial} root=/dev/mmcblk0p3 rootfstype=f2fs
elevator=deadline fsck.repair=yes rootwait cma=416M
Aug 22 19:08:14 irena kernel: zswap: loaded using pool lzo/zbud
Aug 22 19:08:14 irena systemd[1]: Reached target Swap.
Aug 22 19:08:20 irena systemd[1]: Starting dphys-swapfile - set up,
mount/unmount, and delete a swap file...
Aug 22 19:08:21 irena swapsetup.cmd[391]: SwapSetupFailed ?want
/var/swap=1024MByte?
Aug 22 19:08:21 irena root[425]: SwapSetupLogFailed want /var/swap=1024MByte
Aug 22 19:08:21 irena swapsetup.cmd[391]:
/usr/local/bin/swapsetup.cmd: line 9: exit: want: numeric argument
required
Aug 22 19:08:21 irena systemd[1]: dphys-swapfile.service: Main process
exited, code=exited, status=2/INVALIDARGUMENT
Aug 22 19:08:21 irena systemd[1]: dphys-swapfile.service: Failed with
result 'exit-code'.
Aug 22 19:08:21 irena systemd[1]: Failed to start dphys-swapfile - set
up, mount/unmount, and delete a swap file.
# journalctl|grep -i dphys-swapfile
Aug 22 19:08:20 irena systemd[1]: Starting dphys-swapfile - set up,
mount/unmount, and delete a swap file...
Aug 22 19:08:21 irena systemd[1]: dphys-swapfile.service: Main process
exited, code=exited, status=2/INVALIDARGUMENT
Aug 22 19:08:21 irena systemd[1]: dphys-swapfile.service: Failed with
result 'exit-code'.
Aug 22 19:08:21 irena systemd[1]: Failed to start dphys-swapfile - set
up, mount/unmount, and delete a swap file.
#

Test5 answer: "dphys-swapfile setup" run only one time (I also tested
if /etc/init.d/dphys-swapfile still run, the answer is no)

# cat /proc/swaps
Filename                                Type            Size    Used    Priority
# ls -l /var/swap
-rw------- 1 root root 1073741824 Aug 15 20:13 /var/swap
# /sbin/dphys-swapfile swapon
# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/var/swap                               file            1048572 256     -2
#

I have not got "dphys-swapfile setup" exit code. It seems that it give
a question mark.
"dphys-swapfile setup" exit with false code altought "dphys-swapfile
setup" seems to went okay for me, because I can run
"/sbin/dphys-swapfile swapon" successfully.
I will see if I can get the exit code from the 64-bit environment tomorrow.

// Evald

Reply via email to