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

    PfSense 2.2 - ufslabels.sh does not handle swap partition correctly. **SOLVED**

    Problems Installing or Upgrading pfSense Software
    2
    8
    3.4k
    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.
    • B
      bblacey
      last edited by

      Swap partition status before running ufslabels.sh…

      
      [2.2-RELEASE][root@firewall.home]/etc: cat fstab
      # Device		Mountpoint	FStype	Options		Dump	Pass#
      /dev/ufsid/54d19a0598e05f42		/		ufs	rw		1	1
      /dev/ada0s1b		none		swap	sw		0	0
      
      [2.2-RELEASE][root@firewall.home]/etc: swapinfo
      Device          1K-blocks     Used    Avail Capacity
      /dev/ada0s1b     16777216        0 16777216     0%
      
      

      Run ufslabels.sh

      
      [2.2-RELEASE][root@firewall.home]/etc: ufslabels.sh 
      FS: Swap slice 0 on device ada0s1b
      ====================
      Current fstab:
      # Device		Mountpoint	FStype	Options		Dump	Pass#
      /dev/ufsid/54d19a0598e05f42		/		ufs	rw		1	1
      /dev/ada0s1b		none		swap	sw		0	0
      ====================
      New fstab:
      # Device		Mountpoint	FStype	Options		Dump	Pass#
      /dev/ufsid/54d19a0598e05f42		/		ufs	rw		1	1
      /dev/label/swap0		none		swap	sw		0	0
      Commit changes? (y/n):
      y
      Disabling swap to apply label
      Applying label to swap parition
      Activating new fstab
      Re-enabling swap
      
      

      Swap partition no longer active after ufslabels.sh

      
      [2.2-RELEASE][root@firewall.home]/etc: swapinfo
      Device          1K-blocks     Used    Avail Capacity
      [2.2-RELEASE][root@firewall.home]/etc: swapon -a
      swapon: /dev/label/swap0: No such file or directory
      
      

      glabel listing only shows the ufs label - where is the /dev/label/swap0 label?

      
      [2.2-RELEASE][root@firewall.home]/etc: glabel list -a
      Geom name: ada0s1a
      Providers:
      1\. Name: ufsid/54d19a0598e05f42
         Mediasize: 102854214144 (96G)
         Sectorsize: 512
         Stripesize: 0
         Stripeoffset: 40448
         Mode: r1w1e1
         secoffset: 0
         offset: 0
         seclength: 200887137
         length: 102854214144
         index: 0
      Consumers:
      1\. Name: ada0s1a
         Mediasize: 102854214144 (96G)
         Sectorsize: 512
         Stripesize: 0
         Stripeoffset: 40448
         Mode: r1w1e2
      
      
      
      [2.2-RELEASE][root@firewall.home]/etc: glabel status -a
                        Name  Status  Components
      ufsid/54d19a0598e05f42     N/A  ada0s1a
      
      

      I looked at the ufslabels.sh script but it wasn't obvious to me where it might have gone wrong.  One observation is that ufslabels.sh redirects error messages to /dev/null as follows so reactivating swap silently fails:

      
          134         echo "Activating new fstab"
          135         /bin/mv -f ${FSTAB} ${FSTAB}.old
          136         /bin/mv -f ${FSTAB}.tmp ${FSTAB}
          137
          138         echo "Re-enabling swap"
          139         /sbin/swapon -a 2>/dev/null >/dev/null
          140 fi
      
      

      Any ideas?

      ==========================

      SOLUTION (thanks to jimp's help):

      • Option A:  Use the latest ufslabels.sh script from git https://github.com/pfsense/pfsense/blob/master/usr/local/sbin/ufslabels.sh.  You can download it and install it in /usr/local/sbin

      • Option B:  After running the stock 2.2 ufslabels.sh script, manually label swap following jimp's instructions below https://forum.pfsense.org/index.php?topic=88116.msg487251#msg487251

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

        Some fixes were put on the script after 2.2-RELEASE, you might have a look at the current version of the script in the repository to compare.

        Judging by the error somehow the filesystem label didn't take when it tried to label the swap partition.

        could try it by hand now:

        /sbin/glabel label swap0 /dev/ada0s1b
        

        Then see if the label shows up

        ls -l /dev/label/
        

        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
        • B
          bblacey
          last edited by

          Thanks for the response!

          As suggested, I diff'ed the latest ufslabels.sh in git with the 2.2 version on my firewall and most changes are immaterial.  Trying to label the swap partition manually, indeed fails so that is the root cause…

          
          [2.2-RELEASE][root@firewall.home]/root: /sbin/glabel label -v swap0 /dev/ada0s1b
          Metadata value stored on /dev/ada0s1b.
          Done.
          [2.2-RELEASE][root@firewall.home]/root: ls -l /dev/label
          ls: /dev/label: No such file or directory
          [2.2-RELEASE][root@firewall.home]/root: 
          
          

          This is a full install on an internal Sata III SSD.

          What am I missing?

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

            does it work if you label it just "swap" and not "swap0"?

            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
            • B
              bblacey
              last edited by

              jimp, thanks again for trying to help me resolve this issue.  Unfortunately, dropping the 0, has no effect.  In reading the man pages, automatic labelling requires the geom_label kernel module to be loaded but I didn't see it in /boot/kernel.

              From glabel man page - https://www.freebsd.org/cgi/man.cgi?query=glabel&sektion=8

              label    Set up a label name for the given provider.  This is the
                    ``automatic'' method, where metadata is stored in a provider's
                    last sector.  The kernel module geom_label.ko will be loaded if
                    it is not loaded already.

              
              [2.2-RELEASE][root@firewall.home]/root: ls -l /boot/kernel/
              total 16488
              -r-xr-xr-x  1 root  wheel     34616 Jan 22 13:13 aesni.ko
              -r-xr-xr-x  1 root  wheel     17680 Jan 22 13:13 alpm.ko
              -r-xr-xr-x  1 root  wheel     17272 Jan 22 13:13 amdpm.ko
              -r-xr-xr-x  1 root  wheel     14368 Jan 22 13:13 amdsmb.ko
              -r-xr-xr-x  1 root  wheel     12736 Jan 22 13:13 amdtemp.ko
              -r-xr-xr-x  1 root  wheel     11120 Jan 22 13:13 coretemp.ko
              -r-xr-xr-x  1 root  wheel     83424 Jan 22 13:13 dummynet.ko
              -r-xr-xr-x  1 root  wheel     15592 Jan 22 13:13 fdescfs.ko
              -r-xr-xr-x  1 root  wheel     20368 Jan 22 13:13 glxsb.ko
              -r-xr-xr-x  1 root  wheel     21360 Jan 22 13:13 ichsmb.ko
              -r-xr-xr-x  1 root  wheel     10384 Jan 22 13:13 if_ic.ko
              -r-xr-xr-x  1 root  wheel     25536 Jan 22 13:13 if_stf.ko
              -r-xr-xr-x  1 root  wheel     12136 Jan 22 13:13 iic.ko
              -r-xr-xr-x  1 root  wheel     18632 Jan 22 13:13 iicbb.ko
              -r-xr-xr-x  1 root  wheel     18352 Jan 22 13:13 iicbus.ko
              -r-xr-xr-x  1 root  wheel     13880 Jan 22 13:13 iicsmb.ko
              -r-xr-xr-x  1 root  wheel     19032 Jan 22 13:13 intpm.ko
              -r-xr-xr-x  1 root  wheel     17056 Jan 22 13:13 ipdivert.ko
              -r-xr-xr-x  1 root  wheel    119904 Jan 22 13:13 ipfw.ko
              -r-xr-xr-x  1 root  wheel     59800 Jan 22 13:13 ipmi.ko
              -r-xr-xr-x  1 root  wheel      4560 Jan 22 13:13 ipmi_linux.ko
              -r-xr-xr-x  1 root  wheel  13283420 Jan 22 13:13 kernel.gz
              -rw-r--r--  1 root  wheel     26412 Jan 22 13:13 linker.hints
              -r-xr-xr-x  1 root  wheel     12360 Jan 22 13:13 lpbb.ko
              -r-xr-xr-x  1 root  wheel    169736 Jan 22 13:13 ndis.ko
              -r-xr-xr-x  1 root  wheel     21976 Jan 22 13:13 nfsmb.ko
              -r-xr-xr-x  1 root  wheel     13704 Jan 22 13:13 opensolaris.ko
              -r-xr-xr-x  1 root  wheel      9744 Jan 22 13:13 pcf.ko
              -rw-r--r--  1 root  wheel         4 Feb  3 20:03 pfsense_kernel.txt
              -r-xr-xr-x  1 root  wheel    204616 Jan 22 13:13 sfxge.ko
              -r-xr-xr-x  1 root  wheel    102616 Jan 22 13:13 sfxge.ko.symbols
              -r-xr-xr-x  1 root  wheel     11488 Jan 22 13:13 smb.ko
              -r-xr-xr-x  1 root  wheel      7808 Jan 22 13:13 smbus.ko
              -r-xr-xr-x  1 root  wheel     29832 Jan 22 13:13 viapm.ko
              -r-xr-xr-x  1 root  wheel   2239712 Jan 22 13:13 zfs.ko
              
              

              geom_label.ko is not in /boot/kernel so is it "linked in" to the pfSense FreeBSD 10.1 kernel?

              In case this help, here are the relevant sysctl parameters.

              
              [2.2-RELEASE][root@firewall.home]/root: sysctl -a kern.geom.label
              kern.geom.label.debug: 2
              kern.geom.label.ext2fs.enable: 1
              kern.geom.label.iso9660.enable: 1
              kern.geom.label.msdosfs.enable: 1
              kern.geom.label.ntfs.enable: 1
              kern.geom.label.reiserfs.enable: 1
              kern.geom.label.ufsid.enable: 1
              kern.geom.label.ufs.enable: 1
              kern.geom.label.gpt.enable: 1
              kern.geom.label.gptid.enable: 1
              kern.geom.label.disk_ident.enable: 1
              
              

              While I can live without labelling swap, I am interested in troubleshooting this issue for the broader pfSense community hence let me know any other tests or info that I can provide to reach that goal.

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

                All the components are there, I'd suspect something is up with the disk itself perhaps…

                : glabel status -a
                :
                : swapoff /dev/ad0s1b
                : glabel label swap0 /dev/ad0s1b
                : ls -l /dev/label/
                total 0
                crw-r-----  1 root  operator  0x6a Feb  6 15:48 swap0
                : glabel status -a
                       Name  Status  Components
                label/swap0     N/A  ada0s1b
                
                

                Works fine when I try it on a local disk

                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
                • B
                  bblacey
                  last edited by

                  Hmmm, this is a brand new Kingston SVG300 SSD that I just installed because my previous Intel didn't work with 2.2.  I "think" the "manual" trick is that you have to turn off swap before labelling the swap partition because following your commands precisely did the trick.

                  
                  ada0 at ata0 bus 0 scbus2 target 0 lun 0
                  ada0: <kingston sv300s37a120g="" 583abbf0="">ATA-8 SATA 3.x device
                  ada0: Serial Number 50026B7749097076
                  ada0: 600.000MB/s transfers (SATA 3.x, UDMA5, PIO 512bytes)
                  ada0: 114473MB (234441648 512 byte sectors: 16H 63S/T 16383C)
                  ada0: Previously was known as ad0</kingston> 
                  
                  
                  gpart list
                  
                  Geom name: ada0s1
                  modified: false
                  state: OK
                  fwheads: 16
                  fwsectors: 63
                  last: 234441584
                  first: 0
                  entries: 8
                  scheme: BSD
                  Providers:
                  1\. Name: ada0s1a
                     Mediasize: 102854214144 (96G)
                     Sectorsize: 512
                     Stripesize: 0
                     Stripeoffset: 40448
                     Mode: r1w1e2
                     rawtype: 7
                     length: 102854214144
                     offset: 8192
                     type: freebsd-ufs
                     index: 1
                     end: 200887152
                     start: 16
                  2\. Name: ada0s1b
                     Mediasize: 17179869184 (16G)
                     Sectorsize: 512
                     Stripesize: 0
                     Stripeoffset: 4070006784
                     Mode: r1w1e0
                     rawtype: 1
                     length: 17179869184
                     offset: 102854222336
                     type: freebsd-swap
                     index: 2
                     end: 234441584
                     start: 200887153
                  Consumers:
                  1\. Name: ada0s1
                     Mediasize: 120034091520 (112G)
                     Sectorsize: 512
                     Stripesize: 0
                     Stripeoffset: 32256
                     Mode: r2w2e4
                  
                  

                  Executing your exact commands exactly:

                  
                  [2.2-RELEASE][root@firewall.home]/boot/kernel: glabel status -a
                                    Name  Status  Components
                  ufsid/54d19a0598e05f42     N/A  ada0s1a
                  
                  [2.2-RELEASE][root@firewall.home]/boot/kernel: swapinfo
                  Device          1K-blocks     Used    Avail Capacity
                  /dev/ada0s1b     16777216        0 16777216     0%
                  
                  [2.2-RELEASE][root@firewall.home]/boot/kernel: swapoff /dev/ad0s1b
                  
                  [2.2-RELEASE][root@firewall.home]/boot/kernel: glabel label swap0 /dev/ad0s1b
                  
                  [2.2-RELEASE][root@firewall.home]/boot/kernel: ls -l /dev/label
                  total 0
                  crw-r-----  1 root  operator  0x61 Feb  6 12:57 swap0
                  [2.2-RELEASE][root@firewall.home]/boot/kernel: glabel status -a
                                    Name  Status  Components
                  ufsid/54d19a0598e05f42     N/A  ada0s1a
                             label/swap0     N/A  ada0s1b
                  
                  

                  Note - /dev/label/swap0 is now there!  Only manual difference is turning off swap before labelling but ufslabels.sh turns swapoff and then applies a label so I am not sure why it wouldn't have worked.  I am going to revert the label and re-run ufslabels to see if it works.

                  1 Reply Last reply Reply Quote 0
                  • B
                    bblacey
                    last edited by

                    jimp, mystery solved.  Bottom-line:

                    • The pfSense release 2.2 ufslabels.sh script fails to set $DEV properly

                    • The ufslabels.sh f76cbd6 or later in git contains the fix

                    • Manually labelling the swap partition will silently fail if you don't disable swap first (swapoff)

                    Thanks for all your help.  In hindsight, I should have simply run the latest ufslabels.sh per your suggestion instead of simply inspecting the difference on github.

                    Best,
                    Bruce

                    Here are the supporting diag/debug details.

                    Command-logging of 2.2 ufslabels.sh script (the grep regular expression fails to return the swap device entry)

                    
                    + [ y = y ]
                    + echo 'Disabling swap to apply label'
                    Disabling swap to apply label
                    + /sbin/swapoff /dev/ada0s1b
                    + echo 'Applying label to swap parition'
                    Applying label to swap parition
                    + SWAPNUM=0
                    + find_fs_device /dev/ada0s1b
                    + unset DEV
                    + /usr/bin/grep -e '[[:blank:]]/dev/ada0s1b[[:blank:]]' /etc/fstab
                    + awk '{print $1;}'
                    + DEV=''
                    + DEV=''
                    + [ '' != '' ]
                    + echo 'Activating new fstab'
                    Activating new fstab
                    + /bin/mv -f /etc/fstab /etc/fstab.old
                    + /bin/mv -f /etc/fstab.tmp /etc/fstab
                    + echo 'Re-enabling swap'
                    Re-enabling swap
                    + /sbin/swapon -a
                    
                    

                    Command-logging of post-2.2 ufslabels.sh script (the grep regular expression properly returns the swap device).

                    
                    + echo 'Applying label to swap partition'
                    Applying label to swap partition
                    + SWAPNUM=0
                    + find_fs_device /dev/ada0s1b
                    + unset DEV
                    + /usr/bin/grep -e '[[:blank:]]*/dev/ada0s1b[[:blank:]]' /etc/fstab
                    + awk '{print $1}'
                    + DEV=/dev/ada0s1b
                    + DEV=ada0s1b
                    + [ ada0s1b != '' ]
                    + SWAPDEV=ada0s1b
                    + [ -n ada0s1b ]
                    + echo 'Disabling swap ada0s1b to apply label'
                    Disabling swap ada0s1b to apply label
                    + /sbin/swapoff /dev/ada0s1b
                    swapoff: /dev/ada0s1b: Invalid argument
                    + /sbin/glabel label swap0 /dev/ada0s1b
                    + SWAPNUM=1
                    + echo 'Activating new fstab'
                    Activating new fstab
                    + /bin/mv -f /etc/fstab /etc/fstab.old
                    + /bin/mv -f /etc/fstab.tmp /etc/fstab
                    + echo 'Re-enabling swap'
                    Re-enabling swap
                    + /sbin/swapon -a
                    
                    ```****
                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.