Ubuntu Server 18.04 – Understanding the Linux filesystem

Initial Configurations of Windows server 2019

Before we get into the subject of managing storage volumes, we’ll first need to have a better understanding of how the filesystem is laid out. The term filesystem itself can be somewhat confusing in the Linux world because it can refer to two different things, the default directory structure, as well as the actual filesystem we choose when formatting a volume (ext4, XFS, and so on). In this section, we’re going to take a quick look at the default directory structure.

In Linux (Ubuntu uses the Linux kernel and related utilities) the filesystem begins with a single forward slash, /. This is considered the beginning of the filesystem, and directories and sub-directories branch out from there. For example, consider the /home directory. This directory exists at the root level of the filesystem, which you can see from the fact that it begins with a forward slash. My home directory on my system is /home/jay, which means that it’s the directory jay, which is inside the directory home, and that directory is at the beginning of the filesystem. This is confusing at first, but becomes very logical once you become accustomed to it. To really bring this home, use the ls command against several directories on your server. If you execute ls / you will see all of the directories at the root of the filesystem. You’ll see the directory home among the results, among many others.

This default directory structure is part of the Filesystem Hierarchy Standard (FHS), which is a set of guidelines that defines how the directory structure is laid out. This specification defines the names of the directories, where they are located, and what they are for. Distributions will sometimes go against some of the definitions here, but for the most part, follow it fairly closely. This is why you may see a very similar (if not the same) directory structure on distributions of Linux other than Ubuntu.

So why is this important relative to managing storage volumes? When you add a volume to your server (which can be a physical disk in the case of a physical server, or a virtual disk when it comes to virtual machines) you format that volume, and then mount (attach) the volume to a directory on the filesystem. The directory you attach the volume to can have any name and be located anywhere you wish. The FHS defines specific directories for this purpose, but whether or not you follow that is up to you. You could certainly mount an additional drive to a directory called kittens located at the root of the filesystem, there’s nothing stopping you. The question is, should you? That’s what the FHS was defined to address.

A full walkthrough of the FHS is beyond the scope of this tutorial, but I have included a link to this specification at the end of the chapter should you decide to read more about it. There are some directories you definitely should know, however. Here are some of the more important ones.

Directory

Purpose

/

The beginning of the filesystem, all directories are underneath this

/home

User home directories

/root

The home directory for root (root doesn’t have a directory underneath /home)

/media

For removable media, such as flash drives

/mnt

For volumes that are intended to stay mounted for a while

/opt

Additional software packages (some programs are installed here, not as common)

/bin

Essential user binaries (ls, cp, and so on)

/proc

Virtual filesystem for OS-level components

/usr/bin

A majority of user commands

/usr/lib

Libraries

/usr/lib

Libraries

/var/log

Log files

 

Don’t worry if some of this doesn’t make sense right now, it will come with time. The main point here is that there are many directories, each having their own purpose. If you want to know the purpose of a particular directory, consult the FHS. If you’re curious where you should place something on a server, also consult the FHS. When we get to the section of mounting volumes later on in this chapter, we’ll use the filesystem directly.

Comments are closed.