Losing swap after reboot



  • I am using 2.4.4-RELEASE-p2 with a pair of SATA drives configured in a ZFS mirror with encrypted, mirrored swap. I am sure this was working fine before 2.4.4 but on the current build it cannot recreate the swap on startup. Encrypted swap is automatically destroyed on shutdown as designed but I now have to manually start swap when the start up has completed.

    The start up process is trying to bring up the swap using a swap partition identified as /dev/label/swap referred to in /tmp/fstab but this doesn't work on my system.

    To bring up the swap I have to execute the following command:
    swapon /dev/mirror/swap.eli

    Is anyone else using encrypted mirrored swap?
    If so, do you lose it after a restart on 2.4.4-RELEASE-p2?



  • I found this in /etc/pfSense-rc...

    SWAPDEVICE=`/bin/cat /etc/fstab | /usr/bin/grep swap | /usr/bin/cut -f1 | /usr/bin/head -n 1`
    if [ -n "${SWAPDEVICE}" ]; then
    	/bin/rm -f /tmp/fstab.swap
    	if ! [ -c ${SWAPDEVICE} ]; then
    		# The swap device in fstab does not exist, look for a valid one and update fstab
    		for SWAPLABEL in /dev/label/swap*; do
    			echo "${SWAPLABEL}	none	swap	sw	0	0" >> /tmp/fstab.swap
    		done
    	else
    		/bin/cp /etc/fstab /tmp/fstab.swap
    	fi
    	/sbin/swapon -F /tmp/fstab.swap -a 2>/dev/null >/dev/null
    	/etc/rc.savecore
    fi
    

    So it looks like I only have to modify /etc/fstab but on examination it already has been.

    # Device		Mountpoint	FStype	Options		Dump	Pass#
    /dev/mirror/swap.eli		none	swap	sw		0	0
    

    Could it be that some other partition is already labelled as swap?
    the command glabel status (or glabel list) doesn't show anything called swap.

    Name  Status  Components
    gpt/gptboot0     N/A  ada0p1
    gpt/gptboot1     N/A  ada1p1
    

    SWAPDEVICE evaluates to /dev/mirror/swap.eli

    I can't see where this is going wrong. I will try another reboot test later to see if it has magically fixed itself (wishing).



  • Still losing swap after a reboot. I have changed the swapon invocation in /etc/psSense-rc to see the error message if any.

    #	/sbin/swapon -F /tmp/fstab.swap -a 2>/dev/null >/dev/null
    	/sbin/swapon -F /tmp/fstab.swap -a
    

    Rebooting again...



  • That last change reveals that the process is at least recognising that my swap is mirrored but it still fails to launch properly.

    GEOM_MIRROR: Device mirror/swap launched (2/2).
    

    I also tried using -aL and repeating the swapon line for a second time but neither of these coaxed my encrypted swap to return.



  • I have a workaround that works!

    It's not an elegant fix, but it works for me. As the geometry of my hard drive partitions is not going to change, I'm going with this for now.

    #	/sbin/swapon -F /tmp/fstab.swap -a 2>/dev/null >/dev/null
    	/sbin/swapon /dev/mirror/swap.eli
    	/etc/rc.savecore
    

    Which successfully activates my encrypted swap.

    GEOM_MIRROR: Device mirror/swap launched (2/2).
    random: unblocking device.
    GEOM_ELI: Device mirror/swap.eli created.
    GEOM_ELI: Encryption: AES-XTS 128
    GEOM_ELI:     Crypto: software
    

  • Rebel Alliance Developer Netgate

    What do you have in /tmp/fstab.swap?



  • I am still getting the following in /tmp/fstab.swap

    /dev/label/swap*	none	swap	sw	0	0
    

    One thing I didn't mention earlier is my setup is using CARP with two identical machines.
    The problem exists on both machines.


  • Rebel Alliance Developer Netgate

    OK, I did not test the new swap device code with ZFS encrypted+mirrored swap. I'll have to setup a test environment and replicated it here.

    https://redmine.pfsense.org/issues/9281



  • @jimp said in Losing swap after reboot:

    OK, I did not test the new swap device code...

    WHAT IS THIS, OPNSENSE??

    %(#d8dbd9)[(Meant only as a joke, mad respect for the hard work you guys put into all the testing you do)-|]


  • Rebel Alliance Developer Netgate

    I just committed a fix, should show up soon on the issue linked above.



  • Thanks for working on a fix.
    I am assuming this will be rolled into the next round of updates. Do I need to do anything special? Will it just work after a reboot or will I need to reinstall (if the fix is in the install process)?


  • Rebel Alliance Developer Netgate

    If you add the fix as a patch using the system patches package, then you can just reboot and it will be active. You could turn it on by hand if you want, but rebooting is simpler.

    If you wait for the next update then it will come in naturally and just work without any intervention.


  • LAYER 8 Rebel Alliance

    I just want to report the patch is working here.

    Vanilla 2.4.4-p2
    0_1548188651000_zfs_swap_mirror.png

    2.4.4-p2 with Patch 14d470377eab89d7c3f6f765a150ce737409af28
    0_1548188677186_zfs_swap_mirror_patched.png

    2.4.4-p1 was Okay and broke in 2.4.4-p2

    -Rico



  • It works great, thanks.


Log in to reply