Linux Partitioning Schemes
Linux Disk Partitioning Schemes and Layout
Planning your Hard Disk Layout
The layout of your partitioning scheme on Linux is fairly dependant on how you plan to use your system. Firstly, there is no correct solution to your layout, however, there are some simple best practice rules that you can apply that will be of benefit. By default, many Linux distributions will create a default layout normally creating partitions for "/", "/boot" and "swap". Although this will probably work quite well, it is not the ideal layout to use. Most distributions will give you multiple options at installation time regarding the layout of your disk. Many of these will also offer LVM (Logical Volume Manager) as a method of controlling your disk space.
Things to consider
As we mentioned earlier there is no de-facto layout for a Linux installation. However we should consider some of the following factors before we start.
Firstly, what distribution are you planning to install? Does the distribution have any size recommendations on its home page?
What will be the primary function of your server installation? (Web server, File Server, Database Server, Media Server, print server or family computer)
How many people will be using this system? (Single user, multi users, small office, call centre)
What is your backup strategy? (Are you using a custom rsync script, local to remote server backups, full data dump or incremental, synchronising automatically to the cloud)
What frequency of backups will you take? (Daily, weekly, monthly)
How important is your data?
What is your anticipated disk usage?
What strategy will you use if you need more space?
Simple Disk Layout with separate home area
A popular option when creating a disk layout is to have your "/home" area on a separate partition. The advantage of this is that you can at a later date upgrade or move to a different Linux distribution without having to delete your existing "/home" area. By separating filesystems away from the "/" area of your system, you system can continue to run if your home area becomes completely full. Another advantage to having a separate home area is that if you are unfortunate enough to experience a corrupted "/" system, your home area has a far greater chance of not being corrupted and can then be easily retrieved or used after the main system has been repaired. Below is an example of a single disk installation with a separate "/home" area:
john@crunchbang:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/crunchbang-root 2.4G 2.0G 329M 86% / tmpfs 506M 0 506M 0% /lib/init/rw udev 501M 168K 501M 1% /dev tmpfs 506M 4.0K 506M 1% /dev/shm /dev/sda1 228M 15M 202M 7% /boot /dev/mapper/crunchbang-home 5.0G 163M 4.6G 4% /home john@crunchbang:~$ sudo lvs [sudo] password for john: LV VG Attr LSize Origin Snap% Move Log Copy% Convert home crunchbang -wi-ao 5.06g root crunchbang -wi-ao 2.40g swap_1 crunchbang -wi-ao 300.00m
The above is a very small installation, with a single disk environment with a separate "/", "/boot" and "/home" partition. We have also used LVM for the "/" partition and also the "/home" area. If we need more space in the future, we can then assign more disk to the relevant Volume Groups. (See LVM Explanation)
Standard Partitioning Scheme
A standard approach often used with a Linux system is to use a partition scheme similar to the following:
|swap||2 x Physical RAM|
The above should be used as an example only and the sizes will differ depending on how big your initial hard disk is. In the above example the "/" root area contains the main operating system. "/home" is where all your downloads, documents would be stored. This is the equivalent to the Windows "Documents and Settings" area. You may want to increase this area if multiple users will be using this system. "/var" is the area used by most applications for storing log files. It is always best to keep this area on a separate partition. This is a precautionary measure. If "/var" shared the same partition space as "/" and a program encountered a serious problem, it is possible that "/var" could become filled quickly. This cold eventually lead to "/" filling up. "/tmp" is a temporary area that can be used by all users on the system. This area doesn't have to be too big as any data stored here is generally removed on boot. You should also keep in mind that larger Linux systems may only get booted once a month. This should be taken into consideration.
On many modern PCs it is quite command to see disk drives in the region of 500MB - 1TB in size. If this is the case you may want to add more space to your "/home" area.
Most Larger systems will use LVM (Logical Volume Manager) to manage disk space. Using LVM gives the System Administrator the ability to add or reduce space quickly and efficiently. This method is often used within Enterprises in conjunction with a SAN storage configuration. Here disk can be quickly deployed to servers and added with LVM where necessary.
For examples of LVM see our LVM Guide
During installation time of a Linux distribution you will assign or the installation will assign what is known as a "Swap Partition". This is an area of disk space that is used to store programs that do not need to be kept in physical memory. If the system requires more physical memory than is available, then programs are paged out to this swap space. This is also called "Virtual Memory". As a rule of thumb, the swap space partition should be around two times the amount of Physical Ram.
For example, if your system has 1GB of memory, you should create a Swap partition of 2GB.