# How to add second hard drive HDD

**URL:** https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132
**Category:** Guides
**Created:** [March 6, 2020, 2:06pm UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132 "2020-03-06T14:06:39Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![constantius24](https://discourse.nixos.org/user_avatar/discourse.nixos.org/constantius24/32/2173_2.png) [@constantius24](https://discourse.nixos.org/u/constantius24)
#### Post date: [March 6, 2020, 2:06pm UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/1 "2020-03-06T14:06:39Z")

</div>

Hi  
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

---

<div class="post-metadata">

### Author: ![KoviRobi](https://discourse.nixos.org/user_avatar/discourse.nixos.org/kovirobi/32/33578_2.png) [@KoviRobi](https://discourse.nixos.org/u/KoviRobi)
#### Post date: [March 6, 2020, 2:49pm UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/2 "2020-03-06T14:49:48Z")

</div>

> **[NixOS 23.11 manual | Nix & NixOS](https://nixos.org/manual/nixos/stable/index.html)**
>
> Nix is a tool that takes a unique approach to package management and system configuration. Learn how to make reproducible, declarative and reliable systems.

and also if you `man configuration.nix` and search for `fileSystems` (or just click here, but it’s a big HTML file [NixOS 23.11 manual | Nix & NixOS](https://nixos.org/nixos/manual/options.html#opt-fileSystems))

---

<div class="post-metadata">

### Author: ![dalto](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dalto/32/2176_2.png) [@dalto](https://discourse.nixos.org/u/dalto)
#### Post date: [March 6, 2020, 2:52pm UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/3 "2020-03-06T14:52:33Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![constantius24](https://discourse.nixos.org/user_avatar/discourse.nixos.org/constantius24/32/2173_2.png) [@constantius24](https://discourse.nixos.org/u/constantius24)
#### Post date: [March 7, 2020, 3:15pm UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/4 "2020-03-07T15:15:38Z")

</div>

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

what is wrong?

---

<div class="post-metadata">

### Author: ![dalto](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dalto/32/2176_2.png) [@dalto](https://discourse.nixos.org/u/dalto)
#### Post date: [March 7, 2020, 3:36pm UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/5 "2020-03-07T15:36:39Z")

</div>

> [@constantius24](#):
>
> 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`

---

<div class="post-metadata">

### Author: ![constantius24](https://discourse.nixos.org/user_avatar/discourse.nixos.org/constantius24/32/2173_2.png) [@constantius24](https://discourse.nixos.org/u/constantius24)
#### Post date: [March 7, 2020, 4:14pm UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/6 "2020-03-07T16:14:03Z")

</div>

ok works i have got it thanks

---

<div class="post-metadata">

### Author: ![TheOddler](https://discourse.nixos.org/user_avatar/discourse.nixos.org/theoddler/32/4686_2.png) [@TheOddler](https://discourse.nixos.org/u/TheOddler)
#### Post date: [August 6, 2021, 8:43am UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/7 "2021-08-06T08:43:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dalto](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dalto/32/2176_2.png) [@dalto](https://discourse.nixos.org/u/dalto)
#### Post date: [August 6, 2021, 10:41am UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/8 "2021-08-06T10:41:27Z")

</div>

> [@TheOddler](#):
>
> I mounted my second drive /dev/sdb1 to /run/media/pablo/Data.

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.

---

<div class="post-metadata">

### Author: ![TheOddler](https://discourse.nixos.org/user_avatar/discourse.nixos.org/theoddler/32/4686_2.png) [@TheOddler](https://discourse.nixos.org/u/TheOddler)
#### Post date: [August 6, 2021, 11:19am UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/9 "2021-08-06T11:19:22Z")

</div>

Oh! That makes sense.

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

---

<div class="post-metadata">

### Author: ![NobbZ](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nobbz/32/7022_2.png) [@NobbZ](https://discourse.nixos.org/u/NobbZ)
#### Post date: [August 6, 2021, 11:23am UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/10 "2021-08-06T11:23:55Z")

</div>

Where do you need it?

---

<div class="post-metadata">

### Author: ![dalto](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dalto/32/2176_2.png) [@dalto](https://discourse.nixos.org/u/dalto)
#### Post date: [August 6, 2021, 11:51am UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/11 "2021-08-06T11:51:39Z")

</div>

> [@TheOddler](#):
>
> Where should I mount permanently? Just /mnt or is there a better place in NixOS?

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.

---

<div class="post-metadata">

### Author: ![travistennies](https://discourse.nixos.org/user_avatar/discourse.nixos.org/travistennies/32/9915_2.png) [@travistennies](https://discourse.nixos.org/u/travistennies)
#### Post date: [July 1, 2023, 12:03am UTC](https://discourse.nixos.org/t/how-to-add-second-hard-drive-hdd/6132/12 "2023-07-01T00:03:59Z")

</div>

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