RAM Disk Settings shows Kernel Memory at 0 Kb and doesn't allow to create RAM disks.
-
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.
-
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.
-
@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.
-
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
-
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.
-
@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. -
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