Difference between revisions of "Handbook:Parts/Blocks/DesigningPartitionScheme"

From Gentoo Wiki
Jump to:navigation Jump to:search
m (Oxford comma.)
(Revise section based on Bug 760321 forwarded to discussion page by Jonas Stein.)
Line 5: Line 5:
  
 
<!--T:4-->
 
<!--T:4-->
The number of partitions is highly dependent on the environment. For instance, if there are lots of users, then it is advised to have {{Path|/home/}} separate as it increases security and makes backups easier. If Gentoo is being installed to perform as a mail server, then {{Path|/var/}} should be separate as all mails are stored inside {{Path|/var/}}. A good choice of filesystem will then maximize the performance. Game servers will have a separate {{Path|/opt/}} as most gaming servers are installed there. The reason is similar for the {{Path|/home/}} directory: security and backups. In most situations, {{Path|/usr/}} is to be kept big: not only will it contain the majority of applications, it typically also hosts the Gentoo ebuild repository (by default located at {{Path|{{Handbook Variable|main-ebuild-repository-location}}}}) which already takes around 650 MiB. This disk space estimate ''excludes'' the {{Path|binpkgs/}} and {{Path|distfiles/}} directories that are stored under {{Path|/var/cache/}} by default.
+
The design of disk partition layout is highly dependent on the demands of the system. If there are lots of users, then it is advised to have {{Path|/home}} on a separate partition which will increase security and make backups and other types of maintenance easier. If Gentoo is being installed to perform as a mail server, then {{Path|/var}} should be a separate partition as all mails are stored inside the {{Path|/var}} directory. Game servers may have a separate {{Path|/opt}} partition since most gaming server software is installed therein. The reasoning for these is similar to the {{Path|/home}} directory: security, backups, and maintenance.
 +
 
 +
In most situations on Gentoo, {{Path|/usr}} and {{Path|/var}} should be kept relatively large in size. {{Path|/usr}} hosts the majority of applications available on the system and the Linux kernel sources (under {{Path|/usr/src}}). By default, {{Path|/var}} hosts the Gentoo ebuild repository (located at {{Path|{{Handbook Variable|main-ebuild-repository-location}}}}) which, depending on the file system, generally consumes around 650 MiB of disk space. This estimate ''excludes'' the {{Path|{{Handbook Variable|main-ebuild-repository-location}}/distfiles}} directory, which will gradually fill with source files as packages are installed to the system.
  
 
<!--T:5-->
 
<!--T:5-->
It very much depends on what the administrator wants to achieve. Separate partitions or volumes have the following advantages:
+
How many partitions and how big very much depends on considering the trade-offs and choosing the best option for the circumstance. Separate partitions or volumes have the following advantages:
  
 
<!--T:6-->
 
<!--T:6-->
Line 17: Line 19:
  
 
<!--T:7-->
 
<!--T:7-->
However, multiple partitions have disadvantages as well. If not configured properly, the system might have lots of free space on one partition and none on another. Another nuisance is that separate partitions - especially for important mount points like {{Path|/usr/}} or {{Path|/var/}} - often require the administrator to boot with an initramfs to mount the partition before other boot scripts start. This isn't always the case though, so results may vary.
+
However, multiple partitions have certain disadvantages as well:
  
<!--T:8-->
+
* If not configured properly, the system might have lots of free space on one partition and little free space on another.
There is also a 15-partition limit for SCSI and SATA unless the disk uses GPT labels.
+
* Another nuisance is that separate partitions - especially for important mount points like {{Path|/usr/}} or {{Path|/var/}} - often require the administrator to boot with an initramfs to mount the partition before other boot scripts start. This is not always the case though, so results may vary.
 +
* There is also a 15-partition limit for SCSI and SATA unless the disk uses GPT labels.
  
 
=== What about swap space? === <!--T:9-->
 
=== What about swap space? === <!--T:9-->

Revision as of 19:13, 4 January 2021

Designing a partition scheme

How many partitions and how big?

The design of disk partition layout is highly dependent on the demands of the system. If there are lots of users, then it is advised to have /home on a separate partition which will increase security and make backups and other types of maintenance easier. If Gentoo is being installed to perform as a mail server, then /var should be a separate partition as all mails are stored inside the /var directory. Game servers may have a separate /opt partition since most gaming server software is installed therein. The reasoning for these is similar to the /home directory: security, backups, and maintenance.

In most situations on Gentoo, /usr and /var should be kept relatively large in size. /usr hosts the majority of applications available on the system and the Linux kernel sources (under /usr/src). By default, /var hosts the Gentoo ebuild repository (located at /var/db/repos/gentoo) which, depending on the file system, generally consumes around 650 MiB of disk space. This estimate excludes the /var/db/repos/gentoo/distfiles directory, which will gradually fill with source files as packages are installed to the system.

How many partitions and how big very much depends on considering the trade-offs and choosing the best option for the circumstance. Separate partitions or volumes have the following advantages:

  • Choose the best performing filesystem for each partition or volume.
  • The entire system cannot run out of free space if one defunct tool is continuously writing files to a partition or volume.
  • If necessary, file system checks are reduced in time, as multiple checks can be done in parallel (although this advantage is more with multiple disks than it is with multiple partitions).
  • Security can be enhanced by mounting some partitions or volumes read-only, nosuid (setuid bits are ignored), noexec (executable bits are ignored), etc.

However, multiple partitions have certain disadvantages as well:

  • If not configured properly, the system might have lots of free space on one partition and little free space on another.
  • Another nuisance is that separate partitions - especially for important mount points like /usr/ or /var/ - often require the administrator to boot with an initramfs to mount the partition before other boot scripts start. This is not always the case though, so results may vary.
  • There is also a 15-partition limit for SCSI and SATA unless the disk uses GPT labels.

What about swap space?

There is no perfect value for the swap partition. The purpose of swap space is to provide disk storage to the kernel when internal memory (RAM) is under pressure. A swap space allows for the kernel to move memory pages that are not likely to be accessed soon to disk (swap or page-out), freeing memory. Of course, if that memory is suddenly needed, these pages need to be put back in memory (page-in) which will take a while (as disks are very slow compared to internal memory).

When the system is not going to run memory intensive applications or the system has lots of memory available, then it probably does not need much swap space. However, swap space is also used to store the entire memory in case of hibernation. If the system is going to need hibernation, then a bigger swap space is necessary, often at least the amount of memory installed in the system.