# Partitions layout advice for NixOS during installation

**URL:** https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659
**Category:** Help
**Created:** [June 16, 2021, 1:34pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659 "2021-06-16T13:34:00Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![drupol](https://discourse.nixos.org/user_avatar/discourse.nixos.org/drupol/32/9471_2.png) [@drupol](https://discourse.nixos.org/u/drupol)
#### Post date: [June 16, 2021, 1:34pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/1 "2021-06-16T13:34:00Z")

</div>

Hello,

I ordered a new hard disk drive for my laptop, I should be receiving it tomorrow.  
I was using a Samsung EVO 860 since ~5 years and I ordered the Samsung EVO 870, same size which is 500Gb.

I didn’t reinstalled the NixOS on top of my old disk because the partition were using the JFS type and I’d like to go back to EXT4 and keep my existing data, without transferring everything somewhere else.

In order to have a hard disk drive in good health, it is recommended to partition it in a smart way.  
Therefore, I have a layout in mind, do you think you could help me and give me your point of view?

Here it is:

- `/boot` partition: 1Gb
- `/nix` partition: 100Gb ([documentation for this](https://nixos.wiki/wiki/Storage_optimization))
- `/home` partition: 300Gb
- `/` partition: 91Gb
- `swap` partition 8Gb

Do you think this layout is fine? Would you recommend something else?

Thanks!

---

<div class="post-metadata">

### Author: ![cmm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/cmm/32/3347_2.png) [@cmm](https://discourse.nixos.org/u/cmm)
#### Post date: [June 16, 2021, 1:46pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/2 "2021-06-16T13:46:08Z")

</div>

- why separate `/nix` partition?
- you probably don’t need a separate `/home` partition, unless you plan to use several distros on the same computer (do you?)
- if you are dead set on separate partitions, perhaps create them more flexibly (as LVM volumes or ZFS pools)
- I’m not sure good modern SSDs actually care, health-wise, how you partition them (except possibly for the alignment, but modern partitioning tools take care of that for you)
- depending on the amount of RAM, 8Gb may not be enough swap if you want your computer to be able to hibernate

---

<div class="post-metadata">

### Author: ![drupol](https://discourse.nixos.org/user_avatar/discourse.nixos.org/drupol/32/9471_2.png) [@drupol](https://discourse.nixos.org/u/drupol)
#### Post date: [June 16, 2021, 2:17pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/3 "2021-06-16T14:17:16Z")

</div>

- why separate `/nix` partition?

Apparently, it’s better to separate partition where read/write happens a lot of time (during updates). I remember I saw that in an article where it explained that it is better for the lifespan of the SSD.

- you probably don’t need a separate `/home` partition, unless you plan to use several distros on the same computer (do you?)

No I only plan to use NixOS.

- if you are dead set on separate partitions, perhaps create them more flexibly (as LVM volumes or ZFS pools)

No, I want something simple. I don’t want to dive into LVM and ZFS.

- I’m not sure good modern SSDs actually care, health-wise, how you partition them

I will try to find this article if I can.

- depending on the amount of RAM, 8Gb may not be enough swap if you want your computer to be able to hibernate

Good point, I will increase it.

---

<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: [June 16, 2021, 2:20pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/4 "2021-06-16T14:20:24Z")

</div>

> [@cmm](#):
>
> why separate `/nix` partition?

It helps mitigating the “out of inodes” problem one might run into easily when using Nix+Ext4.

---

<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: [June 16, 2021, 2:23pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/5 "2021-06-16T14:23:40Z")

</div>

I currently have a LVM+ext4 setup, with which I am not 100% happy with:

- `/`: 1 GB
- `/boot`: 1 GB
- `/nix`: 100 GB
- `/home`: 400 GiB
- `/var/lib/docker`: 50 GiB

And I am eager to add more data-drives as needed.

In the current setup there are still 400 GB of space left in the LVM to get allocated.

---

<div class="post-metadata">

### Author: ![drupol](https://discourse.nixos.org/user_avatar/discourse.nixos.org/drupol/32/9471_2.png) [@drupol](https://discourse.nixos.org/u/drupol)
#### Post date: [June 16, 2021, 2:37pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/6 "2021-06-16T14:37:13Z")

</div>

1 GB for `/` partition ?!

---

<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: [June 16, 2021, 2:38pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/7 "2021-06-16T14:38:47Z")

</div>

Yes, I try to avoid having anything on `/` that isn’t a symlink.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [June 16, 2021, 5:24pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/8 "2021-06-16T17:24:00Z")

</div>

I’d note that `/nix` can be mounted `noatime` 🙂

Partitioning is always subjective. I like a separate `/home`, it’s useful for disaster recovery, but it is indeed a bit superfluous on nix hosts (since almost everything else in `/` will be controlled anyway). Nonetheless, it’s pretty harmless.

Other than that, your `/` is indeed a big for NixOS - most files that traditionally go there should be kept in `/nix`. 1GB is a bit little, but I’ve not found myself needing even 20GB. `/boot` is also on the big end, unless you intend to keep a lot of kernels around.

I also resonate with the LVM suggestion. It’s nice to be able to change your mind without a lot of effort in the future, or if you need to add extra drives when you eventually run out of `/home` space. LVM is a lot less complex than it might seem initially!

Also see [Erase your darlings: immutable infrastructure for mutable systems - Graham Christensen](https://grahamc.com/blog/erase-your-darlings), i.e. root-in-tmpfs, which I’d consider the ultimate in terms of NixOS file system management, though it’s well into complex territory.

Edit: Should probably have linked my [LVM setup commands/instructions](https://github.com/tlater/nixos-hosts#preparing-a-new-system) while I’m at it, which document exactly what I do.

---

<div class="post-metadata">

### Author: ![brogos](https://discourse.nixos.org/user_avatar/discourse.nixos.org/brogos/32/2660_2.png) [@brogos](https://discourse.nixos.org/u/brogos)
#### Post date: [June 16, 2021, 7:57pm UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/9 "2021-06-16T19:57:35Z")

</div>

I have a 1TB NVME with this partition scheme:

- `/boot`: 1GB fat32
- `swap`: 13GB
- `/`: 987GB BTRFS

Inside the `/` I have this scheme of subvolumes:

- `@`: `/`
- `@home`: `/home`
- `@nix`: `/nix`
- `@log`: `/var/log`

All subvolumes are mount with compression (`compress-force=zstd:1`) which helps with disk space. Subvolumes is a very good idea because a subvolume can occupy all space in disk and if I need to reinstall the system I can the `/home`.

---

<div class="post-metadata">

### Author: ![drupol](https://discourse.nixos.org/user_avatar/discourse.nixos.org/drupol/32/9471_2.png) [@drupol](https://discourse.nixos.org/u/drupol)
#### Post date: [June 22, 2021, 6:16am UTC](https://discourse.nixos.org/t/partitions-layout-advice-for-nixos-during-installation/13659/10 "2021-06-22T06:16:01Z")

</div>

Hello,

I did it and it works well.

Here’s the output of `df -h`:

```sh
root@x260 / (master)# df -h                                                                                                                                                                                          
Filesystem Size Used Avail Use% Mounted on
devtmpfs 795M 0 795M 0% /dev
tmpfs 7.8G 47M 7.8G 1% /dev/shm
tmpfs 3.9G 8.5M 3.9G 1% /run
tmpfs 7.8G 528K 7.8G 1% /run/wrappers
/dev/sda3 98G 5.3G 88G 6% /
/dev/sda4 49G 21G 27G 44% /nix
/dev/sda2 295G 61G 220G 22% /home
/dev/sda1 1022M 42M 981M 5% /boot
tmpfs 1.6G 5.1M 1.6G 1% /run/user/1000

```

I guess at some point I will shrink the size of `/`. Right now, the space is mostly used by `docker`, maybe I should have created a partition for `/var`.
