this post was submitted on 11 Aug 2023
115 points (96.7% liked)

Linux

48372 readers
1665 users here now

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

Related Communities

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

founded 5 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 22 points 1 year ago (1 children)

It really depends on your requirements...

But a few useful points:

  1. Use GPT partition table and not MBR. Everything will be simpler, no need for extended/logical partitions.
  2. If you need to be able to do online (mounted) partition resizing, pick btrfs. Ext4 can only grow them online but not shrink.
  3. Make sure your partition boundaries are 1 MiB aligned.
  4. If you need more advanced setups, consider using LVM.
[–] [email protected] 4 points 1 year ago (1 children)

About lvm though, experiment with it before jumping in with your daily driver.

[–] [email protected] 2 points 1 year ago

Indeed, it's a bit more complex setup, you won't be able to boot without initramfs. But in certain cases (e.g. encryption or partitions spanning multiple devices) it is very useful.

[–] dack 19 points 1 year ago (3 children)

1Gb EFI, rest of the disk LUKS with a single BTRFS inside. Use BTRFS subvols to divide things up. Swap as a swap file on BTRFS (be sure to set it as no_cow).

[–] [email protected] 2 points 1 year ago

Same, except ZFS instead of BTRFS for me.

And / is tmpfs, /home is tmpfs, /nix, /etc/nixos, /var/log, /home/$username/downloads, /home/$username/documents, and some other directories are ZFS subvolumes bind-mounted at boot. That's only an option for NixOS or Guix though, so don't worry about opt-in state on other distros.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

I prefer a very small EFI partition mounted at /boot/efi, that way the kernels and initrds sit at /boot alongside the rest ot the files (though if you also want encryption you need to add your encryption keys to initrd so you don't have to enter the password twice)

[–] [email protected] 13 points 1 year ago (1 children)

i usually have efi boot partition (512mb), / (linux root), /home (i usually make this pretty big) , and swap partition.

[–] [email protected] 4 points 1 year ago

Same, except I also keep /var on a separate partition (old FreeBSD habit), as the I/O characteristics of /var are usually very different from rest of /

[–] [email protected] 11 points 1 year ago* (last edited 1 year ago) (2 children)

Usually, I do the simplest thing: all the stuff goes on one big ext4 partition. I don't make a separate partition for /home. I'll make a swap partition if I can remember but I've forgotten to do that before and nothing bad happened. The bootloader goes on a fat32 /boot/efi on the same drive as whatever the Linux install is on. This way I can swap around the drive to different pcs if I have to or easily change/upgrade drives without having to reinstall all my stuff.

This strategy works for dual booting Windows also. I'll put the windows install all on its own separate drive so it won't try to erase grub during a disk check or something. That happened one time. Also, by putting Windows and Linux on separate drives you can use the bios to boot between Windows or Linux if you mess up one of the bootloaders.

[–] [email protected] 3 points 1 year ago

The two drives thing is an interesting strategy. I might look into implementing that. Thinking of switching to an arch based Linux from debian.

[–] tok3n 1 points 1 year ago

I also use this method and it's worked great for a long time.

[–] [email protected] 7 points 1 year ago (3 children)
  • 500mb-600mb fat32 /boot partition
  • 40gb - 100gb ext4 or btrfs / partition (if you know you're gonna install a lot of software, go bigger)
  • 1x - 2x ram as swap
  • rest of disk as ext4 /home partition
[–] [email protected] 6 points 1 year ago

Why not BRTFS for the /home partition?

[–] [email protected] 4 points 1 year ago (1 children)

I haven't had swap since I started using 32GB of ram and I've been fine. Might be worthwhile to use LVM for a more adjustable partitioning just in case. I made the mistake of making root 50G and I've been fighting with it for a while.

[–] [email protected] 8 points 1 year ago (1 children)

swap is there so u can hibernate rather than shutdown

[–] devfuuu 2 points 1 year ago

Yeah, 32g is barely enough for what I do daily at work, so I have similar amount of ram combined with similar amount of swap file so I can safely hibernate even when the ram is full.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

[This comment has been deleted by an automated system]

[–] [email protected] 6 points 1 year ago* (last edited 1 year ago) (1 children)

I think you're going to get a wide variety of responses here. It comes down to a lot of factors.

For me personally, I've been shifting everything I have to Btrfs, so I can tell you what I've done recently and why.

A big caveat is that many of my systems have multiple physical drives. This means I'm often setting things up based on the speed and capacity of those disks.

But, I do have one system with a single drive shared for booting, root, and home. It's set up like this:

  1. A FAT32 partition for /boot. 512 MB.

  2. A single Btrfs partition across the rest of the drive.

  3. Btrfs subvolumes: @ mounted at /, @home mounted at /home. @snapshots mounted at /.snapshots.

I could go crazy with other subvols (e.g. for /var/log), but ultimately it is sufficient for me to be able to snapshot / and /home separately.

For some of my other systems, I'll have / and /home on different drives. In that case, each has their own @snapshots with their own mount point. I tend still to throw the EFI boot partition mounted at /boot on the same drive as /.

It's very easy to simply change /etc/fstab as needed and point to another snapshot, effectively rolling back the drive to some former point as necessary.

[–] [email protected] 5 points 1 year ago (1 children)

I've had some wild issues that I can't even begin to explain with btrfs. I landed on using xfs for / partition and btrfs on /home

[–] [email protected] 2 points 1 year ago (1 children)

Fair, I've not had any issues but I'm sure they exist. One or the other is faster based on workload, too, so it's not really that one is objectively better all the time.

load more comments (1 replies)
[–] mrvictory1 5 points 1 year ago
  • 1 GiB FAT32 EFI, rest in your preferred filesystem for root
  • If you are dualbooting and accessing all files / games from Windows is a concern, make Linux root partition around 50 GiB
  • I use zram instead of swapfile or partition but setting up zswap (NOT zram) with swapfile is a better idea.
  • You didn't mention encryption. Are you considering it?
[–] [email protected] 5 points 1 year ago* (last edited 1 year ago) (1 children)

Depends on your system. Desktop have different requirements than servers.

On both at minimum, I'd keep /home and /var/log separate. Those usually see the most writes, are least controlled, and so long as they're separate partitions they can fill up accidentally and your system should still remain functional. /tmp and /var/tmp should usually be mounted separately, for similar reasons.

/boot usually keep separate because bootloaders don't always understand the every weird filesystem you might use elsewhere. It would also be the one unencrypted partition you need to boot off of.

On a server, /opt and /srv would usually be separate, usually separate volumes for each directory within those as well, depending how you want to isolate each application/data store location. You could just use quotas; but mounting separately would also allow you to specify different flags, i.e. noexec, nosuid for volumes that should only ever contain data.

/var/lib/docker and other stuff in /var/lib I usually like to keep on separate mounts. i.e. put /var/lib/mysql or other databases on a separate faster disk, use a different file system maybe, and again different mount options. In distant past, you'd mount /var/spool on a different filesystem with more inodes than usual.

Highly secure systems usually require /var/log/audit to be separate, and needs to have enough space guaranteed that it won't ever run out of space and lock the system out due to inability to audit log.

Bottom line is its differnet depending on your requiremtns, but splitting unnecessarily is a good way to waste space and nothing else. Separate only if you need it on a different type of device, different mount options, different size guarantees etc, don't do it for no reason.

[–] [email protected] 3 points 1 year ago

Regarding /boot, it can be encrypted as long as your bootloader can decrypt it, for example GRUB can decrypt LUKS encrypted partitions (albeit somewhat slowly). And the only partition that really has to be unencrypted is UEFI system partition (ESP), where bootloaders are located.

[–] virr 3 points 1 year ago

Depends on environment.

Real hardware separate for a server partitions for: /home, /var, swap, sometimes /usr, sometimes /var/log/audit Depends on deployment requirements, and if a system is expected to run after filling up audit.

Real hardware for a at home desktop: /var, swap, maybe /home, or just one partition for / and one for swap.

Cloud: all one partition, put swap in a file if it is needed. Cloud images are easy to grow if it is just one partition. Cloud-init will handle that automatically with the right packages installed, no configuration needed. Swap partitions are unlikely to be the right size as they vary according to memory and memory varies according to instance/guest sizes. Swap makes auto growing root partition harder (cloud-init custom config injection required). Best practice is to size workload and instances to not need swap whenever possible.

[–] [email protected] 3 points 1 year ago (1 children)

Use zram instead of a SWAP partititon. Zram compresses and keeps in RAM. It's default on Fedora and a few others iirc.

[–] [email protected] 5 points 1 year ago (1 children)

Can you still hibernate and suspend?

[–] [email protected] 5 points 1 year ago* (last edited 1 year ago)

[This comment has been deleted by an automated system]

load more comments
view more: next ›