Partitioning Your Linux Drives: Does It Provide Any Benefits?

3 years ago by 卩尺丨ㄚ卂ㄥ to c/linux

Partitioning your drive is something that basically everyone on Linux does but what purpose does it actually serve and is there any reason why it might be better to avoid creating partitions in your d...
atzanteol 45 points 3 years ago

A lot of the reasons for disk partition are pretty legacy.

/boot was/is often a separate partition because the boot loaders may not support all filesystems. So if you wanted to use LVM, reiserfs, zfs, etc. for your root directory or have a RAID root then you may have a separate partition for /boot. Especially on older systems where grub/lilo only supported ext file systems. On modern systems there is likely to be a /boot/efi partition for UEFI (it only supports vfat I think?).

/home is often handy to keep separate since you can more easily re-format everything except your home drive. Make distro-hopping a bit easier.

The other reasons are more focused on server-usage rather than home-usage. Things like mounting /tmp on a separate FS so that users couldn't fill up disk space that would block other users from working in their home directory. Or /usr/local being an NFS mount to provide centralized applications.

These days the actual on-disk partitions don't matter as much due to LVM, ZFS and BTRFS. You can now slice and dice your disks however you like and even change things on the fly. I only ever create 1 disk partition anymore (2 if I need a separate /boot or /boot/efi) and then handle the rest in the filesystems or LVM.

With these higher-level partitioning the benefits are more around snapshotting and backups. You can snapshot your /home partition easily with btrfs before making major changes. Or you can copy a zfs partition to a remote server for backup. Things like the immutable distros and proxmox use this functionality a lot since a) partitions in these tools are cheap and b) it's easier to do these things at the partition-level.

Edit: Fun fact: Linux ext* filesystems have the capability to reserve a certain percentage of disk space only for the root user. Useful on a multi-user system where you don't want users filling up all the disk space and blocking the root user from logging in to clean it all up. It used to save something like 5-10% by default but I don't know if that's the case anymore. You can see if it's being done with tune2fs -l <device>.

path: 0 8158966, hotness: undefined, score: 45, children: 0
zenharbinger 33 points 3 years ago

some partitions are useful. Keeping /var and /tmp separate can stop DoS attacks by now allowing logs to fill the entire drive /home means you can wipe the / partition and keep user data.

path: 0 8155731, hotness: undefined, score: 33, children: 16
limelight79 11 points 3 years ago

I've had a full /var partition cause all sorts of problems using the system. But I still think it's good to have four partitions /, /var, /tmp, and /home. At least split out /home so you can format / without losing your stuff in /home.

path: 0 8155731 8156474, hotness: undefined, score: 11, children: 4
scratchandgame 2 points 3 years ago

I think it is better to partition /usr (and /usr/local) too, for stability and security

path: 0 8155731 8156474 8156609, hotness: undefined, score: 2, children: 3
limelight79 2 points 3 years ago

I can definitely see doing that on a server many people are using. For my personal server, I used to do that, but in the end I couldn't find much benefit, and only headache ("ahhhh / is short on space because I forgot to clean up old kernels...").

path: 0 8155731 8156474 8156609 8156655, hotness: undefined, score: 2, children: 2
scratchandgame 3 points 3 years ago

I think it would save you someday, when there is nothing writing in /usr so the writing in /home would not cause much damage. On a system with a huge root partition, an incomplete writing might damage the whole filesystem.

Fsck would be faster. newfs (mkfs) would be faster. I found NetBSD spend so much time when it do newfs a 32G root partition (installing NetBSD in hyper-v).

Also for the /tmp partition, we can use memory filesystem (tmpfs) if we have 4G of RAM or more, instead of physical disk to store things that are cleaned on reboot.

path: 0 8155731 8156474 8156609 8156655 8156778, hotness: undefined, score: 3, children: 1
emptyother 7 points 3 years ago

Damn I've always wanted Windows to have that. Being able to put user folders on another partition, or even another drive, at install time. And being able to use "dynamic disk" (aka software raid) to expand partitions across disks as storage requirements grow. I know it is possible to setup, but with a lot of workarounds and annoying problems.

path: 0 8155731 8156118, hotness: undefined, score: 7, children: 10
Magickmaster 20 points 3 years ago

Windows user folders are nearly unusable in my opinion, too many programs throw in random folders and files everywhere. Especially the Documents folder, too many games putting incoherent stuff in there

path: 0 8155731 8156118 8156687, hotness: undefined, score: 20, children: 3
emptyother 10 points 3 years ago

Jup, useless folder. There's one related thing I've complained a lot about lately, so I'm gonna complain some more about it:

Microsoft got this "great" idea of trying to repeatedly trick me into uploading that Documents folder to the cloud. A folder filled with GBytes of Battlefield and Assassins Creed cache files, Starfield mods, MS database files, etc... A lot of files that are in constant change, or locked the entire session. Annoying as hell. I love Onedrive, but I dont know why its so damn important for them to have those files.

Sometimes I really wish I could switch to some Linux distro instead.

path: 0 8155731 8156118 8156687 8157002, hotness: undefined, score: 10, children: 2
rtxn 10 points 3 years ago

It's asinine that Onedrive doesn't have an equivalent of the decades-old gitignore technology...

There seems to be a workaround, though - archive link. It should work as long as the local and remote conflict remains unresolved, or Microsoft decides to just push the remote onto the local machine and delete your files instead.

path: 0 8155731 8156118 8156687 8157002 8157138, hotness: undefined, score: 10, children: 1
rtxn 8 points 3 years ago

I'm pretty sure you can just mount a volume to C:\Users.

I definitely wouldn't recommend changing the userdir paths in the system. Many of the office computers I work with are set up that way and it's always a pain in the ass when an application expects the home path to be located on C:.

path: 0 8155731 8156118 8156502, hotness: undefined, score: 8, children: 3
gravitas_deficiency 4 points 3 years ago

when an application expects the home path to be located on C:

Clarification: does NTFS just suck at understanding that a directory-mapped storage device mounted under C: should be treated as if it were C: when within the mount dir?

path: 0 8155731 8156118 8156502 8160518, hotness: undefined, score: 4, children: 1
rtxn 6 points 3 years ago

The second paragraph is about changing the path where Windows should look for the user files (analogous to running usermod -h /new/home user to change the user entry in the passwd file), not changing the filesystem. I don't see any reason why a directory-mapped device would behave any differently than a regular directlry... although in my brief time working with softlinks and directory junctions, I learned not to have expectations of Windows/NTFS.

I think the issue is that Windows stores the home path in two environment variables -- HOMEDRIVE contains the drive letter, and HOMEPATH contains the path relative to the drive's root (no, I'm not willing to call it an absolute path). If an application only uses the HOMEPATH envvar, the full path will default to whichever drive letter the environment's working directory belongs to, which is most likely C:. I don't have a Windows machine to test it though, so I might be wrong.

path: 0 8155731 8156118 8156502 8160518 8161087, hotness: undefined, score: 6, children: 0
LinusWorks4Mo 0 points 3 years ago

what's c: ?

path: 0 8155731 8156118 8156502 8217447, hotness: undefined, score: 0, children: 0
maxprime 3 points 3 years ago

I remember doing this in macOS, when I got my first SSD. I installed it and kept the os on the SSD and mapped my user directory to my hdd. It made upgrades and re-installs much easier, which was a plus because it was actually a hackintosh.

path: 0 8155731 8156118 8156963, hotness: undefined, score: 3, children: 0
scratchandgame 2 points 3 years ago

It isn't possible :)

Windows' filesystem is different to unix, and it is much flawed.

path: 0 8155731 8156118 8156677, hotness: undefined, score: 2, children: 0
Ilgaz 19 points 3 years ago

A separate /home can save you hours or even days in several occasions however don't try crazy things like trying to have KDE of Ubuntu share same theme/settings with KDE6. A /var on a fast drive can create wonders too.

path: 0 8161166, hotness: undefined, score: 19, children: 4
psivchaz 3 points 3 years ago

I'm trying out something mildly nutty by putting .steam in /home/steam, then making user-neon, and symlinking so that I can try kde without reinstalling steam games. If I succeed I might try it with other files.

path: 0 8161166 8171305, hotness: undefined, score: 3, children: 3
Ilgaz 3 points 3 years ago

First of all you can check distrobox.it which can basically run Neon inside your distribution however you better set a different virtual home for neon in that case.

I would first tar the .steam to be on the safe side but steam is different, it is some kind of Ubuntu stable itself residing in that directory. Not a big time gamer but people laughed at Ubuntu for shipping its snap because of it.

Long story short I don't think steam would have issues. I meant not to expect KDE guys to revert upgraded preferences back to KDE5 etc. You know they do such things and blame Linux/KDE etc.

path: 0 8161166 8171305 8193825, hotness: undefined, score: 3, children: 0
Mouette 2 points 3 years ago

I've created a specific partition for steam games so I can use games across distro without reinstalling them. You can tell Steam to go look in your partition for your games

path: 0 8161166 8171305 8180911, hotness: undefined, score: 2, children: 1
webghost0101 1 point 3 years ago

I use my windows drive as a junk drawer for large programs in linux. Comes with the same benefit, fully accessible from either system.

path: 0 8161166 8171305 8180911 8182371, hotness: undefined, score: 1, children: 0
Drito 17 points 3 years ago

I installed Arch on a disk without erasing the /home partition that cames from a previous distro. It saves me some config work, and a bit of disk life expectancy I guess.

path: 0 8167542, hotness: undefined, score: 17, children: 0
Quazatron 14 points 3 years ago

Partitioning does have benefits especially for enterprise scenarios. It allows you to specify different policies per mount point (i.e. no executables on /tmp, etc.). It prevents a runaway process from filling your hard disk with logs. It lets you keep your data separated from your OS, or have multiple OSs with the same home partition.

For home use you'll probably go with something simpler, like separated home, root and games partitions, for instance.

Nowadays you should opt for LVM volumes or BTRFS subvolumes instead of partitions as these are way more flexible should you change your mind in the future about the sizes you allocated.

path: 0 8156130, hotness: undefined, score: 14, children: 2
PumpkinEscobar 2 points 3 years ago

Yeah, I really like the archinstall default btrfs layout, 1 subvolume for each of these

  └─root    254:0    0  1.8T  0 crypt /var/log
                                      /var/cache/pacman/pkg
                                      /home
                                      /.snapshots
                                      /
path: 0 8156130 8158118, hotness: undefined, score: 2, children: 0
scratchandgame 0 points 3 years ago

Partitioning have benefits. It is quite easy to set up "modern gnu/linux" since they all use a graphical installer. For sizes you can refer to openbsd's disklabel(8) man page.

It increase stability and security. Not only for enterprise.

path: 0 8156130 8156672, hotness: undefined, score: 0, children: 0
utopiah 13 points 3 years ago

At least have a dedicated /home partition. This way if you want to upgrade the OS, change distribution, heck even migrate to a totally different OS your actual data is safe. Also if you need to do a backup, "just" backup /home which is probably going to be significantly faster and convenient than the entire OS. It also avoid using e.g dd and get a rather opaque file.

TL;DR: yes /home keeps your data safe

path: 0 8156981, hotness: undefined, score: 13, children: 3
avidamoeba 4 points 3 years ago

What's the benefit of dd-ing a home partition over rsync-a-ing a home directory's contents?

path: 0 8156981 8160017, hotness: undefined, score: 4, children: 2
utopiah 2 points 3 years ago

Well it'd result in a single file which if you have to copy on a microSD or USD stick might be easier. To also counter my own argument the result of dd can be mounted thus getting a rather useful directory quickly

But anyway my point was rather the opposite, that indeed in most cases rsync, rdiff-backup, even scp (whatever one is most familiar with) to a local NAS, remote server, etc is usually better, at least more understandable for somebody who isn't used to the process.

path: 0 8156981 8160017 8180275, hotness: undefined, score: 2, children: 0
smileyhead 1 point 3 years ago

You cannot forget some rsync flag and lose part of metadata about files.

path: 0 8156981 8160017 8178418, hotness: undefined, score: 1, children: 0
nottelling 9 points 3 years ago

I'm surprised no one's mentioned the security implications. Mounting with nosuid and nodev options can undermine rootkit or privileged escalation exploits.

path: 0 8174634, hotness: undefined, score: 9, children: 0
kugmo 6 points 3 years ago

/ and /boot are (arguably) all you need on a single disk system

path: 0 8161737, hotness: undefined, score: 6, children: 9
lemmyvore 4 points 3 years ago

But why /boot?

I would much rather split out /home if I'm going to split anything, so it can go through a future reinstall more smoothly. With /var being a more distant second candidate, because I've been burnt on several occasions by various programs eating up all disk space somewhere under it.

path: 0 8161737 8164082, hotness: undefined, score: 4, children: 7
Laser 6 points 3 years ago

If you want to be compliant to the UEFI spec, the partition holding your EFI binaries must be formatted as a file system related to FAT (see https://en.m.wikipedia.org/...). This is not something you want for you system drive, so a separate partition makes sense.

path: 0 8161737 8164082 8164818, hotness: undefined, score: 6, children: 2
lemmyvore 1 point 3 years ago

Isn't EFI a separate partition? Different from /boot?

path: 0 8161737 8164082 8164818 8165390, hotness: undefined, score: 1, children: 1
pete_the_cat 3 points 3 years ago

They can be the same partition, they are for different purposes though. EFI holds the EFI binaries as the name implies, while /boot holds the initrd, kernel, and the bootloader config files.

If they are the same partition, /boot needs to be formatted as FAT32 and have EFI as a subdirectory. Otherwise they can be separate partitions, either way the partition that contains the EFI directory needs to be formatted as FAT32.

path: 0 8161737 8164082 8164818 8165390 8168955, hotness: undefined, score: 3, children: 0
SomethingBurger 3 points 3 years ago

For EFI probably.

path: 0 8161737 8164082 8164280, hotness: undefined, score: 3, children: 1
aBundleOfFerrets 1 point 3 years ago

Its best practice to just split out /efi in that case

path: 0 8161737 8164082 8164280 8164729, hotness: undefined, score: 1, children: 0
smileyhead 1 point 3 years ago

I keep / and /home on a btrfs subvolumes, so I do not have to think about their sizes and also can do snapshots.

path: 0 8161737 8164082 8178486, hotness: undefined, score: 1, children: 1
lemmyvore 1 point 3 years ago

How do btrfs snapshots work?

I use borg to take snapshots from / and /home because I can be selective (it has include and exclude patterns, like rsync). Also because it does deduplication (at file and chunk level too, saves a ton of space) and compression. And of course a big factor is that I can keep the backups somewhere else.

I've looked into zfs snapshots but they seem really limited in comparison. Good for recovering accidental deletes or changes if you catch on soon enough, but not very useful otherwise.

path: 0 8161737 8164082 8178486 8184360, hotness: undefined, score: 1, children: 0
FriendBesto 2 points 3 years ago

Unless you need to dual-boot.

path: 0 8161737 8204550, hotness: undefined, score: 2, children: 0
scratchandgame 5 points 3 years ago path: 0 8155301, hotness: undefined, score: 5, children: 0
avidamoeba 3 points 3 years ago

Partitioning (beyond what's needed to boot)? No. Logical volumes or datasets? Perhaps, but probably not for most trivial setups. Even swap is fine on a file if you need it and it simplifies disk encryption. Most of my machines run an EFI and an LVM partition. If I need a separate volume for something, I can always create it in LVM.

path: 0 8159867, hotness: undefined, score: 3, children: 0
TCB13 -22 points 3 years ago

This is mostly a worthless discussion. A computer / device should be considerable disposable as well as all the data on it. Just sync everything real time to a local "server" with something like Syncthing and if something goes wrong with your machines resync it back. Done.

path: 0 8155363, hotness: undefined, score: -22, children: 12
theshatterstone54 12 points 3 years ago

Not everyone is rich. I sure wish I was, but we can't all do that.

path: 0 8155363 8155693, hotness: undefined, score: 12, children: 4
TCB13 -7 points 3 years ago

Why do you say you've to be rich in order to do that?

path: 0 8155363 8155693 8155966, hotness: undefined, score: -7, children: 3
TCB13 1 point 3 years ago

I mean, I'm sure you can find some old laptop, ARM SBC or anything second hand with a broken screen that people may even gift you or sell very cheap to run as your "home server".

path: 0 8155363 8155693 8155966 8158829, hotness: undefined, score: 1, children: 0
theshatterstone54 1 point 3 years ago

Not everyone can afford to host such a service. For some people, bills would be an issue. For others, buying and storing the hardware would be an issue. For me, storing the hardware and hosting anything would be problematic, as I'm in student accommodation meaning space is limited as it is, let alone with extra stuff laying around. There's also a point in my contract which states that upon using too much electricity, I would be asked to pay for it over it being included in the contract. On top of that, I don't even need this as it is overkill for my use case, where I already have a backup of all cool and important stuff and a secondary backup of all the cool and important stuff that can't be found on the internet or is very difficult to find. So yeah. That's what I meant. Not everyone can afgord the luxury of doing so.

path: 0 8155363 8155693 8155966 8184522, hotness: undefined, score: 1, children: 1
TCB13 0 points 3 years ago

There’s also a point in my contract which states that upon using too much electricity

Yes, because an extra 1.50$ / year would definitely kill your wallet.

For me, storing the hardware and hosting anything would be problematic, as I’m in student accommodation meaning space is limited as it is

This is a valid concern thought, however you may host it at your parent's home for instance. Either way a RPi and a disk aren't that big.

You're framing this as luxury when it fact it's more like a small time effort to set it up than anything else.

path: 0 8155363 8155693 8155966 8184522 8185596, hotness: undefined, score: 0, children: 0
grue 4 points 3 years ago

Oh yeah, but did you know your server is a computer/device and therefore should be considered disposable, too? Checkmate, atheists! ^\s^

Honestly, though, you're not wrong about how always having multiple copies of your data on separate devices is essential. (You do however also need backups, not just synchronized copies, because data-destroying fuck-ups can get sync'd too.)

I'm not sure what your comment has to do with partitioning, though.

path: 0 8155363 8156737, hotness: undefined, score: 4, children: 1
TCB13 -2 points 3 years ago

Ahahaha nice comment. I never said I didn't have backups, the thing is that once you get your data across multiple machines with something like Synching your life becomes way better and things are easier to deal with. Even if my "server" dies I still have three more real time copies of the data (or at least one actually real time and two others a bit behind because those machines aren't always turned on) and the "server" backups to another local drive a long term offsite backup that gets updated from time to time.

I’m not sure what your comment has to do with partitioning, though.

People usually go about and suggest partitioning their disks because they might require to reinstall the system and that way your home directory "will be safe" from whatever mess forced them into a reinstall. In reality this will just introduce unnecessary complexity and it is as likely to fail as single partition system. To be fair I would rather consider a BRTFS sub-volume for home with regular snapshots is way more interesting and manageable than just dumb partitions.

path: 0 8155363 8156737 8158973, hotness: undefined, score: -2, children: 0
atzanteol 3 points 3 years ago

When the only tool you have is a hammer...

Will syncthing help me dual boot then? Our setup EFI? Or boot into a system that uses LVM for a root mount point even if the boot loader doesn't support LVM?

path: 0 8155363 8157257, hotness: undefined, score: 3, children: 2
TCB13 -1 points 3 years ago

People usually go about and suggest partitioning their disks because they might require to reinstall the system and that way your home directory “will be safe” from whatever mess forced them into a reinstall. In reality this will just introduce unnecessary complexity and it is as likely to fail as single partition system. I would rather consider a BRTFS sub-volume for home with regular snapshots is way more interesting and manageable than just dumb partitions.

path: 0 8155363 8157257 8158997, hotness: undefined, score: -1, children: 1
atzanteol 1 point 3 years ago

I think when people talk about partitions these days they typically mean things like LVM or sub-volumes. I would also recommend only having 1 or 2 physical disk partitions and then doing all your partitioning in software.

But the examples I provided above all require on-disk partitions to work. UEFI doesn't know what a btrfs sub-volume is.

path: 0 8155363 8157257 8158997 8159202, hotness: undefined, score: 1, children: 0
Revan343 2 points 3 years ago

Oh, good idea, should I use partitions on my 'server' though?

path: 0 8155363 8175040, hotness: undefined, score: 2, children: 1
TCB13 -1 points 3 years ago

I guess it depends on how you're running things... and you should have backups anyways.

My previous point was that once you get your data across multiple machines your life becomes way better and things are easier to deal with. Even your “server” dies you'll still have more real time copies of the data in your laptop, desktop etc. and eventually a long term offsite backup that gets updated from time to time. Having backups is important as real time sync won't save you from you deleting files by mistake.

A quick way to do things would be to have an SSD drive (so no noise) on the "server" for your real time sync and OS and a mechanical hard drive (usually spin down) that gets a copy of the data via rsync every day. Then you do a monthly or weekly backup of the data to a remote location ove the internet or some USB hard drive that you physically move to other site.

If you're using on an SBC you may run your OS on a SD card + 2.5" SSD drive for real time data + 3.5" for daily backup. And some other remote / offsite backup solution.

path: 0 8155363 8175040 8186045, hotness: undefined, score: -1, children: 0
linux
linux

@lemmy.ml

login for more options
68094
9450
5174

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

go to feed...