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

RAM Disk Settings shows Kernel Memory at 0 Kb and doesn't allow to create RAM disks.

CE 2.6.0 Development Snapshots (Retired)
2
7
990
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.
  • J
    jjstecchino
    last edited by jjstecchino Mar 16, 2021, 9:17 PM Mar 16, 2021, 9:14 PM

    login-to-view

    Pfsense + 21.05-DEVELOPMENT (amd64) built on Wed Mar 10 01:03:55 EST 2021.
    Config imported from pfSense CE 2.5.

    RAM disk settings under System/Advanced/Miscellaneous show a kernel free memory of 0 Kb do no RAM disk of any size can be created.

    J 1 Reply Last reply Mar 18, 2021, 2:13 PM Reply Quote 1
    • J
      jjstecchino @jjstecchino
      last edited by jjstecchino Mar 18, 2021, 2:14 PM Mar 18, 2021, 2:13 PM

      @jimp

      This seems to be a bug affecting pfSense plus why was this moved to 2.6 snapshots?

      for some reasons kernel memory is not set right and if use ram disk is set it is preventing changes to the entire miscellaneous setting page.

      I looked at the code, it looks like /usr/local/www/system_advanced_misc.php has been refactored to use two functions from etc/inc/web/system_advanced_misc.inc to get data and save data.

      In /usr/local/www/system_advanced_misc.php:

      $group->setHelp('Sets the size, in MiB, for the RAM disks. ' .
              'Ensure each RAM disk is large enough to contain the current contents of the directories in question. %s' .
              'Maximum total size of all RAM disks cannot exceed available kernel memory: %s',
              '<br/>', format_bytes( $available_kernel_memory ));
      

      should be changed to:

      $group->setHelp('Sets the size, in MiB, for the RAM disks. ' .
              'Ensure each RAM disk is large enough to contain the current contents of the directories in question. %s' .
              'Maximum total size of all RAM disks cannot exceed available kernel memory: %s',
              '<br/>', format_bytes( $pconfig['available_kernel_memory'] ));
      

      saveSystemAdvancedMisc in etc/inc/web/system_advanced_misc.inc expects available_kernel_memory to be in the form POSTed data but /usr/local/www/system_advanced_misc.php doesn't post that value, so either post available_kernel-memory or since there is no need to POST it, just change function saveSystemAdvancedMisc to get the value:

      function saveSystemAdvancedMisc($post, $json = false) {
              global $config;
      
              $available_kernel_memory = get_single_sysctl("vm.kmem_map_free");
      
              $rv = array();
      
      

      and check for it:

      if (is_numericint($post['use_mfs_tmp_size']) && is_numericint($post['use_mfs_var_size']) &&
                  ((($post['use_mfs_tmp_size'] + $post['use_mfs_var_size']) * 1024 * 1024) > $available_kernel_memory)) {
                      $input_errors[] = gettext("Combined size of /tmp and /var RAM disks would exceed available kernel memory.");
              }
      

      hope it helps.

      J 1 Reply Last reply Mar 18, 2021, 2:16 PM Reply Quote 0
      • J
        jimp Rebel Alliance Developer Netgate @jjstecchino
        last edited by Mar 18, 2021, 2:16 PM

        @jjstecchino said in RAM Disk Settings shows Kernel Memory at 0 Kb and doesn't allow to create RAM disks.:

        This seems to be a bug affecting pfSense plus why was this moved to 2.6 snapshots?

        Your post was about 21.05 and at the moment we don't have a category for 21.05, and 2.6.0 is along the same development line currently. So it's the best match.

        We are currently focused on Plus 21.02.2 and CE 2.5.1 so issues on 2.6.0/21.05 will not likely see any attention until after those are released. If you can reproduce this on 21.02.2, let us know.

        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!

        J 1 Reply Last reply Mar 18, 2021, 2:20 PM Reply Quote 0
        • J
          jjstecchino @jimp
          last edited by Mar 18, 2021, 2:20 PM

          @jimp

          The fix above is simple, any way to incorporate it in the snapshots? Would like to continue to test and help if I can but I hate to have to modify the code with every update.

          Thanks

          1 Reply Last reply Reply Quote 0
          • J
            jimp Rebel Alliance Developer Netgate
            last edited by Mar 18, 2021, 2:29 PM

            I've passed that along to the dev who was most recently working in that code, which appears to only be on the 21.05 snapshots, so they'll check into it shortly.

            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!

            J 2 Replies Last reply Mar 18, 2021, 2:33 PM Reply Quote 0
            • J
              jjstecchino @jimp
              last edited by Mar 18, 2021, 2:33 PM

              @jimp
              Yes I just checked, 2.5.1 was not refactored yet so it has the older working code. This affect only 21.05 but breaks the entire miscellaneous page.

              1 Reply Last reply Reply Quote 0
              • J
                jjstecchino @jimp
                last edited by Mar 18, 2021, 6:16 PM

                @jimp

                if you want to pass it along...

                the better fix is to pass available_kernel_memory in the post data to keep up with the MVC refactoring that it is going on.

                I added an hidden input field in the form in /usr/local/www/systrm_advanced_misc.php at the end of the RAM disk section as follow:

                $group->add(new Form_Input(
                        'use_mfs_tmp_size',
                        '/tmp RAM Disk Size',
                        'number',
                        $pconfig['use_mfs_tmp_size'],
                        ['placeholder' => 40]
                ))->setHelp('/tmp RAM Disk<br />Do not set lower than 40.');
                
                $group->add(new Form_Input(
                        'use_mfs_var_size',
                        '/var RAM Disk Size',
                        'number',
                        $pconfig['use_mfs_var_size'],
                        ['placeholder' => 60]
                ))->setHelp('/var RAM Disk<br />Do not set lower than 60.');
                
                $group->setHelp('Sets the size, in MiB, for the RAM disks. ' .
                        'Ensure each RAM disk is large enough to contain the current contents of the directories in question. %s' .
                        'Maximum total size of all RAM disks cannot exceed available kernel memory: %s',
                        '<br/>', format_bytes( $pconfig['available_kernel_memory'] ));
                
                // new hidden input field to pass available kernel memory in POST data
                $group->add(new Form_Input(
                        'available_kernel_memory',
                        'Available Kernel Memory',
                        'hidden',
                        $pconfig['available_kernel_memory']));
                
                $section->add($group);
                
                

                no changes required to the save data function in etc/inc/web/system_advanced_misc.inc

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