# LPI Linux Certification/Design Hard Disk Layout
## Detailed Objectives

(LPIC-1 Version 5.0)
Weight: 2
Description:
Candidates should be able to design a disk partitioning scheme for a Linux system.
Key knowledge area(s):
* Allocate filesystems and swap space to separate partitions or disks.
* Tailor the design to the intended use of the system.
* Ensure the /boot partition conforms to the hardware requirements for booting.
The following is a partial list of the used files, terms and utilities:
* / (root) filesystem
* /var filesystem
* /home filesystem
* /boot filesystem
* EFI System Partition (ESP)
* swap space
* mount points
* partitions

## Filesystems

A filesystem is simply a way of organizing data in computer-accessible form on the hard disk or other media. Different filesystems have different organizing structures to determine where the data and indexing information will be stored. Some popular filesystems include:

## Partitions

When doing an installation there is normally a minimum disk configuration of two partitions that needs to be created:
* / (root): directory that contains the Linux distribution.
* Swap space: partition that allows a kernel to run more processes than can normally fit into RAM.
If multiple disks are available it is good practice to also have the /usr and /home directories on different partitions. Each partition will contain a filesystem type and can be mounted on the active system in the filesystem global tree. To print the active mounted filesystems, use mount.
The swap partition doesn't need a file system. It will be accessed in raw mode by the kernel with no filesystem system calls as overhead.

## Disk speed issues

Before deciding on your partitioning scheme, you really need to know exactly what sort of applications you will be running.
* Mail Server
* Web Server
* Graphical X-Windows based applications
* And more
If your system has multiple disks, use the fastest one to store most of your data.
* / Contains most of the system utilities and doesn't get used much. These can be shipped off to the slowest disk.
* /var/log contains a lot of logging information. Best on a fast disk.
* /usr is typically on a separate partition anyway and if you have a lot of clients starting lots of X applications, use a fast disk.
Examples of system applications:
For e-mail serving, Sendmail writes to two main locations: mail queue, usually /var/spool/mqueue and /var/spool/mail as well as other locations. Apache uses several different files, two log files per site hosted for logging and access to the actual pages. Apache spends quite a bit of time writing to log files in /var/log (or where configured to do so).

## Virtual memory (Swap)

When you set up a new system, swap should be twice your actual RAM. This is not always sensible in real-world scenarios, however it is a traditional guideline and a conservative answer to give in an exam. swapon is used to enable specified devices/partitions designated for swapping. On the contrary, swapoff is used to disable a specified device/partition of swapping. Both commands can take the -a option, which iterates all swap devices found in /proc/swaps or /etc/fstab.
Information on the swap partition can be displayed with swapon.
To get information on the usage of virtual memory, use vmstat.

## Exercises

* Exercises results
* Open two terminals: In one terminal display periodically the virtual memory usage. In the second terminal disable the virtual memory and re-enable it. Notify the changes in the first terminal.
* What is the disk layout of your system and how many disks do you have?
* How many swap space can you use?