loading...

Ubuntu Server 18.04 – Planning the partitioning layout

How to Create MySQL Users Accounts and Grant Privileges

One of the many joys of utilizing Linux for server platforms is how flexible the partitioning is. Partitioning your disk allows you to divide up your hard disk to dedicate specific storage allocations to individual applications or purposes. For example, you can dedicate a partition for the files that are shared by your Apache web server so changes to other partitions won’t affect it. You can even dedicate a partition for your network file shares—the possibilities are endless. Each partition is mounted (attached) to a specific directory, and any files sent to that directory are thereby sent to that separate partition. The names you create for the directories where your partitions are mounted are arbitrary; it really doesn’t matter what you call them. The flexible nature of storage on Linux systems allows you to be creative with your partitioning as well as your directory naming.

Admittedly, we’re probably getting ahead of ourselves here. After all, we’re only just getting started and the point of this chapter is to help you set up a basic Ubuntu Server installation to serve as the foundation for the rest of the chapter. When going through the installation process, we’ll accept the defaults anyway. However, the goal of this section is to give you examples of the options you have for consideration later. At some point, you may want to get creative and play around with the partition layout.

With custom partitioning, you’re able to do some very clever things. For example, with the right configuration you’re able to wipe and reload your distribution while preserving user data, logs, and more. This works because Ubuntu Server allows you to carve up your storage any way you want during installation. If you already have a partition with data on it, you can choose to leave it as is so you can carry it forward into a new install. You simply set the directory path where it’s mounted to be the same as before, restore your configuration files, and your applications will continue working as if nothing happened.

One very common example of custom partitioning in the real world is separating the /home directory into its own partition. Since this is where users typically store their files, you can set up your server such that a reload of the distribution won’t disturb their files. When they log in after a server refresh, all their files will be right where they left them. You could even place the files shared by your Apache web server on to their own partition and preserve those too. You can get very creative here.

It probably goes without saying, but when reinstalling Ubuntu, you should backup partitions that have data you care about (even if you don’t plan on formatting the partitions). The reason being, one wrong move (literally a single checkbox) and you can easily wipe out all the data on that partition. Always backup your data when refreshing a server.

Another reason to utilize separate partitions may be to simply create boundaries or restrictions. If you have an application running on your server that is prone to filling up large amounts of storage, you can point that application to its own partition, limited by size. An example of where this could be useful is an application’s log files. Log files are the bane of any administrator when it comes to storage. While helpful if you’re trying to figure out why something crashed, logs can fill up a hard disk if you’re not careful. In my experience, I’ve seen servers come to a screeching halt due to log files filling up all the available free space on a server where everything was on a single partition. The only boundary the application had was the entirety of the disk.

While there are certainly better ways of handling excessive logging (log rotating, disk quotas, and so on), a separate partition also would have helped. If the application’s log directory was on its own partition, it would be able to fill up that partition, but not the entire drive. A full log partition will certainly cause issues, but it wouldn’t have been able to affect the entire server. As an administrator, it’s up to you to weigh the pros and the cons and develop a partitioning scheme that will best serve the needs of your organization.

Success when maintaining a server is a matter of efficiently managing resources, users, and security—and a good partitioning scheme is certainly part of that. Sometimes it’s just a matter of making things easier on yourself so that you have less work to do should you need to reload your operating system. For the sake of following along with this tutorial, it really doesn’t matter how you install or partition Ubuntu Server. The trick is simply to get it installed—you can always practice partitioning later. After all, part of learning is setting up a platform, figuring out how to break it in epic ways, and then fixing it up.

Here are some basic tips regarding partitioning:

  • At minimum, a partition for the root filesystem (designated by a forward slash) is required.
  • The /var directory contains most log files, and is a ripe candidate for separation.
  • The /home directory stores all user files. Separating this into a separate partition can be beneficial.
  • If you’ve used Linux before, you may be familiar with the concept of a swap partition. This is no longer necessary—a swap file will be created automatically in newer Ubuntu releases.

When we perform our installation in the next section, we’ll choose the defaults for the partitioning scheme to get you started quickly. However, I recommend you come back to the installation process at some point in the future and experiment with it. You may come up with some clever ways to split up your storage. However, you don’t have to—having everything in one partition is fine too, depending on your needs.

Comments are closed.

loading...