Certification Objective 11.06: Managing Logical Volumes

 < Day Day Up > 

Red Hat often waits a while before including software in its Linux distributions. I believe this practice promotes the interests of stability. This practice extends to Logical Volume Management (LVM). As a RHCE, you need to know how to add, remove, and resize Logical Volumes (LV).

You learned to create logical volumes during the installation process in Chapter 2, and after RHEL 3 is installed in Chapter 3. If you've created and mounted any Logical Volumes on your RHEL 3 computer, they should be readily available in the /etc/fstab configuration file. For example, I have a fairly generic LV for the /home directory on a different RHEL 3 computer, and it shows as the following command line in /etc/fstab:

/dev/Volume00/LogVol00  /home   ext3   defaults   1 2
Exam Watch 

In the Red Hat Exam Prep guide, Red Hat has recently added a requirement to add, remove, and resize LVs to the Troubleshooting and System Maintenance portion of the RHCE exam.

Alternatively, you should be able to find the same basic information with the vgscan command. You can verify configured volume groups (VG) with the vgdisplay command. For example, Figure 11-13 illustrates the configuration of logical volume Volume00.

click to expand
Figure 11-13: Configuration of a Logical Volume (LV)

Before Logical Volumes are useful, you need to know how to add another LV. For example, if you've added more users, and they need more room than you have on the /home directory, you may need to add more LV for other filesystems, or resize the current /home directory Logical Volume.

On The Job 

Linux can't read /boot files if they're installed on a Logical Volume.

If you haven't added an LV before, you'll need to set up the basic files and the kernel LVM module, lvm-mod. To do so, run the vgscan command. This creates the /etc/lvmtab configuration file and adds the lvm-mod module. The next time you boot Linux, the /etc/rc.d/rc.sysinit file finds your /etc/lvmtab file and automatically loads the lvm-mod module.

Adding Another Logical Volume

Adding another LV is a straightforward process. I've described it in some detail in Chapter 3, so I only summarize the steps here. For example, if you've just added a fourth SCSI hard drive, it's known as device /dev/sdd. If you need more Logical Vvolumes for the /tmp directory, you'd follow these basic steps:

  1. Add the new hard drive.

  2. Configure the new hard drive with partitions using a command tool such as fdisk. Make sure the hex code for the LVM partition(s) corresponds to the Linux LVM format. It's code 8e within fdisk. Alternatively, you can dedicate all space on the new hard drive as a Physical Volume (PV) with the pvcreate /dev/sdd command.

  3. If you've created separate partitions, you can dedicate the space of a specific partition to a PV. If you don't already have an empty logical volume, you'll need to create more than one. For example, for the first partition /dev/sdd1, you can do this with the following command:

    # pvcreate /dev/sdd1
  4. Next, you'll want to create a Volume Group (VG) from two or more empty, properly configured partitions (or drives). One way to do this, assuming you have an empty /dev/sdc3 partition, is with the following command:

    # vgcreate Volume01 /dev/sdc3 /dev/sdd1
  5. Before proceeding, you should inspect the VG with the vgdisplay command. I've illustrated an example back in Figure 11-13.

  6. You should now be able to add another LV with the lvcreate command. For example, the following command takes 20 Physical Extents (PE) for the new LV, LogVol01:

    # lvcreate -l 20 Volume01 -n LogVol01
  7. You've added a new logical volume. Naturally, you'll need to format and mount a directory on this LV before you can use it. For the example shown, you would use the following commands:

    # mkfs -j /dev/Volume01/LogVol01 # mount -t ext3 /dev/Volume01/LogVol01 /tmp 

Removing Logical Volumes

Removing an existing LV requires a straightforward command. The basic command is lvremove. If you've created an LV in the previous section and want to remove it, the basic steps are simple:

  1. Save any data in directories that are mounted on the LV.

  2. Unmount any directories associated with the LV. Based on the example in the previous section, you would use the following command:

    # umount /dev/Volume01/LogVol01
  3. Apply the lvremove command to the LV with a command such as:

    # lvremove /dev/Volume01/LogVol01
  4. You should now have the PEs from this LV free for use in other LVs.

Resizing Logical Volumes

If you have an existing LV, you can add a newly created PV to extend the space available on your system. All it takes is appropriate use of the vgextend and lvextend commands. For example, if you want to add PEs to the VG associated with the aforementioned /home directory, you could take the following basic steps:

  1. Back up any data existing on the /home directory.

  2. Unmount the /home directory from the current logical volume.

  3. Extend the VG to include the new hard drive or partitions that you've created. For example, if you wanted to add /dev/sdd1 to the /home VG, you would run the following command:

    # vgextend Volume00 /dev/sdd1
  4. Make sure the new partitions are included in the VG with the following vgdisplay command:

    # vgdisplay Volume00
  5. Extend the current LV to include the space you need. For example, if you wanted to extend the LV to 2000MB, you'd run the following command:

    # lvextend -L2000M /dev/Volume00/LogVol00

    The lvextend command can help you configure LVs in KB, MB, GB, or even TB. For example, you could get the same result with the following command:

    # lvextend -L2G /dev/Volume00/LogVol00
  6. Reformat and remount the LV, using commands described earlier:

    # mkfs -j /dev/Volume00/LogVol00 # mount -t ext3 /dev/Volume00/LogVol00 /home

 < Day Day Up > 

RCHE Red Hat Certified Engineer Linux Study Guide[c] Exam (Rh302)
RCHE Red Hat Certified Engineer Linux Study Guide[c] Exam (Rh302)
ISBN: 71765654
Year: 2003
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net