How to add second hard drive HDD

Iam new in nixos. How to add second hard drive in nix os system?
fstab is read only file and i cannot edit it. I cant find that info in manual.
Thanks in advance for reply

1 Like
and also if you man configuration.nix and search for fileSystems (or just click here, but it’s a big HTML file

On easy way is to mount it where you want it and then run nixos-generate-config

That will update /etc/nixos/hardware-configuration.nix with your current mount points.


mounted sdb1 and then
writing /etc/nixos/hardware-configuration.nix…
warning: not overwriting existing /etc/nixos/configuration.nix

what is wrong?

Nothing. It doesn’t overwrite configuration.nix but it does overwrite hardware-configuration.nix which is what you want. You should now see the mount in /etc/nixos/hardware-configuration.nix

From there, running nixos-rebuild switch should getting everything working and update /etc/fstab

1 Like

ok works i have got it thanks


I tried this, but running nixos-generate-config it did not change my hardware-configuration.nix.
I mounted my second drive /dev/sdb1 to /run/media/pablo/Data.

I’m running the newest 21.05 NixOS, so maybe this changed since you answered.

Edit: It might also have to do with the fact that it’s a windows drive. I just moved from windows to NixOS, so my data drive is still formatted for windows.

It skips filesystems mounted under /run. That is where things get automounted, you probably don’t want to create permanent mounts there since it is a tmpfs.

Oh! That makes sense.

Where should I mount permanently? Just /mnt or is there a better place in NixOS?

Where do you need it?

You can put it almost anywhere. A subdirectory of /mnt, inside your home directory or mounted at /mydata. As long as you don’t mount it inside /proc, /dev, /run or /sys you should be fine.

1 Like

The warning is actually a happy message, that it did not overwrite your existing (if any) mount points.