← Back to Home

Put Your Browser in RAM — Complete Technical Guide

Browser in RAM

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.

1. Understanding the Concept

Firefox stores everything inside a directory called the profile. This includes:

The idea is to:

  1. Copy the profile into /dev/shm (RAM).
  2. Rename the original as a backup.
  3. Create a symlink so Firefox transparently uses the RAM version.
  4. Create restore/save scripts to sync data between RAM and disk.

This guarantees:

2. Step-by-Step, Explained

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.

3. Actual Commands

3.1 Identify your profile

ls ~/.mozilla/firefox
cat ~/.mozilla/firefox/profiles.ini

3.2 Create the RAM directory

mkdir -p /dev/shm/firefox-profile

3.3 Copy the profile into RAM

cp -a ~/.mozilla/firefox/YOUR_PROFILE/* /dev/shm/firefox-profile/

3.4 Turn the original folder into a backup

mv ~/.mozilla/firefox/YOUR_PROFILE ~/.mozilla/firefox/YOUR_PROFILE.backup

3.5 Create the symbolic link

ln -s /dev/shm/firefox-profile ~/.mozilla/firefox/YOUR_PROFILE

3.6 Save script

sudo nano /usr/local/bin/save-firefox-profile.sh
#!/bin/sh
rsync -a --delete /dev/shm/firefox-profile/ ~/.mozilla/firefox/YOUR_PROFILE.backup/

3.7 Restore script

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

⚠️ Important Notes for Chromium-based Browsers

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.

Verification

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

4. Init System Integration

Void Linux (runit)

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/

Alpine Linux (OpenRC)

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.*

systemd (Ubuntu, Debian, Arch, Fedora)

⚠️ 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

Conclusion

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