|< Day Day Up >||
Logical Volume Management (LVM) can allow you to manage active partitions. Before LVM, there was no easy way to increase or reduce the
|On The Job||
This isn't quite true; you can use the GNU Parted utility to manage the size of an active partition. However, while the Red Hat curricula does refer to fdisk , there is no reference as of this writing to Parted. For more information on Parted, see www.gnu.org/software/parted.
For example, if you find that you have extra space on the /home directory partition and need more space on your /var directory partition for log files, LVM will let you reallocate the space. Alternatively, if you are managing a server on a growing network, new users will be common. You may come to the point where you need more room on your /home directory partition. With LVM, you can add a new physical disk and allocate its storage capacity to an existing /home directory partition.
|On The Job||
While LVM can be an important tool to manage partitions, it does not by itself provide redundancy. Do not use it as a substitute for RAID. However, you can use LVM in concert with a properly configured RAID array.
The LVM system organizes hard disks into Logical Volume (LV) groups. Essentially, physical hard disk partitions (or possibly RAID arrays) are set up in a bunch of equal-
Physical Volume (PV) is the standard partition that you add to the LVM mix. Normally, a physical volume is a standard primary or logical partition. It can also be a RAID array.
Physical Extent (PE)
Logical Extent (LE) is also a chunk of disk space. Every LE is mapped to a specific PE.
Logical Volume (LV)
Volume Group (VG) is composed of a group of LVs. It is the organizational group for LVM. Most of the commands that you'll use apply to a specific VG.
Logical Volume Management
One of the critical decisions during the Installation and Configuration exam is whether you install in text or graphical mode. Text mode is faster. However, if you're required to create an LVM group during your exam, you can configure with Disk Druid only if you install RHEL in graphical mode.
I can't give you a concrete time savings between graphical and text mode; it depends on the traffic demands (how many other users) and the hardware available during your exam. I can say that when I installed the standard RHEL server configuration in graphical mode, it took five minutes longer than the same process in text mode. If your computer has more than 256MB of RAM (and more than 16MB of video memory), I suspect the difference would decrease.
Alternatively, you can use the techniques I describe in this section to configure LVM groups during the exam. Even if you remember to configure LVM groups during the installation process, read through this section. During the exam, it'll allow you to confirm that the LVM groups were created correctly. And on the job, it'll allow you to create LVM groups for your users in the real world.
If you don't have to configure an LVM group during your Installation and Configuration exam, text mode saves you time. If you are asked to configure an LVM group during your exam, your choice depends on whether you can configure an LVM group more quickly during the graphical installation process or the techniques described in this chapter.
As of this writing, there are two basic ways to create an LVM Volume Group in Red Hat Enterprise Linux. You can set up an LVM if you install RHEL 3 in graphical mode, using Disk Druid. Alternatively, you can use the basic LVM commands to create and manage Volume Groups after Linux is installed. As LVM is not much good unless you can add and delete specific LVs, you should know the basic LVM commands. But the first step is to create a PV.
The first step to create an LVM is to start with a physical disk. If you have a freshly installed hard disk, you can set up a PV on the entire disk. For example, if that hard disk is attached as the third IDE hard disk (/dev/hdc), and you haven't configured partitions on the drive, you'd run the following command:
# pvcreate /dev/hdc
Alternatively, you can set up a new PV on a properly formatted partition. For example, assume that you've added a new partition, /dev/hdc2. You could then use fdisk or a similar tool to set it to the Linux LVM partition type. In fdisk, this corresponds to partition type 8e. The sequence of commands would look similar to the following:
# fdisk /dev/hdc Command (m for help) : t Partition number (1-4) 2 Partition ID (L to list options): 8e Command (m for help) : w
Once your partition is ready, you can run the following command to create a new PV on that partition (/dev/hdc2):
# pvcreate /dev/hdc2
Once you have two or more PVs, you can create a Volume Group (VG). You can substitute the
# vgcreate volumegroup /dev/hdc2 /dev/hdd2
You can add more room to any VG. When you create a new partition that you want to add to the VG, just extend it with the following command:
# vgextend volumegroup /dev/sda1
However, a new VG doesn't help you unless you can mount a filesystem on it. So you need to create a logical volume (LV), for this purpose. The following command creates an LV. You can add as many chunks of disk space (also known as Physical Extents or PEs) as you need.
# lvcreate -l number_of_PEs volumegroup -n logvol
This creates a device named /dev/ volumegroup/logvol . You can format this device as if it were a regular disk partition, and then mount the directory of your choice on your new logical volume.
But this isn't useful if you don't know how much space is associated with each PE. You could use trial and error, using the df command to check the size of the volume after you've mounted a directory on it. Alternatively, you can use the -L switch to set a size in MB. For example, the following command creates an LV named flex of 200MB:
# lvcreate -L 200M volumegroup -n flex
But that's not the last step. You may not get full credit for your work on the exam unless the directory gets mounted on the LVM group when you reboot your Linux computer. Based on a standard RHEL 3 /etc/fstab configuration file, you might add the following line to that file:
LABEL=/home/mj /home/mj ext3 defaults 1 2
Before this line can work, you'll need to set the label for this directory with the following command:
# e2label /dev/ volumegroup/logvol /home/mj
I describe the /etc/fstab file, including the meaning of the data in each these
|< Day Day Up >||