The Linux File System
◾
413
This minimum size dictates the number of initial PEs allocated to that logical volume. The
estimated total size is only a suggestion of how many PEs the volume might eventually use.
As the logical volume grows in size, it is allocated more PEs. In this way,
a poorly esti-
mated total size should not require repartitioning. As long as PEs are available, any of the
logical volumes (partitions) can grow. In addition, if disk space is freed up from a parti-
tion (for instance, by deleting unnecessary files), those PEs are handed back to the pool for
reuse for any of the logical volumes.
Figure 10.7 provides an illustration of the concepts described here. We see all of the
available physical volumes (two disks in this example) united together as a single volume
group. Each physical volume has PEs. A logical volume is a collection of PEs. The PEs are
allocated on an as-needed basis. Because of this, a logical volume’s
PEs are not all located
within one section of a disk drive but instead can range to include space from all of the
physical devices.
There are many reasons to use LVM over physical disk partitioning (recall that disk
partitioning does not physically alter the disk but portions out the disk space for different
uses). The biggest advantage of LVM is that the system administrator will not have to worry
about creating too small a partition, which later might need resizing. The LVM greatly
simplifies any disk maintenance that the administrator may be involved with. Another
benefit of LVM is in creating a backup of a partition. This can be done using LVM without
interfering with the accessibility of that partition. LVMs are also easily capable of incorpo-
rating more hard disk space as hard disk drives are added to the system without having to
repartition or partition anew the added space.
In essence, a new hard disk is added to the
single volume group providing additional PEs to the available pool. You can also establish
redundancy with LVM, simulating RAID technology.
There are some reasons for not using LVMs. First, the LVM introduces an added layer
of indirection in that access to a partition now requires identifying the PEs of the parti-
tion. This can lead to challenges in disaster recovery efforts as well as complications to
the boot process. Additionally, as a partition may no longer occupy disk blocks in close
2 Physical volumes made up of numerous PEs
(not shown to scale)
1
Volume group
4 Logical volumes made up of PEs as needed
FIGURE 10.7
Implementing logical volumes out of physical volumes using LVM.
414
◾
Linux with Operating System Concepts
proximity to each other but instead may be widely distributed because the PEs are pro-
vided on an as-needed basis, the efficiency of accessing large portions of the partition at
one time decreases. In Figure 10.7, we see that one of the logical volumes (the third from
the left) exists on two separate devices.
As booting takes place prior to the mounting of the file systems, the boot sector needs
to reside in an expected location. If the /boot partition were handled by the LVM, then its
placement is not predictable. Therefore, we separate the /boot
partition from LVM, creat-
ing (at least) two physical partitions, one containing /boot and the other containing our
volume group(s). If we have one volume group, then we have two physical partitions. The
volume group partition(s) then contain all of our logical partitions. If you reexamine the
first example of partitioning that we covered in Section 8.3.2 of Chapter 8 when we used
the LVM, you will see that we did exactly this: two partitions of /boot and a volume group,
the latter of which was partitioned using an LVM.
You establish your disk partitioning using LVM at the time you initially partition your
file space. However, you can modify the physical and logical volumes later through a suite
of commands. A few of the more useful commands are provided in Table 10.4. These com-
mands are also available
through the interactive, text-based
lvm2
program (which is usu-
ally called lvm in Linux systems). The lvm2 program is a front-end or interface for the
programs listed in Table 10.4. Note that Table 10.4 is only a partial listing of the LVM
programs available for creating and maintaining LVM-based partitions.
10.4.6 Mounting and Unmounting File Systems
Let us focus again on file systems with a discussion of mounting and unmounting them.
We use
mount
and
umount
to handle these tasks. Unfortunately, the mount command
can be complicated. We will focus on its more basic options.
At its simplest form, the mount command expects two arguments: the file system to
mount and the mount point. The mount point must already exist.
For instance, if we want
to mount a new file system to /home2, we would first have to create /home2. After issuing
the command
mkdir /home2
, we would have an empty directory. This is the mount
TABLE 10.4
Logical Volume Manager Commands
Do'stlaringiz bilan baham: