Forcing Spotify to use a network drive

Spotify Support said this could not be done for “legal reasons” and promptly shut the door on my support ticket a year or two ago as of this writing. They seemed to think I was trying to use the network drive as a share or CDN “to other users”. Which well, still isn’t the case!

With that being said, Spotify on desktop uses a TON of storage for well… the storage of songs that you’ve set as “Download” on various playlists. And even more-so now due to one of their late 2018 or early 2019 update. As of this writing, my Spotify network share sits just under 100GB!

If you’re like me, and have limited space on your desktop machine due to the drives being SSD’s of 1TB or much less, you’re in luck today.

I’ve only tested and executed this on Windows 10 Pro, version 1803 – so as always, YMMV.

Some prerequisites to have done…

  1. Close the Spotify app in full.
    • If you have to, use task manager and close/end anything that says spotify in the process list.
  2. Able to run a command prompt as admin.
    • You should be able to accomplish this by right clicking the start icon (windows icon), click “Command Prompt (Admin)”.
  3. Ensure your network share is active, accessible, and writable.
    • For me, I am using Debian 9 with SAMBA – this is on a virtual machine provisioned for 256GB in a flat file / single virtual machine disk.
    • I’ve included a short config below for the Samba configuration.
  4. Know what IP address that your samba or remote machine’s share resides on.
    • Windows doesn’t do too well with server-shares as a name vs an IP.
  5. Do not delete the current cache folder that resides in your appdata folder – you’ll be moving the content of the Spotify cache folder!

Getting the ball rolling with Samba…

  1. If you don’t have Samba installed, run sudo apt-get install -y samba samba-common
  2. Once installed, create a new user on the host *nix system. In our case, for simplicity, spotify.
  3. Said user will need to be in the same user-group as Samba on the host system, which would likely be sambashare.
  4. Our command (assuming sudo su -) will likely be something like this: useradd -d /srv/spotify/ -m -G sambashare -p spotify spotify
  5. The password is intentionally “spotify”. No need for it to be something too special, as all it is hosting are cache files from spotify – and nothing else.

Samba config file (smb.conf)

Go ahead and get your samba share configured. For me, this is what my Samba share details looks like… Do note that max disk size can be removed from the config below, i intentionally set this on my installation.

[global]
        server role = standalone server
        dns proxy = no
        map to guest = bad user
        passdb backend = tdbsam
        syslog = 1
        workgroup = WORKGROUP
        passwd chat = *Entersnews*spassword:* %nn *Retypesnews*spassword:* %nn *passwordsupdatedssuccessfully* .
        obey pam restrictions = yes
        os level = 20
        pam password change = yes
        server string = Spotify Cache Server
        usershare allow guests = yes
        log file = /var/log/samba/log.%m
        max log size = 1000
        unix password sync = yes
        passwd program = /usr/bin/passwd %u
        max disk size = 104857600
        panic action = /usr/share/samba/panic-action %d

[homes]
   comment = Home Directories
   browseable = no
   read only = yes
   create mask = 0700
   directory mask = 0700
   valid users = %S

[spotify]
        path = /srv/spotify/
        force group = spotify
        writeable = yes
        readonly = no
        guest account = spotify
        force user = spotify
        comment = Spotify Cache

Off to the Windows side of things…

At this point, we intentionally do not map a network drive.

  • Get a command prompt active with Admin / Administrator permissions open.
    • Right click the Windows Start Icon (OR Windows Key + X) and click command prompt (Admin).
  • As long as you know the IP address of the Samba share (virtual) machine, you can type in this to the command prompt to ensure the share is active: net view \IP.IP.IP.IP /all
    • Where IP.IP.IP.IP is the actual samba share host.
  • You should see something like this…
C:WINDOWSsystem32>net view \192.168.20.207 /all
Shared resources at \192.168.20.207

Spotify Cache Server

Share name  Type  Used as  Comment

---------------------------------------------------------------------------
IPC$        IPC            IPC Service (Spotify Cache Server)
spotify     Disk           Spotify Cache
The command completed successfully.
  • Outside of the command prompt, navigate to the folder where your Spotify Cache is stored at. Spotify will always default it to: C:UsersYourUserNameAppDataLocalSpotify in a folder named Storage.
  • Enter into the Storage folder.
  • Select ALL files and folders within the Storage folder, CUT the files and folders, not COPY. (Hint: CTRL A then CTRL X)
  • Now, open up a new (second) explorer window, and navigate to where you have the samba share at.
    • You’ll need to enter the location in manually in the input bar at the top. For me, it is \192.168.20.207spotify.
  • When you navigate to this share for the first time, it should ask for a username and password.
    • If you setup via the process above, the username and password is simply spotify (Username might require the workgroupdomain flow, use WORKGROUPspotify if so).
    • Be sure to check the Remember check box before clicking OK.
  • If the login and access was a success, you should be in the samba share folder. Try creating a folder, title it test or something. If you created the folder without issue, go ahead and delete the test folder.
    • Keep this window open for the next step!
  • Remember all of those folders that you cut above? Yeah, paste them into the new network share now. Get them out of the “Storage” folder currently residing on your C drive.
    • Depending on your LAN ethernet speed and the size of your Spotify cache “Storage” folder, this could take anywhere between one minute to one hour.
    • Wait for this massive process to finish before continuing onward.
  • Once the mass move of folders has completed, go up one level – or to C:UsersYourUserNameHereAppDataLocalSpotify
  • Delete the current “Storage” folder. It gets recreated with the next steps below.
  • Jump back to the command prompt from earlier. We’ll use the net use command to create a persistent mapping to the remote share. This also _SHOULD_ create a user:pass mapping to the share, but in the event it didn’t, the above step should have.
    • net use \IP.IP.IP.IPspotify spotify /USER:WORKGROUPspotify /PERSISTENT:YES
      • ShareIPShareName,
      • Password,
      • User plus workgroup details,
      • Forcing it to be persistent.
  • NOTE: If you use something like CCleaner, or something that removes old-caches and stored data, it may wipe your user:pass login credentials! If this happens, Spotify will throw an error stating that the “drive might be full” due to an forbidden access-event.
  • Edit the username & paste into the terminal: mklink /d "C:UsersYourUserNameHereAppDataLocalSpotifyStorage" \IP.IP.IP.IPspotify
  • Once this mapping and folder ‘link’ has been made, check the C:UsersYourUserNameHereAppDataLocalSpotify directory for a folder named “Storage” with the little arrow at the bottom left. Your folder list should ultimately look like this:
  • Enter into the “Storage” folder and ensure you can access, view, and browse about.

Load up Spotify, and see if it loads in the entire cached library. If there’s an error, you’ll see it light up at the top of the Spotify UI.

All in all, this is a fairly simple process. Just have to have some know-how when it comes to Linux, Samba, Windows, and basic TCP/IP networking knowledge.


Notes / Q&A

Q: Spotify says it doesn’t have permission “maybe disk is full”-error…
A: There are four possible issues ongoing:
1) You’re no longer logged into the network share on Windows. Manually navigate via explorer to the root share IP so that it triggers a login-request.
2) The Samba file system or *nix file system is read only – or possibly not even running!
3) A firewall is blocking it – be it on linux (ipfw or iptables) or on Windows.
4) The machine you’ve linked to is at its quota or actually has a full hard drive!

Q: Spotify is extremely slow to load / start up now…
A: This is to be expected when forcing the cache to use the TCP/IP stack and not a direct local-drive access. It will be even slower if your switch or ethernet ports are not 1Gbps. It takes upwards of 45 seconds to one minute for Spotify to load up the entire (near) 100GB cache I have on the Samba drive. This is what it looks like on windows task manager…

When Spotify needs to download new audio, your task manager will look something like this…

This is working as intended. Spotify will download the song, once completed, uploads it to the network share that has been linked from the process above.

 

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments