Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Losing swap after reboot

    Scheduled Pinned Locked Moved General pfSense Questions
    14 Posts 4 Posters 1.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      vmb
      last edited by

      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).

      1 Reply Last reply Reply Quote 0
      • V
        vmb
        last edited by

        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...

        1 Reply Last reply Reply Quote 0
        • V
          vmb
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • V
            vmb
            last edited by

            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
            
            1 Reply Last reply Reply Quote 0
            • jimpJ
              jimp Rebel Alliance Developer Netgate
              last edited by

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

              Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

              1 Reply Last reply Reply Quote 0
              • V
                vmb
                last edited by vmb

                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.

                1 Reply Last reply Reply Quote 0
                • jimpJ
                  jimp Rebel Alliance Developer Netgate
                  last edited by

                  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

                  Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                  Need help fast? Netgate Global Support!

                  Do not Chat/PM for help!

                  ? 1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User @jimp
                    last edited by

                    @jimp said in Losing swap after reboot:

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

                    WHAT IS THIS, OPNSENSE??

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

                    1 Reply Last reply Reply Quote 0
                    • jimpJ
                      jimp Rebel Alliance Developer Netgate
                      last edited by

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

                      Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                      Need help fast? Netgate Global Support!

                      Do not Chat/PM for help!

                      1 Reply Last reply Reply Quote 0
                      • V
                        vmb
                        last edited by

                        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)?

                        1 Reply Last reply Reply Quote 0
                        • jimpJ
                          jimp Rebel Alliance Developer Netgate
                          last edited by

                          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.

                          Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                          Need help fast? Netgate Global Support!

                          Do not Chat/PM for help!

                          1 Reply Last reply Reply Quote 0
                          • RicoR
                            Rico LAYER 8 Rebel Alliance
                            last edited by

                            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

                            1 Reply Last reply Reply Quote 0
                            • V
                              vmb
                              last edited by

                              It works great, thanks.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.