Use second drive for Steam library

Having a really strange issue setting up my Steam library drive

I’m able to add the folder in the mount on the correct drive and Steam writes to it, but the free space it shows is of my boot drive, so I can’t actually install big games

Steam config

...
  programs = {
    steam = {
      enable = true;
      remotePlay.openFirewall = true;
      localNetworkGameTransfers.openFirewall = true;
    };
    appimage = {
      enable = true;
      binfmt = true;
    };
  };

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "steam"
    "steam-original"
    "steam-unwrapped"
    "steam-run"
  ];
  
  hardware = {
    xone.enable = true;
    steam-hardware.enable = true;
  };
...

2nd drive mount config

...
  fileSystems."/mnt/games" =
  { 
      device = "/dev/disk/by-uuid/9a1e945f-eed8-42c3-9c90-63fa34771a54";
      fsType = "ext4";
      options = [ "nofail" "user" "rw" "exec" "uid=berto" ];
  };
...

Permissions look good to me

> lsa /mnt/games/Steam                                                                                                     ─╯
total 16K
drwxr-xr-x 3 berto users 4.0K May 27 16:37 .
drwxr-xr-x 3 berto users 4.0K May 27 16:36 ..
-rwxr-xr-x 1 berto users   69 May 27 16:37 libraryfolder.vdf
drwxr-xr-x 2 berto users 4.0K May 27 16:37 steamapps

In my reasearch I found someone on Reddit mention that because of how Steam is sandboxed the dir should be in the user’s home folder so I tried both a symlink and mount --bind into my home folder but that doesn’t fix it

Has anyone gotten this kind of setup working?

Did some more troubleshooting I thought of right after posting

Plugged in a flash drive and mounted it via KDE Dolphin. Now Steam gives me an intermediate prompt asking if I want to add it, but that fails, even if I choose “Let me choose another location” and make a subfolder in the flash drive

Error from Steam stdout log

Couldn't write /run/media/berto/Gigafobby/SteamLibrary/.steam_exec_test.sh: No such file or directory

An easy workaround is to move $HOME/.local/share/Steam to your preferred location, then symlink it: for example, ln -sf $HOME/.local/share/Steam /mnt/games/Steam.

1 Like

Just tried it, same problem as trying to add a symlinked library. It’s seeing my boot drive’s free space and not letting me install a game larger than that

Hmmm…this is how I’ve always done it on Linux, most recently with Arch. Maybe you can make the symlink before installing Steam then reinstall; I can’t remember now and I’ve since moved my games back to Windows. I know it worked, though, because my $HOME was in a BTRFS partition on a much smaller drive than where my games were kept.

I seem to have found a workaround

udisksctl mount -b /dev/vdc1
sudo chown -R berto:users /run/media/berto/games

It recognized it correctly and is installing

Now I just need to figure out the Nix way of doing it, but that’s a tomorrow problem

1 Like

I think I’m close to a proper solution, but it’s not working

Added to configuration.nix

  services.udisks2 = {
    enable = true;
    settings = {
      "A217142F-53E8-48F9-9ECC-E849286F957A.conf" = {
        ATA = {
          StandbyTimeout = 50;
        };
      };
    };
  };

This feels like the right solution after reading the docs, but I think my problem is in the conf file name. According udisks man the file should be “IDENTIFIER.conf where IDENTIFIER is the value of the Drive:Id property for the drive” but I don’t know what that actually means so I tried the partition id and it’s now that.

Gonna dig into more, but if anyone can point me in the right direction I will be in your debt

Let’s get misconceptions out of the way first:

uid is not a valid mount option for an ext4 filesystem. It will be silently ignored, and the filesystem will continue to be mounted by root.

The ownership of files on ext4 is determined by file metadata, i.e. literally part of the data, and cannot be changed by the mount command - you need to set ownership when you format the drive, there is no declarative way to handle this beyond making drive formatting declarative.

This is unlike ntfs or fat filesystems, because Windows doesn’t have a concept of file ownership. But for all filesystems a sane person would use on Linux, just remember that you can’t - and should not - use mount to change file ownership.

user is also superfluous, because with your configuration the drive will be mounted on boot by root, so no user will ever mount it. This makes exec and rw superfluous, since those are only required because you set user.

So you really should only set nofail and leave the rest at default. nofail isn’t required either, neededForBoot is false by default so the system will only lightly nag you if it’s missing, which is probably a good thing.

That is definitely false, I’ve been running with steam library folders in /mnt for well over a decade now. This might be true with the flatpak (which you are not using anyway), but the solution there is to override the permitted directories list, not to symlink stuff to your home directory. Symlinks wouldn’t work anyway because that’d be a stupid easy way to escape sandboxes, wouldn’t it.


So, udisks is a neat utility primarily designed around letting users mount - primarily removable - media. It’ll largely sort out the permission issues for you.

That said, if you set up your fstab correctly this shouldn’t be a problem in the first place. Maybe all you need to do is remove the extraneous mount options and change file ownership recursively?

This all looks like a steam bug, FWIW, I’d report it upstream.

1 Like

Ok I got it working. Thanks to @TLATER for the wealth of info, seems like my options were causing Steam to fail for some reason

  fileSystems."/mnt/games" =
  { 
      device = "/dev/disk/by-partuuid/a217142f-53e8-48f9-9ecc-e849286f957a";
      fsType = "ext4";
      options = [ "nofail" ];
  };

Another thing that worked was by adding it via console like this comment describes (just seemed more likely to have problems in the future so I kept poking)

1 Like