Linux Disk Layout: Planning Partitions for Installation
Efficiently designing disk partitioning is essential for a well-done installation.
Linux is a robust system that allows the file system to be split into multiple partitions and multiple disks.
This scheme can be a bit confusing for users accustomed to Microsoft Windows, but it is essential for the CompTIA Linux+ and LPI exams.
The choice of how the file system will be organized can be influenced by several factors such as the amount of disk space, system size, applications used, and how backups will be performed.
Regardless of these variables, some important considerations need to be made and taken into account during disk partitioning during installation.
The first point that needs to be addressed is the location of the boot manager on the disk. Most old BIOS have the limitation of not being able to read disk sectors after cylinder 1024.
Therefore, the GRUB boot manager needs to be located within the first 1024 cylinders in order to be able to load the Kernel correctly.
The new EFI and UEFI motherboard firmwares no longer have this limitation of being able to adequately read only the first 1024 cylinders.
It is generally recommended that the boot manager be separate from the main file system and mounted as /boot if the root file system is formatted with a file system other than ext2, ext3, or ext4.
Some distributions do not support journaling for the boot partition, such as reiserfs and others.
On motherboards with EFI, this firmware no longer uses the same scheme of Cylinder, Head and Sector (CHS) addressing to detect disk geometry, preferring Logical Block Addressing (LBA).
With this, this 1024 cylinder limitation does not exist. On motherboards that use BIOS and provide the LBA feature, this limit also does not need to be observed.
Both in BIOS and EFI, it is highly recommended to separate the partition that will host the kernel boot system (GRUB or GRUB2), as well as the kernel image from the rest of the disk into a partition called "/boot" and format it with a simple file system such as ext2fs or ext3fs. This allows boards that use EFI to directly access this partition and GRUB.
The Swap Partition in Linux
Linux allows a special partition called Swap to act as virtual memory on disk, allowing programs and data to be stored temporarily, enabling the system to run more programs concurrently.
The space allocated for this partition depends on the applications that will be running on the system and the volume of data that these applications will handle.
As a rule, it is recommended that Swap be at least the same size as the RAM memory and, on systems with little memory, three times its size.
If the disk space available for the Linux installation is small, say around 5GB, it is advisable that you keep the root system in a single partition to avoid waste.
The following configuration is recommended:
- 150MB for the /boot partition;
- 1 GB for the swap partition;
- Remaining for the root system /.
For large systems where disk space is not so problematic, it is recommended that the root file system be divided into several Linux partitions and if possible on different disks as follows:
- I suggest separating the /var directory into a partition large enough to accommodate LOG files. The advantage is that if this partition becomes full it will not affect system stability;
- Separate the /tmp partition into a partition that accommodates all temporary files generated by applications and users;
- Separate the /home partition providing users with a partition large enough for their files;
- Separate the swap partition among disks if there is more than one. This can increase virtual memory performance.
In networks that have several machines with the same version of Linux, the /usr folder can be installed on only one computer and shared among several machines on a network as "read-only" via NFS.
The scheme used in disk partitioning of a system will depend heavily on the applications used, disk sizes and other factors already mentioned.
But it is important that you remember the need for the Kernel and boot manager to be within the first 1024 cylinders (if your BIOS or EFI does not support it), and allocate for the swap partition at least the same size as the RAM memory.
Learn much more about Linux in our online course. You can enroll here with a 7-day free trial. If you already have an account, you can access it here.
Did you like it? Share :-)
That was just one piece. The course teaches the whole path — from your first command to exam day.