RackNerd Billboard Banner

How To Fix Spotify Cache Bloat Using Tmpfs (RAM) On Debian And Ubuntu Linux

Spotify is great, but its Linux client has a nasty habit: it lets its cache grow endlessly. Before long, you’ll find several gigabytes of album art, audio chunks, and metadata clogging your ~/.cache/spotify directory.

If you’re running a system with limited storage — especially on SSDs — that bloat isn’t just annoying, it’s wasteful. The fix? Redirect Spotify’s cache to tmpfs, a RAM-based filesystem that wipes itself clean on reboot. It’s fast, temporary, and keeps your disk tidy.

Here’s how to do it.


1. Check Your Spotify Cache Size

Open a terminal and run:

du -sh ~/.cache/spotify

You might be surprised at how big it’s gotten. Anything over a few hundred megabytes is unnecessary.


2. Create a RAM-Based Cache Directory

We’ll use tmpfs to hold Spotify’s cache in RAM. This keeps your disk clean and speeds up access at the cost of using a bit of memory while Spotify is running.

Create a new directory for it:

sudo mkdir -p /mnt/spotify-cache

Then mount it as a tmpfs filesystem:

sudo mount -t tmpfs -o size=256M tmpfs /mnt/spotify-cache

💡 Adjust the size= value as you like.
256M is usually plenty — it stores cached song fragments temporarily but won’t eat all your RAM.


3. Redirect Spotify’s Cache to the RAM Mount

You can either symlink Spotify’s cache directory or use Spotify’s internal environment variable. Let’s go with a symlink for simplicity.

rm -rf ~/.cache/spotify
ln -s /mnt/spotify-cache ~/.cache/spotify

This tells Spotify to use your RAM-mounted folder for caching instead of your home directory.


4. Make It Persistent Across Reboots

By default, tmpfs mounts vanish after reboot. To make it automatic, edit /etc/fstab:

sudo nano /etc/fstab

Add this line at the end:

tmpfs   /mnt/spotify-cache   tmpfs   size=256M,mode=1777   0   0

Save and close the file. Next time you reboot, the cache folder will be mounted automatically.


5. (Optional) Create a Systemd Mount Unit

If you prefer the systemd way, create a mount unit instead of editing /etc/fstab.

sudo nano /etc/systemd/system/mnt-spotify\x2dcache.mount

Paste this:

[Unit]
Description=RAM cache for Spotify

[Mount]
What=tmpfs
Where=/mnt/spotify-cache
Type=tmpfs
Options=size=256M,mode=1777

[Install]
WantedBy=multi-user.target

Then enable and start it:

sudo systemctl enable --now mnt-spotify\\x2dcache.mount

6. Restart Spotify and Verify

Launch Spotify, play a song or two, then check the mount:

df -h | grep spotify

You should see your tmpfs mounted and Spotify’s cache appearing inside it.


7. Bonus: Limit Disk Cache in Spotify

Spotify doesn’t officially expose cache size settings on Linux, but if you run it under Flatpak, you can clear its cache easily:

flatpak run --command=sh com.spotify.Client
rm -rf ~/.var/app/com.spotify.Client/cache/spotify

Still, using tmpfs is the cleaner, automatic fix.


Why This Works

  • Faster access: RAM is much faster than disk.
  • Auto-cleans: The cache disappears every reboot — no need to purge manually.
  • Saves SSD writes: No unnecessary wear from constant cache churn.

Spotify will still work exactly as before — you just won’t be left with gigabytes of stale data.


Final Thoughts

Spotify’s cache bloat is a long-standing quirk of the Linux client. Using tmpfs to store that cache in RAM is a simple, elegant workaround that improves performance and keeps your drive clean.

Once you set it up, you’ll never have to worry about Spotify eating your disk space again.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
© 2025 Computer Everywhere
Your Everyday Guide to the Digital World.
Terms of Service | Privacy Policy
Copy link