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

    How to add swapspace

    Scheduled Pinned Locked Moved General pfSense Questions
    18 Posts 6 Posters 7.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.
    • M
      minph
      last edited by

      Hello

      I get out of swap space in my syslog

      kernel: pid 58599 (snort), uid 0, was killed: out of swap space
      
      ```and I saw that I have no swap activated at all
      Pfsense runs on a mSATA, that has 32G but pfsense0 has only 1.8G, why?
      

      Filesystem          Size    Used  Avail Capacity  Mounted on
      /dev/ufs/pfsense0    1.8G    290M    1.4G    17%    /
      devfs                1.0K    1.0K      0B  100%    /dev
      /dev/md0              38M    438K    35M    1%    /tmp
      /dev/md1              58M    9.0M    44M    17%    /var
      /dev/ufs/cf          49M    671K    45M    1%    /cf
      devfs                1.0K    1.0K      0B  100%    /var/dhcpd/dev

      I see 3 partitions there, while only one is used
      

      ******* Working on device /dev/ad6 *******
      parameters extracted from in-core disklabel are:
      cylinders=248085 heads=16 sectors/track=63 (1008 blks/cyl)

      Figures below won't work with BIOS for partitions not in cyl 1
      parameters to be used for BIOS calculations are:
      cylinders=248085 heads=16 sectors/track=63 (1008 blks/cyl)

      Media sector size is 512
      Warning: BIOS sector numbering starts with sector 1
      Information from DOS bootblock is:
      The data for partition 1 is:
      sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
          start 63, size 3854529 (1882 Meg), flag 80 (active)
      beg: cyl 0/ head 1/ sector 1;
      end: cyl 751/ head 15/ sector 63
      The data for partition 2 is:
      sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
          start 3854655, size 3854529 (1882 Meg), flag 0
      beg: cyl 752/ head 1/ sector 1;
      end: cyl 479/ head 15/ sector 63
      The data for partition 3 is:
      sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
          start 7709184, size 102816 (50 Meg), flag 0
      beg: cyl 480/ head 0/ sector 1;
      end: cyl 581/ head 15/ sector 63
      The data for partition 4 is:

      Why doesnt it use the whole disk and which partition can I delete to create a partition with at least 3G to use as swap space?
      1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by

        It looks like you are running the NanoBSD variant, probably the 4GB image.
        There is no swap in NanoBSD as it's designed specifically to run from flash media where the high writes would ware it out.
        There are 3 slices as you've found. Two system slices and the config slice. One system slice is booted and the other is backup.
        Out of swap space is not necessarily a problem since there is none at all. What are you doing with the box that causes that message?

        Steve

        1 Reply Last reply Reply Quote 0
        • M
          minph
          last edited by

          Hello

          Thanks for your reply.

          I installed snort and when I activate a few rules, it runs out of memory. I read, that snort can be a memory-hog.
          Since I got a 32G HD in the box, couldn't I just create a new partition of lets say 4G and create the swap there? It would be cool if I won't have to reinstall pfsense with another image.
          I am not so used with how fdisk is implemented in BSD, I know about the slices but not how to work with them.

          1 Reply Last reply Reply Quote 0
          • stephenw10S
            stephenw10 Netgate Administrator
            last edited by

            Short answer: no.
            NanoBSD is designed to not use swap at all. To introduce a swap slice would be complex at best. Probably the easiest thing you could do is just add more RAM. How much RAM do you have?

            Steve

            1 Reply Last reply Reply Quote 0
            • M
              minph
              last edited by

              Hi

              I got 1GB of RAM on this box. It's not possible to add more RAM.

              No matter how complex it is, where can I find straight-forward information about adding swap? Thanks

              1 Reply Last reply Reply Quote 0
              • D
                doktornotor Banned
                last edited by

                Why are you running nanobsd in the first place?

                1 Reply Last reply Reply Quote 0
                • K
                  kejianshi
                  last edited by

                  You are asking for help to break your pfsense. 
                  Having a cache/swap will destroy your flashdrive in VERY short order.
                  (Unless that 32GB can take alot of writes?)

                  What exactly is the model of your drive?    <<<<<

                  IF (This is a big if) its a very good one, you should just move to full install.

                  1 Reply Last reply Reply Quote 0
                  • M
                    minph
                    last edited by

                    No, I wrote its running on a mSATA-Disk, that's SSD not USB-flash.

                    I am just using the nanoimage becasue first I had it on an 4G-USB and it was working well and since I didn't want to reinstall, I just wrote the USB-image from da0 to ad0.

                    1 Reply Last reply Reply Quote 0
                    • J
                      jasonlitka
                      last edited by

                      You should either do a config backup and then reinstall the full version of pfSense or reconfigure snort with a less memory-intensive option.

                      I can break anything.

                      1 Reply Last reply Reply Quote 0
                      • M
                        minph
                        last edited by

                        So anything configured on pfsense is saved in that one config and it will be configured exactly as it was when I just backup that one?

                        1 Reply Last reply Reply Quote 0
                        • stephenw10S
                          stephenw10 Netgate Administrator
                          last edited by

                          Yes unless you've done any customisation outside the wegui setup.

                          Steve

                          1 Reply Last reply Reply Quote 0
                          • M
                            minph
                            last edited by

                            I was just wondering, if I did. It is running for a while now and I just got to install snort. That's why I am hesitating to touch the running system and just wanted to add a partition to use it with swap.

                            1 Reply Last reply Reply Quote 0
                            • stephenw10S
                              stephenw10 Netgate Administrator
                              last edited by

                              I don't think it's going to be possible to add swap. If you Google for adding swap to NanoBSD there are a lot of people wanting to do it and some who've experimented with it. However anything I read about successfully adding it involved rebuilding the Nano image from patched FreeBSD source. Not adding it to a live system.

                              Perhaps, if you really don't want to switch to a full install, you could add space in another way. With Squid for example you can add another drive or slice and use that for cache storage instead of the default location. Often the problems with Snort are caused when it tries to update it's definition files and the result is too large. If that could be downloaded to a separate slice it may help. I'm just think aloud here.
                              If you are running Snort on a box that can take a maximum of 1GB of RAM you probably need to simply tune it more rigorously.
                              What hardware are you running?

                              Steve

                              1 Reply Last reply Reply Quote 0
                              • M
                                minph
                                last edited by

                                Maybe I am thinking too easy from a Linux-point of view where I would just create a partition with fdisk and mount it as swap.
                                I already have snort on lowmem performance but I still get out of swap space errors. Probably I will try to backup the whole disk into an image and then trying to reinstall with using an hd-install version of pfsense. If reinstalling the config-file would break up my setup, I can still restore with the backup

                                1 Reply Last reply Reply Quote 0
                                • stephenw10S
                                  stephenw10 Netgate Administrator
                                  last edited by

                                  That sounds like a good plan.
                                  You can't really compare this to a standard install of Linux or FreeBSD. It's more like OpenWRT, for example. Imagine trying to add an external SWAP drive to a SOHO router. It could be done but it's probably going to involve command line hackery and will be broken by the next update.

                                  Steve

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

                                    Step 0: Say goodbye to anything you love on da0 and be ready to redo this when (not if) it dies.

                                    : dd if=/dev/zero of=/dev/da0 bs=512 count=1
                                    : fdisk -I /dev/da0
                                    : tunefs -L myswap /dev/da0s1
                                    : swapon /dev/ufs/myswap
                                    : swapinfo -h
                                    Device          1K-blocks     Used    Avail Capacity
                                    /dev/ufs/myswap   1951864       0B     1.9G     0%
                                    

                                    Add a shellcmd to do the swapon command at boot.

                                    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
                                    • stephenw10S
                                      stephenw10 Netgate Administrator
                                      last edited by

                                      That would be to use a USB stick for swap space I take it.

                                      Steve

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

                                        Yep.

                                        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
                                        • First post
                                          Last post
                                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.