-
Notifications
You must be signed in to change notification settings - Fork 10
Add pfSense NVMe cache overlay documentation #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
| categories: [ConfigExample] | ||
| FaqSection: operation | ||
| --- | ||
| ## Dscription | ||
| This script creates a filesystem overlay using nullfs to mount an alternate NVMe-backed directory as the Squid cache location. On pfSense systems, the standard cache path (/var/squid/cache) is transparently redirected to a user-defined path on a different drive. | ||
| The overlay itself functions correctly: Squid writes to and utilizes the new cache location as intended. However, the Clear Cache button in the pfSense GUI does not currently work with this setup. While this was the original goal of the project, this implementation is an important first step—it enables cache relocation without modifying Squid’s configured path, even though cache clearing still requires manual intervention. | ||
| — | ||
| J. Lee | ||
| ## Usage | ||
| This script is intended for Netgate pfSense systems where Squid’s cache is normally located at: | ||
| /var/squid/cache | ||
| When an alternate drive or filesystem (such as NVMe storage) is used for caching, management becomes more complex. In particular, the pfSense Clear Cache function does not operate correctly, requiring manual deletion of cache files. | ||
| This script was created to simplify cache relocation by overlaying the default Squid cache path with a different storage location, while maintaining compatibility with pfSense’s expected directory structure. | ||
|
|
||
| ## add cron file | ||
| @reboot /root/mount_squid_nullfs.sh | ||
|
|
||
| ## Script .sh file used for cron job | ||
|
|
||
| #!/bin/sh | ||
|
|
||
| TAG="squid-nullfs" | ||
| NVME_DEV="/dev/nda0p2" | ||
| NVME_MNT="/nvme/LOGS_Optane" | ||
| CACHE_SRC="${NVME_MNT}/Squid_Cache" | ||
| CACHE_DST="/var/squid/cache" | ||
|
|
||
| # --- Helper function to log safely to system.log using pfSense PHP --- | ||
| log_sys() { | ||
| MESSAGE="$1" | ||
| logger -t "$TAG" "$MESSAGE" | ||
| } | ||
|
|
||
| log_sys "Starting Squid nullfs mount sequence" | ||
|
|
||
| # 1. Ensure NVMe filesystem is mounted | ||
| if ! mount | grep -q "on ${NVME_MNT} "; then | ||
| log_sys "Mounting NVMe filesystem" | ||
| mount_msdosfs "${NVME_DEV}" "${NVME_MNT}" || { | ||
| log_sys "ERROR: NVMe mount failed" | ||
| exit 1 | ||
| } | ||
| else | ||
| log_sys "NVMe already mounted" | ||
| fi | ||
|
|
||
| # 2. Stop squid if running | ||
| if pgrep -x squid >/dev/null; then | ||
| log_sys "Stopping squid" | ||
| /usr/local/sbin/pfSsh.php playback svc stop squid | ||
| sleep 2 | ||
| fi | ||
|
|
||
| # 3. Ensure directories exist | ||
| mkdir -p "${CACHE_SRC}" "${CACHE_DST}" | ||
|
|
||
| # 4. Mount nullfs if not already mounted | ||
| if ! mount | grep -q "on ${CACHE_DST} "; then | ||
| log_sys "Mounting nullfs cache" | ||
| mount -t nullfs "${CACHE_SRC}" "${CACHE_DST}" || { | ||
| log_sys "ERROR: nullfs mount failed" | ||
| exit 1 | ||
| } | ||
| else | ||
| log_sys "nullfs already mounted" | ||
| fi | ||
|
|
||
| # 5. Start squid | ||
| log_sys "Starting squid" | ||
| /usr/local/sbin/pfSsh.php playback svc start squid | ||
|
|
||
| log_sys "Squid nullfs mount completed" | ||
|
|
||
| ## Testing should show a valid mount on reboot in logs | ||
| <img width="690" height="226" alt="Screenshot 2026-01-12 at 14 56 06" src="https://github.com/user-attachments/assets/f770a6e0-b799-47dc-89fc-d5a05e25aef5" /> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.