This page contains the complete and expanded version of the tutorial shown in my video. Here you will find the full step-by-step procedure, explained clearly and in detail, with commands for Void Linux (runit), Alpine Linux (OpenRC), Slackware, and systemd-based distributions.
Running Firefox directly in RAM is one of the most powerful optimisations you can apply to your Linux system.
The goal is simple: move Firefox’s profile folder into /dev/shm, a special memory-backed filesystem that lives entirely inside RAM.
⚠️ DISCLAIMER
I do not use systemd in my daily workflow. The systemd integration shown here was last tested more than one year ago on Debian.
It should work correctly, but please double-check every step and make sure the scripts run on your system before relying on them.
Think before you paste commands — do not trust anyone blindly, not even me.
Firefox stores everything inside a directory called the profile. This includes:
The idea is to:
/dev/shm (RAM).This guarantees:
Step 1 — Identify your Firefox profile.
Step 2 — Create a RAM workspace.
Step 3 — Copy the full profile into RAM.
Step 4 — Rename the original folder as backup.
Step 5 — Create the symbolic link.
Step 6 — Create Restore and Save scripts.
Step 7 — Attach the scripts to your init system.
ls ~/.mozilla/firefox
cat ~/.mozilla/firefox/profiles.ini
mkdir -p /dev/shm/firefox-profile
cp -a ~/.mozilla/firefox/YOUR_PROFILE/* /dev/shm/firefox-profile/
mv ~/.mozilla/firefox/YOUR_PROFILE ~/.mozilla/firefox/YOUR_PROFILE.backup
ln -s /dev/shm/firefox-profile ~/.mozilla/firefox/YOUR_PROFILE
sudo nano /usr/local/bin/save-firefox-profile.sh
#!/bin/sh
rsync -a --delete /dev/shm/firefox-profile/ ~/.mozilla/firefox/YOUR_PROFILE.backup/
sudo nano /usr/local/bin/restore-firefox-profile.sh
#!/bin/sh
mkdir -p /dev/shm/firefox-profile
rsync -a ~/.mozilla/firefox/YOUR_PROFILE.backup/ /dev/shm/firefox-profile/
Make both scripts executable:
chmod +x /usr/local/bin/save-firefox-profile.sh
chmod +x /usr/local/bin/restore-firefox-profile.sh
Some browsers like Chrome, Chromium, Brave, and Vivaldi will delete your symlink if the RAM directory has strict permissions.
Fix:
chmod -R 755 /dev/shm/firefox-profile
chown -R $USER:$USER /dev/shm/firefox-profile
This prevents the browser from replacing the RAM directory with a new on-disk folder.
To confirm Firefox is actually running in RAM:
ls -l ~/.mozilla/firefox
You should see:
YOUR_PROFILE -> /dev/shm/firefox-profile
Then check live files inside RAM:
ls /dev/shm/firefox-profile
sudo mkdir -p /etc/sv/firefox-restore
sudo nano /etc/sv/firefox-restore/run
#!/bin/sh
exec /usr/local/bin/restore-firefox-profile.sh
sudo ln -s /etc/sv/firefox-restore /var/service/
sudo nano /etc/local.d/firefox.restore.start
/usr/local/bin/restore-firefox-profile.sh
sudo nano /etc/local.d/firefox.save.stop
/usr/local/bin/save-firefox-profile.sh
sudo chmod +x /etc/local.d/firefox.*
⚠️ Reminder: I do not use systemd daily. This configuration worked on Debian more than one year ago — test it carefully.
Restore service:
sudo nano /etc/systemd/system/firefox-restore.service
[Unit]
Description=Restore Firefox RAM profile
Before=graphical.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/restore-firefox-profile.sh
[Install]
WantedBy=graphical.target
sudo systemctl enable firefox-restore
Save service:
sudo nano /etc/systemd/system/firefox-save.service
[Unit]
Description=Save Firefox RAM profile back to disk
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/save-firefox-profile.sh
[Install]
WantedBy=shutdown.target
sudo systemctl enable firefox-save
This method transforms Firefox into an extremely fast, highly responsive browser with nearly zero disk usage. It improves privacy, increases SSD lifespan, and makes browsing feel instant.
Use it with care, understand each step, and never copy commands blindly. RAM is powerful — but volatile. With the scripts properly configured, the setup becomes robust and reliable.
Comments