Partitions and slices
Although it is theoretically possible to use a full disk to house the Linux system, this is almost never done in practice. Instead, full disk block devices are split up in smaller, more manageable block devices. On most systems, these are called partitions. Other architectures use a similar technique, called slices.
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 and the file system(s) applied to the device. 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 reason for these recommendations 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 space estimate excludes the /var/cache/distfiles and /var/cache/binpkgs directories, which will gradually fill with source files and (optionally) binary packages respectively as they are added 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 realized 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.
- A separate partition for /usr/ may require the administrator to boot with an initramfs to mount the partition before other boot scripts start. Since the generation and maintenance of an initramfs is beyond the scope of this handbook, we recommend that newcomers do not use a separate partition for /usr/.
- There is also a 15-partition limit for SCSI and SATA unless the disk uses GPT labels.
Installations that intend to use systemd as the service and init system must have the /usr directory available at boot, either as part of the root filesystem or mounted via an initramfs.
What about swap space?
|2 GB or less
|2 * RAM
|3 * RAM
|2 to 8 GB
|2 * RAM
|8 to 64 GB
|8 GB minimum, 16 maximum
|1.5 * RAM
|64 GB or greater
|8 GB minimum
|Hibernation not recommended! Hibernation is not recommended for systems with very large amounts of memory. While possible, the entire contents of memory must be written to disk in order to successfully hibernate. Writing tens of gigabytes (or worse!) out to disk can can take a considerable amount of time, especially when rotational disks are used. It is best to suspend in this scenario.
There is no perfect value for swap space size. The purpose of the space is to provide disk storage to the kernel when internal dynamic 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), which will free memory in RAM for the current task. Of course, if the pages swapped to disk are suddenly needed, they will need to be put back in memory (page-in) which will take considerably longer than reading from RAM (as disks are very slow compared to internal memory).
When a system is not going to run memory intensive applications or has lots of RAM available, then it probably does not need much swap space. However do note in case of hibernation that swap space is used to store the entire contents of memory (likely on desktop and laptop systems rather than on server systems). If the system requires support for hibernation, then swap space larger than or equal to the amount of memory is necessary.
As a general rule for RAM amounts less than 4 GB, the swap space size is recommended to be twice the internal memory (RAM). For systems with multiple hard disks, it is wise to create one swap partition on each disk so that they can be utilized for parallel read/write operations. The faster a disk can swap, the faster the system will run when data in swap space must be accessed. When choosing between rotational and solid state disks, it is better for performance to put swap on the solid state hardware.
It is worth noting that swap files can be used as an alternative to swap partitions; this is mostly helpful for systems with very limited disk space.
Using fdisk on HPPA
Use fdisk to create the partitions needed:
HPPA machines use the PC standard DOS partition tables. To create a new DOS partition table press the o key.
Command (m for help):
Building a new DOS disklabel.
PALO (the HPPA bootloader) needs a special partition to work. A partition of at least 16 MB at the beginning of the disk needs to be created for it. The partition type must be of type f0 (Linux/PA-RISC boot). It is also possible to use the PALO partition as /boot.
If this is forgotten and the installation continues without a special PALO partition, then eventually the system will fail to restart. Also, if the disk is larger than 2 GB, make sure that the boot partition is in the first 2 GB of the disk. PALO is unable to read a kernel after the 2 GB limit.
/dev/sda2 /boot ext2 noauto,noatime 1 1
/dev/sda3 none swap sw 0 0
/dev/sda4 / ext4 noatime 0 0
In fdisk, such a partition layout looks like so:
Command (m for help):
Disk /dev/sda: 4294 MB, 4294816768 bytes 133 heads, 62 sectors/track, 1017 cylinders Units = cylinders of 8246 * 512 = 4221952 bytes Device Boot Start End Blocks Id System /dev/sda1 1 8 32953 f0 Linux/PA-RISC boot /dev/sda2 9 20 49476 83 Linux /dev/sda3 21 70 206150 82 Linux swap /dev/sda4 71 1017 3904481 83 Linux