Change the owner of my hard drives

Hi everyone,

My hdd discs :
sda1, sdb1, sdb2 = dd int.
sdc1 = dd ext.
Before any manipulation (nixos-generate-confg) sdc1 mounts automatically /run… and I am the owner when I mount it in the desired location it is root who becomes the owner.
I mount 4 hard drives with “hardware-configuration.nix” and the owner is root, which does not suit me.
“hardware-configuration.nix” does not take the options. How to add options (uid=gg,gid=users,fmask=113,dmask=002) to the mounting of my disks.

Each filesystem in your configuration accepts an options list, e.g.

{
  config = {
    fileSystems."/path/to/mountpoint" = {
      device = "/dev/disk/by-uuid/xxx";
      fsType = "ext4";
      options = ["uid=gg" "gid=users" "fmask=113" "dmask=002"];
    };
  };
}
2 Likes

Thanks I was hoping there is another solution with “hardware-configuration.nix”

in /etc/nixos/configuration.nix

  # Hard drive storage mounting
  fileSystems."/home/gg/Videos/Series de Films" =
  { device = "/dev/disk/by-uuid/567D-5703";
    fsType = "exfat";
    options = ["users" "nofail" "uid=gg" "gid=users"];
  };
  fileSystems."/home/gg/Music" =
  { device = "/dev/disk/by-uuid/76BF-63AA";
    fsType = "exfat";
    options = ["users" "nofail" "uid=gg" "gid=users"];
  };
  fileSystems."/home/gg/Stocks" =
  { device ="/dev/disk/by-uuid/FEAA-FD15";
    fsType = "exfat";
    options = ["users" "nofail" "uid=gg" "gid=users"];
  };
  fileSystems."/home/gg/Videos/Series" =
  { device = "/dev/disk/by-uuid/58CD-8A03";
    fsType = "exfat";
    options = ["users" "nofail" "uid=gg" "gid=users"];
  };

“nixos-generate-config” is useless.
Is it possible to move this piece of code into a file /etc/nixos/file.nix ?