Boot and Hardware Management
Linux Package Management
The course is part of this learning path
"Linux Installation and Package Management" is the third course in this Linux certification series. You'll learn how to control the Linux boot process, how to understand and manage disk partitions and filesystems, and how Linux uses kernel libraries to manage hardware peripherals. We'll also take a closer look at the two most widely used Linux software package management systems: dpkg and rpm.
If you have thoughts or suggestions for this course, please contact Cloud Academy at firstname.lastname@example.org.
Designing Linux disk partitions
While mature Linux distributions like Debian, Ubuntu, and Fedora come with their own automated GUI installation progRAMs, that can smoothly handle most people's needs, at some point in your career as an administrator, you're probably still going to have to manually configure an installation that's meant to perform some special function. Coaxing nonstandard combinations of hardware and software to get along nicely with each other can still sometimes be a delicate and demanding process. So whether your future deployment security needs require that you completely separate parts of the file system from each other, or whether your reliability concerns demand a Raid 10 disk array, the solid understanding of Linux partitions and file systems you gain now will pay off solid dividends later. The principles of good disk design require balancing two opposites: separation and accessibility.
For example, you don't want regular users having access to each other's private files or to your system configuration files. But they can't be so completely cut off that they can't function either.
A partition is a portion of a disk drive that's been logically walled off from the rest of the disk. Thus, a single one terabyte disk can contain four primary partitions, each say 250 gigabytes in size. From the perspective of software and users, these four partitions can look and behave like four physically separate disks, with all the security benefits and access headaches that go with it. On the other hand, you can also design your media so that resources on multiple physical disks can appear to reside on a single disk through either the logical volume manager, LVM or mount points. We'll talk about LVMs a bit later in this video.
And even though we'll discuss mount points in a later course in this series, it can't hurt to quickly show you how it's done right now. I have a USB drive that's been designated as sdc. So it's primary data partition would be /dev/sdc1. We'll go to the /tmp directory and use mkdir (make directory) to create a directory called drive. We'll then type sudo mount /dev/sdc1 drive, then CD into the drive directory. ls will list all the contents, which are actually the contents of my USB drive, meaning that we've successfully mounted that drive to the directory /tmp/drive.
Let's begin with a look at the Linux file system itself. I divided the top level directories into four sections. The home directory, under which users directories and files are kept. The system directories like etc, var, and lib. Virtual or pseudo directories like dev and proc and boot which as we'll soon see is in a category all its own.
Under normal circumstances, you'll spread your installation over three partitions. The root file system, a single 500 megabyte partition containing the Boot file system, which includes the Master Boot record, and a swap partition for virtual memory for use when you run out of RAM. You will usually create a swap partition that's twice the size of your system RAM per graphic desktop computers and the same as your RAM for servers. But there's also times when you'll to keep the home directory tree on a separate partition or sometimes even on a separate disk entirely. This way, if something should happen to corrupt any or all of your system files, rendering your computer unbootable, it will be much less likely to have any effect on your user's personal and work files. That will give you the option of simply copying the entire home system intact to wherever you'd like to rebuild your computer. You will have to create their accounts and assign new passwords, something that shouldn't require more than a few minutes work . But their data will all survive.
Similarly, if you've got a development server that's accessed by a team of coders and admins using it as test bed for deployment experiments, you might want to keep the /var directories in a separate partition from everything else to contain the consequences of an experiment that might go wrong. However you decide to organize your partitions, you'll want to accurately anticipate how much space each will need.
It is possible to re-size a partition once it's been created, but it's something you'd far prefer to avoid because every re-size operation carries a risk of failure. And failure, in this area, usually means the complete loss of all disk data. So how much space will you need. The main Linux system can be comfortable on less than four gigabytes.
You might think you should save everything else for your /home directories and the terabytes of all those funny cat videos they're eagerly waiting to download. But there are other important things to consider. Linux systems can generate an awful lot of data, especially log files. And they're mostly kept in the /var/log directory. I've seen individual log files larger than 100 gigabytes. Naturally, as we'll discuss in a future video, you will want to properly rotate your logs so things don't get out of hand. But some projects might not let you. And there's always a chance, as I've seen happen many times, that someone will launch at test process on a virtual container and forget about it, allowing its logs to cheerfully consume a higher and higher percentage of total disk space. This, by the way, is one reason many administrators create a separate partition for var so that if things do get out of hand, it won't clog up the whole system.
So you'll have to carefully access how your system is going to be used in order to properly accommodate your actual needs. We'll talk about how you can actually create partitions in a later video. But for now, we'll break with our regular practice so we can illustrate what partitions might look like on a real system. Just this once , we'll use a GUI program. GParted is a front end for the command line partitioning tool, parted. And while Linux admins normally prefer the command line to anything else, some have even been known to order pizza from a terminal. gparted is something of an exception. As you can see, there are two hard drives in my system designated as sda and sdb.
sda is a semi-retired disk that, until it began showing some indications that it might soon fail, was my main system disk. I now keep it running just in case I ever need to access old files. My luck, it's been running this way for more than a year and hasn't yet failed. sdb is my current boot drive containing my live deployment of Ubuntu 14.04. You can see that it has three partitions. sdb1 is a 500 megabyte partition mounted to /boot/efi. It's obviously my boot partition with the Master Boot Record. Five hundred megabytes is probably far more than the boot partition will ever need. But in an age of incredibly cheap storage space, this has become pretty much a standard practice.
Note that the boot flag has been set, which signals to BIOS that is a bootable drive. Note also that it was formatted as fat32, which will allow it to be booted to Window Operating System should that be necessary. sdb2 is the largest partition, nearly 500 gigabytes and is mounted in two places. But the only detail that interests us right now is root represented by a single slash. And sdb3 is my swap partition set as a Linux swap File System. You can also see that all of these partitions are represented as devices in /dev directory.
Gparted's main purpos, of course, is to create, delete, and re-size partitions. We're not going to do that now though. By the way, you should definitely be aware that you can display the partition information for all your block devices from the command line using lsblk and a great deal more information using sudo fdsk -l.
As a quick review, partitions organize and protect data and file systems. You can mount file systems so they'll seem to live in different places than they actually do.
Introduction to the Linux Logical Volume Manager (LVM)
Normal Linux installations will create three partitions. Root, represented by a slash, boot, and swap. But for business and practical considerations, you might want to separate other directories. And you always need to care for the future space and access needs. Another way to manage drives and partitions is through LVM, Logical Volume Manager. If your system is already configured with LVM, which is something you're not expected to do for the LPI exam, you can use it to treat every physical hard drive attached to your computer as a single drive and to easily and safely re-size and rearrange any individual parts of those drives just about any way you like. For the exam, it's enough to be familiar with some of the basic LVM tools. First of all, PV stands for physical volume. VG stands for volume group, which is a collection of one or more physical volumes and LV represents logical volume, a virtual volume you create from the contents of a volume group. To create a volume group, you could use VG Create followed by the name you like to give your group, say My VG. You follow that with the physical partition or partitions you'd like to build the group.
In our case, that will be /dev/sdb2 and /dev/sdb3. To create a logical volume, use LV Create /l and the total size you want for your volume, 250 gigabytes in our case, /n followed by the name you'd like to give to the logical volume. And then the name of the volume group from where you'd like the space to come. Finally, use LV Scan to confirm that everything worked out the way you wanted it to .
To review, in LVM2, physical volumes are called PV, Volume Groups, VG, and Logical Volumes, LV. You create a new Volume Group using VG Create. Create a new Logical Volume with LV Create, and display your volumes using LV Scan.
David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.
Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.
Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.
His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.