After some time far from Gentoo world, I want to come back. I can't remember how did I find information about partitioning a hard drive, but I read that it's sometimes better to have more than four partitions (/, /boot/ swap and /home), like this:

Code:

/
/boot
/home
/var
/tmp
/usr
swap

I'm pretty sure about their size, but I'm not sure about their number. Are they too many, or am I right about this scheme? My hard drive is 320 GB and my RAM is 2 GB.

If it hasn't been changed since the last time I installed Gentoo a year ago, the Gentoo Linux x86 Quick Install Guide specifies just the three partitions /boot, / and swap, which is fine although I prefer to have the four partitions /boot, /, swap and /home so that I can re-install if necessary without overwriting all the stuff stored in my /home directory. I normally put the partition with /home last so that I can fill up the rest of the HDD, as I use /home to store a lot of photos, videos, music files and so on which take up a lot of space._________________~amd64, OpenRC, FGLRX, KDE
Fitzcarraldo's blog

After some time far from Gentoo world, I want to come back. I can't remember how did I find information about partitioning a hard drive, but I read that it's sometimes better to have more than four partitions (/, /boot/ swap and /home), like this:

Code:

/
/boot
/home
/var
/tmp
/usr
swap

I'm pretty sure about their size, but I'm not sure about their number. Are they too many, or am I right about this scheme? My hard drive is 320 GB and my RAM is 2 GB.

This scheme is a relic of old times and does not have much connection to current reality. For example, separate /boot was a hack for some computers, where BIOS could access only part of a large disk and the bootloader and the kernel needed to be on that part. Similarly, /usr used to be separate because it was often mounted from a network drive to save disk space. This was already obsolete back in 2001 when I was a newbie. And you definitely don't need swap when you have more than 1GB of memory.

On a normal (non-SSD, non-VM-image) disk, small partitions are faster than large ones, because of shorter seeking distances. But with too many small partitions, managing them becomes a problem, and you often end up moving big files between them, which wastes a lot of time. So I put the preformance-critical parts (/ and /home) on small partitions and rest of the disk is one large storage partition. The purpose of /mnt/extra is to make it possible to do a full rebuild without nuking the existing system. sda7 is an encrypted partition that is normally not mounted (and currently not really used at all). I've been using this scheme for more than a decade, so I know it works well. Of course, it is always good to look for improvement, for example recently I got this idea to move package compilation to a separate partition, because doing it on the storage partition seems to cause noticeable fragmentation there.

A separate boot partition is still useful when dual-booting on eg: laptops, which often
complain if you mess directly with the MBR. It means that you set grub up once, and
then just edit grub.conf (for Grub 1.0) when kernels and partition layouts change.
And in a Gentoo installation, they do tend to change ...

This scheme is a relic of old times and does not have much connection to current reality. For example, separate /boot was a hack for some computers, where BIOS could access only part of a large disk and the bootloader and the kernel needed to be on that part.

Don't write off a separate /boot so quickly. You may not need it, but it can still be useful in several situations:

When BIOS-mode booting from a disk that's over 2TiB in size, the boot loader may require the kernel to be in the first 2TiB of the disk. This is similar to the very case that you dismiss as being obsolete.

The boot loader must be able to read the kernel. Depending on the boot loader in use, it may not be able to read an encrypted root (/) partition, a root filesystem in an LVM or RAID setup, or a particularly exotic filesystem. In these cases, putting /boot on a separate partition is imperative. Note that although GRUB 2 can handle most of these cases, it's not the only boot loader available, and many users prefer to use something else.

EFI-based booting imposes its own wrinkles. One is simply that you might want to use a non-GRUB boot loader that can't read the kernel from certain partitions or filesystems (similar to the last point). In some cases, EFI boot loaders require the kernel to be on the EFI System Partition (ESP), so you must either copy the kernel to the ESP (a non-standard location and/or a nuisance to do) or you must mount the ESP at /boot.

Of course, these cases are far from universal. Many people can get along fine without a separate /boot partition. Relegating such a partition to the dustbin of history is premature, though. The desirability of a separate /boot partition has increased and decreased several times in Linux's history. Currently, it's probably near a low point, but it's on the increase again.

Quote:

And you definitely don't need swap when you have more than 1GB of memory.

This depends very much on how the system is used. I routinely use more than 1GiB of RAM -- often much more. (The system on which I'm typing currently has 3.3GiB used, according to "free".) If I had 2GiB of RAM and used as much memory as I'm using now, I'd need at least 1.3GiB of swap space, directly contradicting your claim. Of course, in such a situation I'd either take steps to use less memory or I'd increase my computer's RAM, but the point is that a simple rule such as you've laid out is inadequate.

Furthermore, swap space is required to use suspend-to-disk (aka hibernate) features, which are particularly popular on laptops. For this feature, you need at least as much swap space as you've got RAM. Again, this shows that how the computer is used affects the determination of how much swap space is required.

There are lots of recommendations and points of view, I'll comment some things that are a bit particular to gentoo

/usr/portage contains the portage tree, it consists right now of >165.000 inodes, and is constantly moving. A it may use from 1 to 4 GiB (more or less), depending on how much distfiles you store on it.
/usr/src contains kernel sources. My typical kernel compile tree takes less than 1,5GiB.

/var/tmp is used for compilations, and some packages may require up to 5-6 GiB of free space IIRC (altough those monster packages usually have the option to be installed directly from binary files, and so there is no compilation needed with this route).

I personally move /usr/src and /usr/portage to /var, and symlink or mount bind them.

About the swap partition, you really want a swap volume, and having 2GiB of memory, I recommend setting a swap volume not smaller than 2GiB.

The more paranoid users like to mount /usr read only, most of the time, so keeping it separate helps that.
A read only root is possible too but its more involved, since you can't write /etc/mtab then.

Everyone should have a small swap. Laptop users that want to hibernate should have something like swap=RAM.

There are several swapping mechanisims open to the kernel, one is to flush buffers waiting to be written to disk, another is to free RAM holding code and data than can be reread from disk.
Lastly, dynamically allocated RAM (that has no permanent home on disk) can be written to swap.
By not having swap, you force the kernel to use the other methods to free RAM for new RAM allocations.

The case for a separate /boot has already been discussed._________________Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.

The OP asked for a normal setup, so I answered what I consider to be normal. Of course there are some cases where more complexity is needed, often because you need to work around stupidity of other people. For example, on work computers all sorts of silly scenarios can happen, depending on how incompetent the necktie clowns that make the rules are.

srs5694 wrote:

When BIOS-mode booting from a disk that's over 2TiB in size, the boot loader may require the kernel to be in the first 2TiB of the disk. This is similar to the very case that you dismiss as being obsolete.

"Those who cannot remember the past are condemned to repeat it."
If you have such system, just keep the whole root partition below the limit. In theory this applied to the old limits as well, but those computers typically also had some Microsoft product there taking up the space.

srs5694 wrote:

The boot loader must be able to read the kernel. Depending on the boot loader in use, it may not be able to read an encrypted root (/) partition, a root filesystem in an LVM or RAID setup, or a particularly exotic filesystem. In these cases, putting /boot on a separate partition is imperative. Note that although GRUB 2 can handle most of these cases, it's not the only boot loader available, and many users prefer to use something else.

EFI-based booting imposes its own wrinkles. One is simply that you might want to use a non-GRUB boot loader that can't read the kernel from certain partitions or filesystems (similar to the last point). In some cases, EFI boot loaders require the kernel to be on the EFI System Partition (ESP), so you must either copy the kernel to the ESP (a non-standard location and/or a nuisance to do) or you must mount the ESP at /boot.

RAID is a valid case, but uncommon on desktop systems. I don't have much experience with EFI, but I assume it can always be disabled. Rest of these are unnecessary (complicate things without adding any value) and should be avoided.

srs5694 wrote:

This depends very much on how the system is used. I routinely use more than 1GiB of RAM -- often much more. (The system on which I'm typing currently has 3.3GiB used, according to "free".) If I had 2GiB of RAM and used as much memory as I'm using now, I'd need at least 1.3GiB of swap space, directly contradicting your claim. Of course, in such a situation I'd either take steps to use less memory or I'd increase my computer's RAM, but the point is that a simple rule such as you've laid out is inadequate.

This means you are running either a lot of java programs or several virtual machines simultaneously. Or what else uses that much? I typically have have about that 3.3 GB (of 4 GB total) free, and that's what I consider to be the normal case.

For some users here, swap appears to be a Ritual Cat that just needs to be there. I have always seen it as a kludge and source of slowness.

srs5694 wrote:

Furthermore, swap space is required to use suspend-to-disk (aka hibernate) features, which are particularly popular on laptops. For this feature, you need at least as much swap space as you've got RAM. Again, this shows that how the computer is used affects the determination of how much swap space is required.

How useful is hibernation in practice? I mean, how much time it saves to wake up the system from hibernation compared to a normal boot? I don't believe it is much, but I haven't tested it myself, so I can be wrong here.

Hibernation is a _lot_ faster, certainly on my laptops. I tend not to use it because
getting all the drivers to play nicely together after being rudely woken is sometimes tricky,
and I'd really only trust my elderly laptop batteries to hold charge for short shutdowns.
Still, when I had it working, it was pretty convenient.