---
title: Folders and partitions
description: How the Debian filesystem is organised, what each top-level folder holds, how partitions differ from folders, and the habits that keep a server tidy.
---


:ellipsis{left=0px width=40rem top=10rem blur=140px zIndex=60}

Windows gives every disk its own letter. Linux doesn't: there is exactly one tree, it starts at `/`, and everything else hangs off it, including your other disks. A second drive isn't `D:`, it's *mounted* at a folder of the tree, `/mnt/data` for example, and from that point on it looks like any other folder. Odd at first, very practical afterwards, since a program never has to care which physical disk it's writing to.

## The tree

That tree isn't arbitrary either. Every Debian install has the same folders in the same places, which is why a tutorial written for someone else's server applies to yours.

| Folder | What's in it |
| --- | --- |
| `/home` | Users' files. Yours is `/home/username`, also written `~` |
| `/root` | The root account's own home, not to be confused with `/` |
| `/etc` | System configuration, all of it plain text files |
| `/var` | Data that grows: logs in `/var/log`, Docker in `/var/lib/docker` |
| `/tmp` | Temporary files, emptied at every reboot |
| `/usr` | The installed programs themselves, managed by `apt` |
| `/opt` | Software installed outside the package manager |
| `/mnt` and `/media` | Where extra disks get mounted, `/media` for removable ones |
| `/boot` | The kernel and the bootloader, on a small partition of its own |
| `/dev` | Your hardware, exposed as files (`/dev/sda` is a disk) |
| `/proc` and `/sys` | The kernel's live state, invented on the fly, not real files |

## Folders are not partitions

Partitions are a different question from folders. A minimal Debian install typically creates two, one for `/` and one for swap, so every folder above except `/boot` lives on the same partition and shares the same free space. Two commands to see the reality of it: `lsblk` draws the tree of disks and partitions, `df -h` shows how full each one is.

```bash [Terminal]
lsblk
```

```console [Output]
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 465.8G  0 disk
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 461.3G  0 part /
└─sda3   8:3    0     4G  0 part [SWAP]
sdb      8:16   0   3.6T  0 disk
└─sdb1   8:17   0   3.6T  0 part /mnt/data
```

## A few habits worth taking

- **Give your Docker stacks one home, and keep them there.** `/srv` is the folder the standard reserves for data served by the machine, which makes it the tidiest choice for compose files and their bind mounts. [Serveex](/serveex/introduction) puts everything in `/srv/docker`, one folder per stack. What matters is picking one place and staying there, rather than scattering half of them into your home folder.
- **Your own files go in your home.** Scripts in `~/bin`, notes, downloads, anything personal. `/root` is the root account's home, not a convenient place to drop things.
- **Never edit anything under `/usr` or `/bin` by hand.** `apt` owns those, and your changes disappear at the next upgrade. What you're allowed to configure lives in `/etc`.
- **In `/etc`, prefer a drop-in file over editing the main one.** Many services read every `.conf` in a `something.d/` folder next to their main config, `/etc/ssh/sshd_config.d/` for instance. Your file then survives a package upgrade that rewrites the original.
- **Mount data disks by UUID, not by `/dev/sdb`.** Device letters are assigned in the order the kernel finds the disks, so they can swap after a reboot or a new drive. `lsblk -f` gives you the UUID to put in `/etc/fstab`.
- **Keep an eye on `/var`.** Docker images, container logs and system logs all pile up there, on the same partition as the rest. `du -sh /var/lib/docker` tells you what the containers weigh, `df -h` whether you should worry.
- **Don't create your files with `sudo` when you don't have to.** A file created as root inside your home stays owned by root, and you'll be fighting permission errors over it for weeks.

::note{to="/general/linux/cli-basics"}
Everything here assumes you can already move around a terminal. If `cd`, `ls` and `sudo` don't mean much yet, start with the **command line basics**.
::
