Heya folks, some people online told me I was doing partitions wrong, but I’ve been doing it this way for years. Since I’ve been doing it for years, I could be doing it in an outdated way, so I thought I should ask.
I have separate partitions for EFI, /
, swap, and /home
. Am I doing it wrong? Here’s how my partition table looks like:
- FAT32: EFI
- BTRFS:
/
- Swap: Swap
- Ext4:
/home
I set it up this way so that if I need to reinstall Linux, I can just overwrite /
while preserving /home
and just keep working after a new install with very few hiccups. Someone told me there’s no reason to use multiple partitions, but several times I have needed to reinstall the OS (Linux Mint) while preserving /home
so this advice makes zero sense for me. But maybe it was just explained to me wrong and I really am doing it in an outdated way. I’d like to read what you say about this though.
Shrug. To me this is like arguing over how to fold your underwear.
Well technically, if you’re using BTRFS, you might want to check out subvolumes. Here’s my subvolume setup:
- Subvolume 1, named
(root subvol)
- Subvolume 2, named
@home
(/home subvol) - Subvolume 3, named
(/srv subvol)
- Subvolume 4, named
(/opt subvol)
- Subvolume 5, named
(which is - you guessed it - the swap subvol)
You then set up fstab to reflect each of the subvolumes, using the subvol=
option. Here’s the kicker: they are all in one partition. Yes, even the swap. Though caveat, swap still has to be a swapfile, but in its own separate subvolume. Don’t ask me why, it’s just the way to do it.
The great thing about subvolumes is that it doesn’t do any size provisioning, unless specified by the user. All subvolumes share the space available within the partition. This means you won’t have to do any soul searching when setting up the partitions regarding use of space.
This also means that if I want to nuke and pave, I only need run a BTRFS command on my subvolume (which contains
/usr
, /share
, /bin
), because it won’t be touching the contents of @home
, , or
. What’s extra cool here is that I’ll lose 0% FS metadata or permission setup, since you’re technically just disassociating some blocks from a subvolume. You’re not really “formatting”… which is neat as hell.
The only extra partitions I have is the EFI partition and an EXT4 partition for the /boot
folder since I use LUKS2.
Have you had any luck with hibernation with a BTRFS swapfile? My computer still does not start from hibernation, and I am not sure why, even though I followed the Arch wiki to set it up.
Can’t say I have. Haven’t used hibernation mode for years even. Sleep mode is just too good nowadays for me to use it, so I guess we could chalk that up to a fault of the setup.
According to ReadTheDocs (BTRFS, swapfile) it’s possible under certain circumstances, but requires the 6.1 kernel to do it in a relatively easy way.
How does that work with you’re installing a new system? Do the subvolumes just show up like partitions?
In tools like lsblk
? Nope. They appear as directories, usually in the top-level subvolume, which typically isn’t mounted anywhere in the system.
Then you just create mount entries in /etc/fstab
just like you would with partitions, this time just using the subvol=
option as mentioned above. I don’t know if there are any installers that do this for you. Archwiki – as usual – has good documentation on this.
It’s fine for most uses.
For server or enterprise cases you want to separate /usr, /var and /tmp to prevent a rogue process from filling the / volume and crashing the machine.
I routinely 100% my root volume accidentally (thanks docker), but my machine has never crashed, it does tend to cause other issues though. Does having a full /usr, /var or /tmp not cause other issues, if not full crashes?
Of course it does, it’s actually filling those that crashes the machine, not /.
When space runs out it runs out, there’s no magical solution. Separating partitions like that is done for other reasons, not to prevent runaway fill: filesystems with special properties, mounting network filesystems remotely etc.
It depends, if your docker installation uses /var, it will surelly help to keep it separated.
For my home systems, I have: UEFI, /boot, /, home, swap.
For my work systems, we additionally have separate /opt, /var, /tmp and /usr.
/usr will only grow when you add more software to your system. /var and /tmp are where applications and services store temporary files, log files and caches, so they can vary wildly depending on what is running. /opt is for third-party stuff, so it depends if you use it or not.
Managing all that seems like a lot of effort, and given my disk issues havent yet been fatal, ill probably not worry about going that far. Thanks for the info though.
I don’t like wasting space or having to predict how much space I’ll be using two years from now, so I prefer the minimum of partitions: efi, boot, and system(luks), with a btrfs subvol for /, home, and swapfile.
What you’re doing is perfectly fine.
It is however more of a mitigation for bad distro installers than general good practice. If the distro installers preserved /home
, you could keep it all in one partition. Because such “bad” distro installers still exist, it is good practice if you know that you might install such a distro.
If you were installing “manually” and had full control over this, I’d advocate for a single partition because it simplifies storage. Especially with the likes of btrfs you can have multiple storage locations inside one partition with decent separation between them.