Best Linux Partitioning Setup?

Over the years, there were many attempts to find the best way to partition the hard disk or even the virtual machine. Do you need to have /var, /tmp, /usr…etc as separate partitions? Some people say it depends on what applications your server is running. If it is a mail server, maybe the /var might grow really quickly. So a bigger partition is needed for /var.

With the introduction of LVM, things have changed. We can now shrink and expand partitions easily. In fact, the default partitioning scheme for some linux distros during installation is to use LVM – Just one partition for ‘/boot’ (100MB) and one for ‘/’ (using up rest of the disk space). This means that if you need a lot of space for /var, you need to increase the space for ‘/’ partition.

So if we have a new drive and wish to expand your ‘/’ partition for example, we have to umount the affected partition, do a resize2fs, then mount it back. Unmounting the ‘/’ partition while the machine is running is a big no no. The solution is to shutdown the machine and resize2fs the partition individually. Tough luck.

To overcome that, I suggest we separate the base OS from data – we create a separate partition call /home/data and place all the variable data, ie web, database, user, email…etc files in there. The only problem is that if you have selinux running, you need to fix the permissions.

I now have my ideal partitioning setup:

/dev/hda1 /boot (100MB)
/dev/hda2 swap (1.5 times my ram)
/dev/hda3 / (10000MB)
/dev/hda4 /home/data (just big enough will do)

I think the above partition scheme is simple and effective. Noticed the sequence of the partitions. I purposely put /home/data at the end so that I can expand it easily. Even though we know that /home/data will grow the fastest, I still believe in expanding it only when required (its easy enough). Assigning the rest of the disk space to it will only make it big and complicates the backup process if you decide to have one.

What if we want to expand the ‘/’ partition. This becomes abit complicated (beyond the scope now). That is why I allocate enough disk space for a long long time. I think 10G to 20G should last a long time.

Hope this article helps.


Like it.? Share it:

Comments are closed.