Project

General

Profile

Actions

Todo #12145

open

Convert RAM disks to ``tmpfs``

Added by Jim Pingle 2 months ago. Updated about 1 month ago.

Status:
Feedback
Priority:
Normal
Assignee:
Category:
Operating System
Target version:
Start date:
07/19/2021
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
21.09
Release Notes:
Default

Description

For various reasons we may want to switch the RAM disks from ufs on md devices to tmpfs .

Appears to be a simple source change:

diff --git a/src/etc/rc.ramdisk_functions.sh b/src/etc/rc.ramdisk_functions.sh
index 522b7f2b1e..0ec9894f70 100755
--- a/src/etc/rc.ramdisk_functions.sh
+++ b/src/etc/rc.ramdisk_functions.sh
@@ -101,7 +101,7 @@ ramdisk_try_mount () {
     NAME=$1
     if [ ramdisk_check_size ]; then
         SIZE=$(eval echo \${${NAME}size})m
-        /sbin/mdmfs -S -M -s ${SIZE} md /${NAME}
+        /sbin/mount -o rw,size=${SIZE},mode=1777 -t tmpfs tmpfs /${NAME}
         return $?
     else
         return 1;
diff --git a/src/usr/local/www/includes/functions.inc.php b/src/usr/local/www/includes/functions.inc.php
index c25ccebaca..3edeeade3b 100644
--- a/src/usr/local/www/includes/functions.inc.php
+++ b/src/usr/local/www/includes/functions.inc.php
@@ -158,7 +158,7 @@ function get_temp() {
 function get_mounted_filesystems() {
     $mout = "";
     $filesystems = array();
-    exec("/bin/df -Tht ufs,zfs,cd9660 | /usr/bin/awk '{print $1, $2, $3, $6, $7;}'", $mout);
+    exec("/bin/df -Tht ufs,zfs,tmpfs,cd9660 | /usr/bin/awk '{print $1, $2, $3, $6, $7;}'", $mout);

     /* Get rid of the header */
     array_shift($mout);

Naturally that could be deceptively oversimplifying it. Needs lots of testing.

Feel free to kick ahead as needed.

Actions #1

Updated by Jim Pingle 2 months ago

One additional item I found is needed: In source:usr/local/www/includes/functions.inc.php#L163 df -Tht is executed and passed the filesystem types to filter, tmpfs will need added to that list.

Actions #2

Updated by Jim Pingle about 1 month ago

  • Description updated (diff)
  • Assignee set to Jim Pingle
  • % Done changed from 0 to 20

Updated the diff for testing but hit another thing we need to account for.

Currently we check if there is sufficient kernel memory for use by the memory disks. tmpfs does not use kernel memory, so it doesn't suffer the same restrictions, but we still need to make sure there is sufficient RAM to host the tmpfs disks.

Currently we calculate based on the value of vm.kmem_map_free (value in bytes), but this should be changed to vm.stats.vm.v_free_count (# of free pages) multiplied by vm.stats.vm.v_page_size (page size in bytes). This size check is performed in two files: source:src/etc/rc.ramdisk_functions.sh#L82 and source:src/usr/local/pfSense/include/www/system_advanced_misc.inc (multiple places, search for available_kernel_memory)

Actions #3

Updated by Jim Pingle about 1 month ago

  • Status changed from New to Feedback
  • % Done changed from 20 to 100
Actions #4

Updated by Jim Pingle about 1 month ago

  • Status changed from Feedback to In Progress

Systems using RAM disks are good now, but on systems not using RAM disks, /var/run is still using md/ufs.

Actions #5

Updated by Jim Pingle about 1 month ago

  • Status changed from In Progress to Feedback
Actions #6

Updated by Darin May about 1 month ago

Would anything need to change in the dashboard UI code to display tempfs vs ufs where appropriate, or is it already dynamic?

Actions #7

Updated by Jim Pingle about 1 month ago

Darin May wrote in #note-6:

Would anything need to change in the dashboard UI code to display tempfs vs ufs where appropriate, or is it already dynamic?

That's already covered in the commits made to implement this change.

Actions

Also available in: Atom PDF