Home Linux Tips & TricksHow To Fix Spotify Cache Bloat Using Tmpfs (RAM) On Debian And Ubuntu Linux

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

A Step-by-Step guide to stop Spotify Cache from filling your disk on Linux.

By sk
1.3K views 6 mins read

If you use Spotify on Linux, you may have noticed your disk space shrinking without a clear reason. Spotify's cache can grow to several gigabytes as you stream more music. On systems with SSDs or limited storage, this can quickly become a headache.

This is a common problem for Linux users. Fortunately, there's a simple way to stop Spotify's cache from filling your disk.

If you find that Spotify's cache is taking too much space, you can easily fix it by moving it into a tmpfs, a temporary filesystem stored in memory (RAM).

In this short tutorial, we will learn how to:

  • Move the Spotify cache to RAM using tmpfs,
  • Control Spotify cache size by setting cache limits, and
  • Keep your Linux system clean and fast while enjoying Spotify.

Step 1: Limit Spotify's Cache Size

The first step is to tell Spotify not to store so much cached data.

1. Close the Spotify application completely.

2. Locate the Spotify Configuration file.

The location of this file depends on how you installed Spotify on your system:

Installation Methodprefs File Location
Native Package (Apt, DNF, Pacman, Yum, etc.)~/.config/spotify/prefs
Snap Package~/snap/spotify/current/.config/spotify/prefs
Flatpak~/.var/app/com.spotify.Client/config/spotify/prefs

3. Open its configuration file using your favorite editor:

nano ~/.config/spotify/prefs

4. Add or update this line:

storage.size=512

This limits the cache to around 512 MB.

5. Save the prefs file, and then restart Spotify.

If your cache was previously larger than the new limit, Spotify will automatically shrink it down upon launch.

You can verify this by checking the size of your cache directory (usually in ~/.cache/spotify/Data or ~/.cache/spotify/Storage).

Step 2: Move Spotify's Cache into RAM

Now we'll move the cache folder into RAM using a tmpfs mount. Data in tmpfs exists only in memory, so it clears itself every time you restart.

1. Edit your /etc/fstab file:

sudo nano /etc/fstab

2. Add this line (replace USERNAME, UID, and GID with your actual values):

tmpfs /home/USERNAME/.cache/spotify tmpfs defaults,noatime,size=1024M,uid=1000,gid=1000,mode=0700 0 0

Here's what it does:

  • tmpfs: mounts the folder in RAM
  • noatime: prevents write operations when reading files
  • size=1024M: sets a 1GB memory cap
  • mode=0700: keeps it private to your user

You might notice two numbers in this setup. In Step 1, we have set storage.size=512 inside Spotify's settings and size=1024M in the /etc/fstab entry in step 2. Here's why:

  • Spotify's setting (storage.size=512) tells the app to keep its cache near 512 MB. This is a soft limit that Spotify tries to follow.
  • The tmpfs limit (size=1024M) is a hard limit set by Linux. It stops Spotify from using more than 1 GB of memory, no matter what happens.

That small gap gives Spotify room to breathe. It avoids errors if the app briefly goes over its 512 MB goal.

So, your system keeps performance high without wasting space.

Step 3: Clean and Mount the Directory

Clear out the old cache and mount the new tmpfs volume:

rm -rf ~/.cache/spotify
mkdir -p ~/.cache/spotify
sudo mount ~/.cache/spotify

Check that it’s active:

df -h | grep spotify

You should see something like:

tmpfs   1024M  700M  324M  69% /home/USERNAME/.cache/spotify

That means the cache is now stored in memory.

Step 4: Use a systemd Mount for Better Reliability (Optional)

If you prefer, you can use a systemd mount instead of /etc/fstab. This is cleaner and more reliable if your /home partition mounts late during boot.

Create a new file:

sudo nano /etc/systemd/system/home-USERNAME-.cache-spotify.mount

Paste the following content, making sure to replace USERNAME, USER_UID, and USER_GID with your actual values (e.g., senthil, 1000, 1000).

[Unit]
Description=Spotify cache tmpfs mount

[Mount]
What=tmpfs
Where=/home/USERNAME/.cache/spotify
Type=tmpfs
Options=defaults,noatime,size=1024M,uid=1000,gid=1000,mode=0700

[Install]
WantedBy=default.target

Enable and start it:

sudo systemctl enable --now home-USERNAME-.cache-spotify.mount

This ensures it mounts automatically every time you log in.

Check to confirm the mount is active and has the correct size:

df -h | grep spotify

Sample output will be:

tmpfs              1.0G  0K  1.0G 0% /home/USERNAME/.cache/spotify

Step 5: Enjoy a Cleaner and Faster Spotify Setup

Now Spotify's cache stays small, resets on reboot, and never eats up space again. Playback still works fine, and there's no performance loss, it feels slightly faster since the cache is in RAM.

Recommended Settings for Spotify Cache in Linux

The cache size you choose depends on how much RAM your system has and how you use Spotify.

Use CaseSystem RAMSpotify storage.sizetmpfs size=Why This Works
Light use: web browsing, light multitasking4–8 GB300 MB384 MB–512 MBKeeps the cache small and efficient. Ideal for laptops or low-memory systems.
Everyday use: Spotify + multitasking + coding8–16 GB400 MB512 MBEnough cache for smooth playback without wasting RAM.
Heavy streaming: offline playlists or long sessions16 GB+600 MB768 MB–1 GBLets Spotify store more songs in memory for faster replay.
Power users: large RAM setups, high caching preference32 GB+800 MB1 GB–1.25 GBFor users who want maximum caching performance without worrying about RAM use.

Please note that these are not officially recommended settings. These values may not suit for all. Please experiment with different settings and pick the best for you.

Benefits of Moving Spotify Cache to tmpfs

Moving Spotify's cache to tmpfs offers four clear benefits:

  1. Zero disk wear: the cache is stored in memory, not on your SSD.
  2. Automatic cleanup: the cache disappears after reboot.
  3. Faster reads: RAM access is much faster than disk I/O.
  4. Controlled size: you set the maximum memory Spotify can use.

It's simple, safe, and works across Debian and Ubuntu systems.

Frequently Asked Questions

Q: Where is Spotify’s cache stored on Linux?

A: On most Linux systems, Spotify’s cache is stored in: ~/.cache/spotify

That's inside your home folder under .cache.

Q: How can I clear Spotify's cache on Debian or Ubuntu?

A: You can safely delete the cache folder while Spotify is closed:

rm -rf ~/.cache/spotify

It will be recreated automatically when you open Spotify again.

Q: What happens if I move Spotify's cache to tmpfs?

A: The cache will be stored in memory (RAM) instead of on your disk. This makes it faster but temporary and it clears every time you restart.

Q: Is it safe to limit Spotify's cache size?

A: Yes. Spotify will still work normally. It may re-download songs you haven't played in a while, but performance and streaming quality remain the same.

Q: Does this method work for other Linux apps?

A: Yes. You can use the same tmpfs trick for any cache-heavy app such as browsers, package managers, or media players. Just be sure to set a reasonable size limit.

Conclusion

Spotify's default cache management can be excessive, but moving it to tmpfs resolves the issue cleanly. This simple trick allows you to speed up Spotify on Debian and Ubuntu systems by relocating the cache to RAM. By doing so, you will save disk space, reduce SSD wear, and enjoy better responsiveness, all through a few simple commands.

Do you use any other good tips to optimize Spotify on Linux? Please share them via the comment section below.

Related Read:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More