LPI Linux Certification/Design Hard Disk Layout
(LPIC-1 Version 5.0)
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
/bootpartition conforms to the hardware requirements for booting.
The following is a partial list of the used files, terms and utilities:
- EFI System Partition (ESP)
- swap space
- mount points
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:
ext2 one of the oldest and most universally supported filesystems on Linux, Unix, and BSD operating systems ext3 an extended version of ext2 which overcomes some limitations and adds journaling ext4 fourth extended filesystem - it is a journaling file system for Linux, developed as the successor to ext3. btrfs reiserfs an enhanced journaling filesystem written by Hans Reiser and extended by the open source community since his incarceration jfs xfs fat or vfat the file allocation table-based filesystem used by MS-DOS and Windows 9x NTFS A more advanced (than fat) filesystem used by Windows NT, 2000, XP and Vista
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.
$ mount dev/hda3 on / type reiserfs (rw) proc on /proc type proc (rw) devpts on /dev/pts type devpts (rw) /dev/hda1 on /boot type ext2 (rw) shmfs on /dev/shm type shm (rw) usbdevfs on /proc/bus/usb type usbdevfs (rw)
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 issuesEdit
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)Edit
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.
swapon -s # Display the active partition
To get information on the usage of virtual memory, use vmstat.
$ vmstat -n 1 procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 5 0 1 184 3228 37684 92828 0 0 37 19 124 228 3 0 97 1 0 0 184 3476 37684 92596 0 0 0 0 102 368 0 0 100 2 0 0 184 3476 37684 92596 0 0 0 0 101 328 0 0 100 R:processes waiting for run time. b: processes in uninterruptable sleep. w: processes swapped out. swpd: virtual memory used (kB). free: Idle memory (kB). buff: Memory used as buffers (kB). si: Memory swapped in from disk (kB/s). so: Memory swapped to disk (kB/s). bi: Blocks received from a block device (blocks/s). bo: Blocks sent to a block device (blocks/s). in: The number of interrupts per second. cs: The number of context switches per second. us: user time sy: system time id: idle time
- 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?