Reader small image

You're reading from  Mastering Linux Administration - Second Edition

Product typeBook
Published inMar 2024
PublisherPackt
ISBN-139781837630691
Edition2nd Edition
Right arrow
Authors (2):
Alexandru Calcatinge
Alexandru Calcatinge
author image
Alexandru Calcatinge

Alexandru Calcatinge is an open-minded architect with a background in computer science and mathematics. He is a senior university lecturer with a PhD in urban planning from Ion Mincu University of Architecture and Urban Planning and a postgraduate degree in DevOps from Caltech's Center for Technology and Management Education (CTME). He teaches students about architectural programming and development and open source technologies. He has authored five books on architecture and urban planning and numerous scientific articles on urban and rural development. Alex was certified as a Linux trainer in 2017. He loves the DevOps philosophy and the possibilities that cloud technologies bring for the future. He is also a certified programming analyst, computer network administrator, trainer, designer, and life coach.
Read more about Alexandru Calcatinge

Julian Balog
Julian Balog
author image
Julian Balog

Julian Balog is a senior software engineer with more than 15 years of experience in the industry. Currently, his work primarily focuses on application delivery controllers, containerized workflows, networking, and security. With a never-ending passion for Linux and open-source technologies, Julian is always in pursuit of learning new things while solving problems and making things work through simple, efficient, and practical engineering. He lives with his wife, two children, and an Aussie-doodle in the greater Seattle area, Washington.
Read more about Julian Balog

View More author details
Right arrow

Working with Disks and Filesystems

In this chapter, you will learn how to manage disks and filesystems, how to use the Logical Volume Management (LVM) system, and how to mount and partition the hard drive, as well as gain an understanding of storage in Linux. You will also learn how to partition and format a disk, as well as how to create logical volumes, and you will gain a deeper understanding of filesystem types. In this chapter, we’re going to cover the following main topics:

  • Understanding devices in Linux
  • Understanding filesystem types in Linux
  • Understanding disks and partitions
  • Introducing LVM in Linux

Technical requirements

A basic knowledge of disks, partitions, and filesystems is preferred. No other special technical requirements are needed, just a working installation of Linux on your system. We will mainly use Ubuntu or Debian for this chapter’s exercises. All the commands used in this chapter can be replicated on any Linux distribution, even if you don’t use Debian or Ubuntu.

Understanding devices in Linux

As already stated on several occasions in this book, everything in Linux is a file. This also includes devices. Device files are special files in Unix and Linux operating systems. Those special files are interfaces to device drivers, and they are present in the filesystem as a regular file.

With no further ado, let’s see how Linux abstraction layers work. This will give you an overview of how hardware and software are related and interconnected.

Linux abstraction layers

Now is as good a time as any to discuss Linux system abstraction layers and how devices fit into the overall picture. Any computer is generally organized into two layers (or levels) – the hardware and the software levels:

  • Hardware level: This level contains the hardware components of your machine, such as the memory (RAM), central processing unit (CPU), and devices, including disks, network interfaces, ports, and controllers.
  • Software level: For all these...

Understanding filesystem types in Linux

When talking about physical media, such as hard drives or external drives, we are not referring to the directory structure. Here, we are talking about the structures that are created on the physical drive when formatting and/or partitioning it. These structures, depending on their type, are known as filesystems, and they determine how the files are managed when stored on the drive.

There are several types of filesystems, some being native to the Linux ecosystem, while others are not, such as specific Windows or macOS filesystems. In this section, we will describe only the Linux-native filesystems.

The most widely used filesystems in Linux are the extended filesystems, known as Ext, Ext2, Ext3, and Ext4, the XFS filesystem, ZFS, and btrfs (short for B-tree filesystem). Each of these have their strengths and weaknesses, but they are all able to do the job they were designed for. The extended filesystems are the ones that were most widely...

Understanding disks and partitions

Understanding disks and partitions is a key asset for any system administrator. Formatting and partitioning disks is critical, starting with system installation. Knowing the type of hardware available on your system is important, and it is therefore imperative to know how to work with it. One of these is the disk; let’s look at this in further detail.

Common disk types

A disk is a hardware component that stores your data. It comes in various types and uses different interfaces. The main disk types are the well-known spinning HDD, the SSD, and the non-volatile memory express (NVMe). SSDs and NVMes use RAM-like technologies, with better energy consumption and higher transfer rates than original spinning hard drives. The following interfaces are used:

  • Integrated Drive Electronics (IDE): This is an old standard that’s used on consumer hardware with small transfer rates. It’s now deprecated.
  • Serial Advanced Technology...

Introducing LVM in Linux

Some of you may have already heard of LVM. For those who do not know what it is, we will explain it briefly in this section. Imagine a situation where your disks run out of space. You can always move it to a larger disk and then replace the smaller one, but this implies system restarts and unwanted downtimes. As a solution, you can consider LVM, which offers more flexibility and efficiency. By using LVM, you can add more physical disks to your existing volume groups while they’re still in use. This still offers the possibility to move data to a new hard drive but with no downtime – everything is done while filesystems are online.

The utilities used in Linux for LVM management are called pvcreate, vgcreate, vgdisplay, lvcreate, lvextend, and lvdisplay. Let’s learn how to use them.

As we don’t have a system with LVM set up just yet, we will show you the steps that are necessary to create new LVM volumes by using another system...

Summary

Managing filesystems and disks is an important task for any Linux system administrator. Understanding how devices are managed in Linux, and how to format and partition disks, is essential. Furthermore, it is important to learn about LVM as it offers a flexible way to manage partitions.

Mastering those skills will give you a strong foundation for any basic administration task. In the following chapter, we will introduce you to the vast domain of networking in Linux.

Questions

If you managed to skim through some parts of this chapter, you might want to recap a few essential details about Linux filesystem and disk management:

  1. Think of another tool to use for working with disks and install it.

    Hint: Try installing parted and use it from the command line. You can also use GParted from the GUI.

  2. Experiment with using Disks (in GNOME) and KDE Partition Manager (in KDE) and use the command-line interface side by side.

    Hint: Keep both applications open and use the command-line utilities side by side. Try to format and mount a disk from the command line while keeping the GUI apps open.

  3. Format new partitions using different filesystems.

    Hint: Use btrfs instead of ext4.

  4. Explore your filesystem and disks.

    Hint: Use tools such as lsblk, df, and fdisk.

Further reading

For more information about what was covered in this chapter, please refer to the following Packt titles:

  • Linux Administration Best Practices, by Scott Alan Miller
  • Mastering Ubuntu Server – Fourth Edition, by Jay LaCroix
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Linux Administration - Second Edition
Published in: Mar 2024Publisher: PacktISBN-13: 9781837630691
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Alexandru Calcatinge

Alexandru Calcatinge is an open-minded architect with a background in computer science and mathematics. He is a senior university lecturer with a PhD in urban planning from Ion Mincu University of Architecture and Urban Planning and a postgraduate degree in DevOps from Caltech's Center for Technology and Management Education (CTME). He teaches students about architectural programming and development and open source technologies. He has authored five books on architecture and urban planning and numerous scientific articles on urban and rural development. Alex was certified as a Linux trainer in 2017. He loves the DevOps philosophy and the possibilities that cloud technologies bring for the future. He is also a certified programming analyst, computer network administrator, trainer, designer, and life coach.
Read more about Alexandru Calcatinge

author image
Julian Balog

Julian Balog is a senior software engineer with more than 15 years of experience in the industry. Currently, his work primarily focuses on application delivery controllers, containerized workflows, networking, and security. With a never-ending passion for Linux and open-source technologies, Julian is always in pursuit of learning new things while solving problems and making things work through simple, efficient, and practical engineering. He lives with his wife, two children, and an Aussie-doodle in the greater Seattle area, Washington.
Read more about Julian Balog