Red Hat LVM ADMINISTRATOR FOR RHEL 4.5 Administrator's Manual

Lvm administrator's guide for rhel 4.5
Table of Contents

Advertisement

Quick Links

LVM Administrator's Guide for RHEL 4.5
Configuration and
Administration
4.5
Cluster_Logical_Volume_Manager
ISBN: N/A
Publication date: July 2008

Advertisement

Table of Contents
loading

Summary of Contents for Red Hat LVM ADMINISTRATOR FOR RHEL 4.5

  • Page 1 LVM Administrator's Guide for RHEL 4.5 Configuration and Administration Cluster_Logical_Volume_Manager ISBN: N/A Publication date: July 2008...
  • Page 2 LVM Administrator's Guide for RHEL 4.5 This book describes the LVM logical volume manager, including information on running LVM in a clustered environment. The content of this document is specific to the LVM2 release in Red Hat Enterprise Linux Release 4.5.
  • Page 3 All other trademarks referenced herein are the property of their respective owners. The GPG fingerprint of the security@redhat.com key is: CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E...
  • Page 4 LVM Administrator's Guide for RHEL 4.5...
  • Page 5: Table Of Contents

    Introduction ....................... ix 1. Audience ....................... ix 2. Software Versions ..................ix 3. Related Documentation .................. ix 4. Document Conventions ...................x 5. Feedback ...................... xi 1. The LVM Logical Volume Manager ................1 1. New and Changed Features ................1 2.
  • Page 6 LVM Administrator's Guide for RHEL 4.5 3.10. Combining Volume Groups ...............31 3.11. Backing Up Volume Group Metadata ..........31 3.12. Renaming a Volume Group ...............31 3.13. Moving a Volume Group to Another System ........32 3.14. Recreating a Volume Group Directory ..........33 4.
  • Page 7 1. Troubleshooting Diagnostics ................69 2. Displaying Information on Failed Devices ............69 3. Recovering from LVM Mirror Failure ...............71 4. Recovering Physical Volume Metadata ............74 5. Replacing a Missing Physical Volume ............76 6. Removing Lost Physical Volumes from a Volume Group ........76 7.
  • Page 8 viii...
  • Page 9: Introduction

    Introduction This book describes the Logical Volume Manager (LVM), including information on running LVM in a clustered environment. The content of this document is specific to the LVM2 release. 1. Audience This book is intended to be used by system administrators managing systems running the Linux operating system.
  • Page 10: Document Conventions

    Red Hat Cluster Suite documentation and other Red Hat documents are available in HTML and PDF versions online at the following location: http://www.redhat.com/docs 4. Document Conventions Certain words in this manual are represented in different fonts, styles, and weights. This highlighting indicates that the word is part of a specific category.
  • Page 11: Feedback

    Feedback /bin/ bold font Bold font represents application programs and text found on a graphical interface. When shown like this: OK , it indicates a button on a graphical application interface. Additionally, the manual uses different strategies to draw your attention to pieces of information. In order of how critical the information is to you, these items are marked as follows: Note A note is typically information that you need to understand the behavior of the...
  • Page 12 Introduction If you spot a typo, or if you have thought of a way to make this manual better, we would love to hear from you. Please submit a report in Bugzilla (http://bugzilla.redhat.com/bugzilla/) against the component rh-cs Be sure to mention the manual's identifier: rh-clvm(EN)-4.5 (2008-07-31T15:15)
  • Page 13: The Lvm Logical Volume Manager

    Chapter 1. The LVM Logical Volume Manager This chapter provides a high-level overview of the components of the Logical Volume Manager (LVM), and includes a summary of new and changed LVM features in Red Hat Enterprise Linux 4.5. 1. New and Changed Features This section lists new and changed features included with the initial release of Red Hat Enterprise Linux 4.5.
  • Page 14: Lvm Architecture Overview

    Chapter 1. The LVM Logical Volume Manager • Convenient device naming Logical storage volumes can be managed in user-defined groups, which you can name according to your convenience. • Disk striping You can create a logical volume that stripes data across two or more disks. This can dramatically increase throughput.
  • Page 15: Running Lvm In A Cluster

    Running LVM in a Cluster process is analogous to the way in which disks are divided into partitions. A logical volume is used by file systems and applications (such as databases). Figure 1.1, “LVM Logical Volume Components” shows the components of a simple LVM logical volume: Figure 1.1.
  • Page 16 Chapter 1. The LVM Logical Volume Manager Figure 1.2. CLVM Overview Logical volumes created with CLVM on shared storage are visible to all computers that have access to the shared storage. CLVM allows a user to configure logical volumes on shared storage by locking access to physical storage while a logical volume is being configured.
  • Page 17: Document Overview

    Document Overview Note CLVM requires changes to the file for cluster-wide locking. For lvm.conf information on configuring the file to support CLVM, see Section 1, lvm.conf “Creating LVM Volumes in a Cluster”. You configure LVM volumes for use in a cluster with the standard set of LVM commands or the LVM graphical user interface, as described in Chapter 4, LVM Administration with CLI Commands...
  • Page 19: Lvm Components

    Chapter 2. LVM Components This chapter describes the components of an LVM Logical volume. 1. Physical Volumes The underlying physical storage unit of an LVM logical volume is a block device such as a partition or whole disk. To use the device for an LVM logical volume the device must be initialized as a physical volume (PV).
  • Page 20: Multiple Partitions On A Disk

    Chapter 2. LVM Components In the Linux kernel (and throughout this document), sectors are considered to be 512 bytes in size. Figure 2.1. Physical Volume layout 1.2. Multiple Partitions on a Disk LVM allows you to create physical volumes out of disk partitions. It is generally recommended that you create a single partition that covers the whole disk to label as an LVM physical volume for the following reasons: •...
  • Page 21: Volume Groups

    Volume Groups may be necessary to move data around partitions when you are migrating an existing system to LVM volumes. Additionally, if you have a very large disk and want to have more than one volume group for administrative purposes then it is necessary to partition the disk. If you do have a disk with more than one partition and both of those partitions are in the same volume group, take care to specify which partitions are to be included in a logical volume when creating striped volumes.
  • Page 22 Chapter 2. LVM Components Figure 2.2. Extent Mapping The physical volumes that make up a logical volume do not have to be the same size. Figure 2.3, “Linear Volume with Unequal Physical Volumes” shows volume group with a physical extent size of 4MB. This volume group includes 2 physical volumes named .
  • Page 23 Linear Volumes Figure 2.3. Linear Volume with Unequal Physical Volumes You can configure more than one linear logical volume of whatever size you desire from the pool of physical extents. Figure 2.4, “Multiple Logical Volumes” shows the same volume group as in Figure 2.3, “Linear Volume with Unequal Physical Volumes”, but in this case two logical...
  • Page 24: Striped Logical Volumes

    Chapter 2. LVM Components Figure 2.4. Multiple Logical Volumes 3.2. Striped Logical Volumes When you write data to an LVM logical volume, the file system lays the data out across the underlying physical volumes. You can control the way the data is written to the physical volumes by creating a striped logical volume.
  • Page 25: Mirrored Logical Volumes

    Mirrored Logical Volumes Figure 2.5. Striping Data Across Three PVs Striped logical volumes can be extended by concatenating another set of devices onto the end of the first set. In order extend a striped logical volume, however, there must be enough free space on the underlying physical volumes that make up the volume group to support the stripe.
  • Page 26: Snapshot Volumes

    Chapter 2. LVM Components mirror or mirrors. This log can be kept on disk, which will keep it persistent across reboots, or it can be maintained in memory. Figure 2.6, “Mirrored Logical Volume” shows a mirrored logical volume with one mirror. In this configuration, the log is maintained on disk.
  • Page 27 Snapshot Volumes Because a snapshot copies only the data areas that change after the snapshot is created, the snapshot feature requires a minimal amount of storage. For example, with a rarely updated origin, 3-5 % of the origin's capacity is sufficient to maintain the snapshot. Note Snapshot copies of a file system are virtual copies, not actual media backup for a file system.
  • Page 29: Lvm Administration Overview

    Chapter 3. LVM Administration Overview This chapter provides an overview of the administrative procedures you use to configure LVM logical volumes. This chapter is intended to provide a general understanding of the steps involved. For specific step-by-step examples of common LVM configuration procedures, see Chapter 5, LVM Configuration Examples.
  • Page 30: Growing A File System On A Logical Volume

    Chapter 3. LVM Administration Overview 1. Create a GFS file system on the logical volume with the command. gfs_mkfs 2. Create a new mount point with the command. In a clustered system, create the mount mkdir point on all nodes in the cluster. 3.
  • Page 31: Logging

    Logging commands are described in Section 3.11, “Backing Up Volume Group vgcfgrestore Metadata”. 5. Logging All message output passes through a logging module with independent choices of logging levels for: • standard output/error • syslog • log file • external log function The logging levels are set in the file, which is described in Appendix B,...
  • Page 33: Lvm Administration With Cli Commands

    Chapter 4. LVM Administration with CLI Commands This chapter summarizes the individual administrative tasks you can perform with the LVM Command Line Interface (CLI) commands to create and maintain logical volumes. Note If you are creating or modifying an LVM volume for a clustered environment, you must ensure that you are running the daemon.
  • Page 34 Chapter 4. LVM Administration with CLI Commands # lvcreate -v -L 50MB new_vg Finding volume group "new_vg" Rounding up size to full physical extent 52.00 MB Archiving volume group "new_vg" metadata (seqno 4). Creating logical volume lvol0 Creating volume group backup "/etc/lvm/backup/new_vg" (seqno 5). Found volume group "new_vg"...
  • Page 35: Physical Volume Administration

    Physical Volume Administration object. This can be useful in a situation where you remove a physical volume called /dev/sdf which is part of a volume group and, when you plug it back in, you find that it is now /dev/sdk LVM will still find the physical volume because it identifies the physical volume by its UUID and not its device name.
  • Page 36: Displaying Physical Volumes

    Chapter 4. LVM Administration with CLI Commands You can scan for block devices that may be used as physical volumes with the lvmdiskscan command, as shown in the following example. # lvmdiskscan /dev/ram0 16.00 MB] /dev/sda 17.15 GB] /dev/root 13.69 GB] /dev/ram 16.00 MB] /dev/sda1...
  • Page 37: Preventing Allocation On A Physical Volume

    Preventing Allocation on a Physical Volume volume. # pvdisplay --- Physical volume --- PV Name /dev/sdc1 VG Name new_vg PV Size 17.14 GB / not usable 3.40 MB Allocatable PE Size (KByte) 4096 Total PE 4388 Free PE 4375 Allocated PE PV UUID Joqlch-yWSj-kuEn-IdwM-01S9-XO8M-mcpsVe command scans all supported LVM block devices in the system for physical...
  • Page 38: Removing Physical Volumes

    Chapter 4. LVM Administration with CLI Commands the physical volume. 2.5. Removing Physical Volumes If a device is no longer required for use by LVM, you can remove the LVM label with the command. Executing the command zeroes the LVM metadata on an empty pvremove pvremove physical volume.
  • Page 39: Adding Physical Volumes To A Volume Group

    Adding Physical Volumes to a Volume policy requires that new extents are adjacent to existing extents. If there are contiguous sufficient free extents to satisfy an allocation request but a allocation policy would not normal use them, the allocation policy will, even if that reduces performance by placing two anywhere stripes on the same physical volume.
  • Page 40: Scanning Disks For Volume Groups To Build The Cache File

    Chapter 4. LVM Administration with CLI Commands command, see Section 3.4, “Scanning Disks for Volume Groups to Build the Cache vgscan File”. command provides volume group information in a configurable form, displaying one line per volume group. The command provides a great deal of format control, and is useful for scripting.
  • Page 41: Removing Physical Volumes From A Volume Group

    Group LVM Device Scans with Filters”. The following example shows the output of a command. vgscan # vgscan Reading all physical volumes. This may take a while... Found volume group "new_vg" using metadata type lvm2 Found volume group "officevg" using metadata type lvm2 3.5.
  • Page 42: Activating And Deactivating Volume Groups

    Chapter 4. LVM Administration with CLI Commands There are several volume group parameters that you can change for an existing volume group with the command. Primarily, however, this command is used to deactivate and vgchange activate volume groups, as described in Section 3.7, “Activating and Deactivating Volume Groups”, The following command changes the maximum number of logical volumes of volume group...
  • Page 43: Combining Volume Groups

    Combining Volume Groups 3.9. Splitting a Volume Group To split the physical volumes of a volume group and create a new volume group, use the command. vgsplit Logical volumes cannot be split between volume groups. Each existing logical volume must be entirely on the physical volumes forming either the old or the new volume group.
  • Page 44: Moving A Volume Group To Another System

    Chapter 4. LVM Administration with CLI Commands vgrename /dev/vg02 /dev/my_volume_group vgrename vg02 my_volume_group 3.13. Moving a Volume Group to Another System You can move an entire LVM volume group to another system. It is recommended that you use commands when you do this. vgexport vgimport command makes an inactive volume group inaccessible to the system, which...
  • Page 45: Recreating A Volume Group Directory

    Logical Volume Administration 3.14. Recreating a Volume Group Directory To recreate a volume group directory and logical volume special files, use the vgmknodes command. This command checks the LVM2 special files in the directory that are needed /dev for active logical volumes. It creates any special files that are missing removes unused ones. You can incorporate the command into the command by specifying the...
  • Page 46 Chapter 4. LVM Administration with CLI Commands You can use the argument of the command to specify the size of the logical lvcreate volume in extents. You can also use this argument to specify the percentage of the volume group to use for the logical volume. The following command creates a logical volume called that uses 60% of the total space in volume group mylv testvol...
  • Page 47 Creating Logical Volumes following example creates a linear logical volume out of extents 0 through 25 of physical volume and extents 50 through 125 of physical volume in volume group /dev/sda1 /dev/sdb1 testvg lvcreate -l 100 -n testlv testvg /dev/sda1:0-25 /dev/sdb1:50-125 The following example creates a linear logical volume out of extents 0 through 25 of physical volume and then continues laying out the logical volume at extent 100.
  • Page 48 Chapter 4. LVM Administration with CLI Commands across two physical volumes, is named and is in volume group . The stripe will stripelv testvg use sectors 0-50 of and sectors 50-100 of /dev/sda1 /dev/sdb1 # lvcreate -l 100 -i2 -nstripelv testvg /dev/sda1:0-50 /dev/sdb1:50-100 Using default stripesize 64.00 KB Logical volume "stripelv"...
  • Page 49 Creating Logical Volumes ignored. The following command creates a mirrored logical volume with a single mirror. The volume is 500 megabytes in size, it is named , and it is carved out of volume group . The first mirrorlv leg of the mirror is on device , the second leg of the mirror is on device /dev/sda1 /dev/sdb1...
  • Page 50: Persistent Device Numbers

    Chapter 4. LVM Administration with CLI Commands 4.2. Persistent Device Numbers Major and minor device numbers are allocated dynamically at module load. Some applications work best if the block device always is activated with the same device (major and minor) number.
  • Page 51: Renaming Logical Volumes

    Removing Logical Volumes 4.5. Renaming Logical Volumes To rename an existing logical volume, use the command. lvrename Either of the following commands renames logical volume in volume group lvold vg02 lvnew lvrename /dev/vg02/lvold /dev/vg02/lvnew lvrename vg02 lvold lvnew For more information on activating logical volumes on individual nodes in a cluster, see Section 8, “Activating Logical Volumes on Individual Nodes in a Cluster”.
  • Page 52: Growing Logical Volumes

    Chapter 4. LVM Administration with CLI Commands mapping) in a fixed format. The following command shows the attributes of . If snapshot logical volumes have lvol2 vg00 been created for this original logical volume, this command shows a list of all snapshot logical volumes and their status (active or inactive) as well.
  • Page 53: Extending A Striped Volume

    Extending a Striped Volume [root@tng3-1 ~]# lvextend -l +100%FREE /dev/myvg/testlv Extending logical volume testlv to 68.59 GB Logical volume testlv successfully resized After you have extended the logical volume it is necessary to increase the file system size to match. By default, most file system resizing tools will increase the size of the file system to be the size of the underlying logical volume so you do not need to worry about specifying the same size for each of the two commands.
  • Page 54 Chapter 4. LVM Administration with CLI Commands The following command adds another physical volume to the volume group, which then has 135G of additional space. # vgextend vg /dev/sdc1 Volume group "vg" successfully extended # vgs #PV #LV #SN Attr VSize VFree 0 wz--n- 406.97G 135.66G...
  • Page 55: Shrinking Logical Volumes

    Shrinking Logical Volumes more required # lvextend -i1 -l+100%FREE vg/stripe1 4.10. Shrinking Logical Volumes To reduce the size of a logical volume, first unmount the file system. You can then use the command to shrink the volume. After shrinking the volume, remount the file system. lvreduce Caution It is important to reduce the size of the file system or whatever is residing in the...
  • Page 56: Controlling Lvm Device Scans With Filters

    Chapter 4. LVM Administration with CLI Commands The following example shows the status of the logical volume , for which a /dev/new_vg/lvol0 snapshot volume has been created. /dev/new_vg/newvgsnap # lvdisplay /dev/new_vg/lvol0 --- Logical volume --- LV Name /dev/new_vg/lvol0 VG Name new_vg LV UUID LBy1Tz-sr23-OjsI-LT03-nHLC-y8XW-EhCl78...
  • Page 57: Online Data Relocation

    Online Data Relocation rescanning. You can control which devices LVM scans by setting up filters in the configuration file. lvm.conf The filters consist of a series of simple regular expressions that get applied to the device names in the directory to decide whether to accept or reject each block device found. /dev The following examples show the use of filters to control which devices LVM scans.
  • Page 58: Activating Logical Volumes On Individual Nodes In A Cluster

    Chapter 4. LVM Administration with CLI Commands command breaks up the data to be moved into sections and creates a temporary pvmove mirror to move each section. For more information on the operation of the command, pvmove see the (8) man page. pvmove Because the command uses mirroring, it is not cluster-aware and needs exclusive...
  • Page 59: Customized Reporting For Lvm

    Customized Reporting for LVM You can also activate logical volumes on individual nodes by using LVM tags, which are described in Appendix C, LVM Object Tags. You can also specify activation of nodes in the configuration file, which is described in Appendix B, The LVM Configuration Files.
  • Page 60 Chapter 4. LVM Administration with CLI Commands • You can append a field to the output with the plus sign (+), which is used in combination with the -o argument. The following example displays the UUID of the physical volume in addition to the default fields.
  • Page 61: Object Selection

    Object Selection PV=VG=Fmt=Attr=PSize=PFree /dev/sdb1=new_vg=lvm2=a-=17.14G=17.14G /dev/sdc1=new_vg=lvm2=a-=17.14G=17.09G /dev/sdd1=new_vg=lvm2=a-=17.14G=17.14G To keep the fields aligned when using the argument, use the argument separator separator in conjunction with the argument. --aligned # pvs --separator = --aligned =Fmt =Attr=PSize =PFree /dev/sdb1 =new_vg=lvm2=a- =17.14G=17.14G /dev/sdc1 =new_vg=lvm2=a- =17.14G=17.09G /dev/sdd1 =new_vg=lvm2=a- =17.14G=17.14G You can use the...
  • Page 62 Chapter 4. LVM Administration with CLI Commands 17.09G 17.14G The pvs Command Table 4.1, “pvs Display Fields” lists the display arguments of the command, along with the field name as it appears in the header display and a description of the field. Argument Header Description...
  • Page 63 Object Selection # pvs -v Scanning for physical volume names Attr PSize PFree DevSize PV UUID /dev/sdb1 new_vg lvm2 a- 17.14G 17.14G 17.14G onFF2w-1fLC-ughJ-D9eB-M7iv-6XqA-dqGeXY /dev/sdc1 new_vg lvm2 a- 17.14G 17.09G 17.14G Joqlch-yWSj-kuEn-IdwM-01S9-XO8M-mcpsVe /dev/sdd1 new_vg lvm2 a- 17.14G 17.13G 17.14G yvfvZK-Cf31-j75k-dECm-0RZ3-0dGW-tUqkCS You can use the argument of the command to display information about each...
  • Page 64 Chapter 4. LVM Administration with CLI Commands /dev/ram5 /dev/ram6 /dev/root /dev/sda /dev/sdb /dev/sdb1 new_vg lvm2 a- 17.14G 17.14G /dev/sdc /dev/sdc1 new_vg lvm2 a- 17.14G 17.09G /dev/sdd /dev/sdd1 new_vg lvm2 a- 17.14G 17.14G The vgs Command Table 4.2, “vgs Display Fields” lists the display arguments of the command, along with the field name as it appears in the header display and a description of the field.
  • Page 65 Object Selection # vgs #PV #LV #SN Attr VSize VFree new_vg 1 wz--n- 51.42G 51.36G Using the argument with the command adds the following fields to the default display: vg_extent_size vg_uuid # vgs -v Finding all volume groups Finding volume group "new_vg" Attr #PV #LV #SN VSize VFree...
  • Page 66 Chapter 4. LVM Administration with CLI Commands Argument Header Description KMaj Actual major device number of the logical volume (-1 if lv_kernel_major inactive) KMIN Actual minor device number of the logical volume (-1 if lv_kernel_minor inactive) The persistent major device number of the logical volume (-1 lv_major if not specified) The persistent minor device number of the logical volume (-1...
  • Page 67 Object Selection # lvs Attr LSize Origin Snap% Move Log Copy% lvol0 new_vg owi-a- 52.00M newvgsnap1 new_vg swi-a- 8.00M lvol0 0.20 Using the argauament with the command adds the following fields to the default display: seg_count lv_major lv_minor lv_kernel_major lv_kernel_minor lv_uuid # lvs -v Finding all logical volumes...
  • Page 68: Sorting Lvm Reports

    Chapter 4. LVM Administration with CLI Commands argument specified. # lvs Attr LSize Origin Snap% Move Log Copy% lvol0 new_vg -wi-a- 52.00M # lvs --segments Attr #Str Type SSize lvol0 new_vg -wi-a- 1 linear 52.00M 9.3. Sorting LVM Reports Normally the entire output of the , or command has to be generated and stored internally before it can be sorted and columns aligned correctly.
  • Page 69: Specifying Units

    Specifying Units # pvs -o pv_name,pv_size,pv_free -O -pv_free PSize PFree /dev/sdd1 17.14G 17.14G /dev/sdb1 17.14G 17.14G /dev/sdc1 17.14G 17.09G 9.4. Specifying Units To specify the unit for the LVM report display, use the argument of the report --units command. You can specify (b)ytes, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (e)xabytes, (p)etabytes, and (h)uman-readable.
  • Page 70 Chapter 4. LVM Administration with CLI Commands The following example displays the output of the command as a number of sectors. # pvs --units s Attr PSize PFree /dev/sdb1 new_vg lvm2 a- 35946496S 35946496S /dev/sdc1 new_vg lvm2 a- 35946496S 35840000S /dev/sdd1 new_vg lvm2 a- 35946496S 35946496S...
  • Page 71: Lvm Configuration Examples

    Chapter 5. LVM Configuration Examples This chapter provides some basic LVM configuration examples. 1. Creating an LVM Logical Volume on Three Disks This example creates an LVM logical volume called that consists of the new_logical_volume disks at , and /dev/sda1 /dev/sdb1 /dev/sdc1 1.1.
  • Page 72: Creating The File System

    Chapter 5. LVM Configuration Examples [root@tng3-1 ~]# lvcreate -L2G -n new_logical_volume new_vol_group Logical volume "new_logical_volume" created 1.4. Creating the File System The following command creates a GFS file system on the logical volume. [root@tng3-1 ~]# gfs_mkfs -plock_nolock -j 1 /dev/new_vol_group/new_logical_volume This will destroy any data on /dev/new_vol_group/new_logical_volume.
  • Page 73: Creating The Volume Group

    Creating the Volume Group This command destroys any data on , and /dev/sda1 /dev/sdb1 /dev/sdc1 [root@tng3-1 ~]# pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1 Physical volume "/dev/sda1" successfully created Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdc1" successfully created 2.2. Creating the Volume Group The following command creates the volume group striped_vol_group [root@tng3-1 ~]# vgcreate striped_vol_group /dev/sda1 /dev/sdb1 /dev/sdc1...
  • Page 74: Splitting A Volume Group

    Chapter 5. LVM Configuration Examples Are you sure you want to proceed? [y/n] y Device: /dev/striped_vol_group/striped_logical_volume Blocksize: 4096 Filesystem Size: 492484 Journals: Resource Groups: Locking Protocol: lock_nolock Lock Table: Syncing... All Done The following commands mount the logical volume and report the file system disk space usage. [root@tng3-1 ~]# mount /dev/striped_vol_group/striped_logical_volume /mnt [root@tng3-1 ~]# df Filesystem...
  • Page 75: Moving The Data

    Splitting the Volume Group 3.2. Moving the Data You can move all the used physical extents in with the /dev/sdc1 /dev/sdb1 pvmove command. The command can take a long time to execute. pvmove [root@tng3-1 ~]# pvmove /dev/sdc1 /dev/sdb1 /dev/sdc1: Moved: 14.7% /dev/sdc1: Moved: 30.3% /dev/sdc1: Moved: 45.7% /dev/sdc1: Moved: 61.0%...
  • Page 76: Creating The New Logical Volume

    Chapter 5. LVM Configuration Examples 3.4. Creating the New Logical Volume After creating the new volume group, you can create the new logical volume yourlv [root@tng3-1 ~]# lvcreate -L5G -n yourlv yourvg Logical volume "yourlv" created 3.5. Making a File System and Mounting the New Logical Volume You can make a file system on the new logical volume and mount it.
  • Page 77: Moving Extents To Existing Physical Volumes

    Moving Extents to Existing Physical replace the disk or to use the disk as part of a different volume. In order to remove a disk, you must first move the extents on the LVM physical volume to a different disk or set of disks. 4.1.
  • Page 78: Moving Extents To A New Disk

    Chapter 5. LVM Configuration Examples /dev/sdd1 myvg lvm2 a- 17.15G 2.15G The disk can now be physically removed or allocated to other users. 4.2. Moving Extents to a New Disk In this example, the logical volume is distributed across three physical volumes in the volume group as follows: myvg...
  • Page 79 Volumes /dev/sdb1: Moved: 79.7% /dev/sdb1: Moved: 100.0% [root@tng3-1]# pvs -o+pv_used Attr PSize PFree Used /dev/sda1 myvg lvm2 a- 17.15G 7.15G 10.00G /dev/sdb1 myvg lvm2 a- 17.15G 17.15G /dev/sdc1 myvg lvm2 a- 17.15G 15.15G 2.00G /dev/sdd1 myvg lvm2 a- 17.15G 15.15G 2.00G 4.2.4.
  • Page 81: Lvm Troubleshooting

    Chapter 6. LVM Troubleshooting This chapter provide instructions for troubleshooting a variety of LVM issues. 1. Troubleshooting Diagnostics If a command is not working as expected, you can gather diagnostics in the following ways: • Use the , or argument of any command for increasingly verbose levels of -vvv -vvvv output.
  • Page 82 Chapter 6. LVM Troubleshooting Partial mode. Incomplete volume groups will be activated read-only. #PV #LV #SN Attr VSize VFree Devices 0 rz-pn- 2.11T 2.07T unknown device(0) 0 rz-pn- 2.11T 2.07T unknown device(5120),/dev/sda1(0) In this example, the failed device caused both a linear and a striped logical volume in the volume group to fail.
  • Page 83: Recovering From Lvm Mirror Failure

    Recovering from LVM Mirror Failure 3. Recovering from LVM Mirror Failure This section provides an example of recovering from a situation where one leg of an LVM mirrored volume fails because the underlying device for a physical volume goes down. When a mirror leg fails, LVM converts the mirrored volume into a linear volume, which continues to operate as before but without the mirrored redundancy.
  • Page 84 Chapter 6. LVM Troubleshooting /dev/sdb1(0) [groupfs_mlog] lwi-ao 4.00M /dev/sdc1(0) [root@link-08 ~]# lvs -a -o +devices Attr LSize Origin Snap% Move Log Copy% Devices groupfs mwi-a- 752.00M groupfs_mlog 100.00 groupfs_mimage_0(0),groupfs_mimage_1(0) [groupfs_mimage_0] vg iwi-ao 752.00M /dev/sda1(0) [groupfs_mimage_1] vg iwi-ao 752.00M /dev/sdb1(0) [groupfs_mlog] lwi-ao 4.00M /dev/sdc1(0)
  • Page 85 Recovering from LVM Mirror Failure PV /dev/sdc2 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdd1 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdd2 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sde1 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sde2...
  • Page 86: Recovering Physical Volume Metadata

    Chapter 6. LVM Troubleshooting Copy% Devices groupfs mwi-a- 752.00M groupfs_mlog 68.62 groupfs_mimage_0(0),groupfs_mimage_1(0) [groupfs_mimage_0] vg iwi-ao 752.00M /dev/sdb1(0) [groupfs_mimage_1] vg iwi-ao 752.00M /dev/sda1(0) [groupfs_mlog] lwi-ao 4.00M /dev/sdc1(0) 4. Recovering Physical Volume Metadata If the volume group metadata area of a physical volume is accidentally overwritten or otherwise destroyed, you will get an error message indicating that the metadata area is incorrect, or that the system was unable to find a physical volume with a particular UUID.
  • Page 87 Recovering Physical Volume Metadata Use the arguments of the command to restore the --uuid --restorefile pvcreate physical volume. The following example labels the device as a physical volume with /dev/sdh1 the UUID indicated above, . This command FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk restores the physical volume label with the metadata information contained in , the VG_00050.vg most recent good archived metatdata for volume group .
  • Page 88: Replacing A Missing Physical Volume

    Chapter 6. LVM Troubleshooting If the on-disk LVM metadata takes as least as much space as what overrode it, this command can recover the physical volume. If what overrode the metadata went past the metadata area, the data on the volume may have been affected. You might be able to use the command fsck to recover that data.
  • Page 89 Insufficient Free Extents for a Logical # vgdisplay --- Volume group --- Free PE / Size 8780 / 34.30 GB Alternately, you can use the arguments of the vg_free_count vg_extent_count command to display the free extents and the total number of extents. [root@tng3-1 ~]# vgs -o +vg_free_count,vg_extent_count #PV #LV #SN Attr VSize...
  • Page 91: Lvm Administration With The Lvm Gui

    Chapter 7. LVM Administration with the LVM In addition to the Command Line Interface (CLI), LVM provides a Graphical User Interface (GUI) which you can use to configure LVM logical volumes. You can bring up this utility by typing . The LVM chapter of the Red Hat Enterprise Linux Deployment Guide system-config-lvm provides step-by-step instructions for configuring an LVM logical volume using this utility.
  • Page 93: The Device Mapper

    Appendix A. The Device Mapper The Device Mapper is a kernel driver that provides a generic framework for volume management. It provides a generic way of creating mapped devices, which may be used as logical volumes. It does not specifically know about volume groups or metadata formats. The Device Mapper provides the foundation for a number of higher-level technologies.
  • Page 95: The Lvm Configuration Files

    Appendix B. The LVM Configuration Files LVM supports multiple configuration files. At system startup, the configuration file is lvm.conf loaded from the directory specified by the environment variable , which is set to LVM_SYSTEM_DIR by default. /etc/lvm file can specify additional configuration files to load. Settings in later files override lvm.conf settings from earlier ones.
  • Page 96 Appendix B. The LVM Configuration Files The following is a sample configuration file. lvm.conf [root@tng3-1 lvm]# cat lvm.conf # This is an example configuration file for the LVM2 system. # It contains the default settings that would be used if there was no # /etc/lvm/lvm.conf file.
  • Page 97 Sample lvm.conf File # When testing I like to work with just loopback devices: # filter = [ "a/loop/", "r/.*/" ] # Or maybe all loops and ide drives except hdc: # filter =[ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ] # Use anchors if you want to be really specific # filter = [ "a|^/dev/hda8$|", "r/.*/"...
  • Page 98 Appendix B. The LVM Configuration Files # There are 6 syslog-like log levels currently in use - 2 to 7 inclusive. # 7 is the most verbose (LOG_DEBUG). level = 0 # Format of output messages # Whether or not (1 or 0) to indent messages according to their severity indent = 1 # Whether or not (1 or 0) to display the command name on each line output...
  • Page 99 Sample lvm.conf File # Settings for the running LVM2 in shell (readline) mode. shell { # Number of lines of history to store in ~/.lvm_history history_size = 100 # Miscellaneous global LVM2 settings global { library_dir = "/usr/lib" # The file creation mask for any files and directories created. # Interpreted as octal if the first digit is zero.
  • Page 100 Appendix B. The LVM Configuration Files locking_type = 1 # If using external locking (type 2) and initialisation fails, # with this set to 1 an attempt will be made to use the built-in # clustered locking. # If you are using a customised locking_library you should set this to fallback_to_clustered_locking = 1 # If an attempt to initialise type 2 or type 3 locking failed, perhaps # because cluster components such as clvmd are not running, with this...
  • Page 101 Sample lvm.conf File # volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ] # Size (in KB) of each copy operation when mirroring mirror_region_size = 512 # 'mirror_image_fault_policy' and 'mirror_log_fault_policy' define # how a device failure affecting a mirror is handled. # A mirror is composed of mirror images (copies) and a log.
  • Page 102 Appendix B. The LVM Configuration Files # Metadata settings # metadata { # Default number of copies of metadata to hold on each PV. 0, 1 or 2. # You might want to override it from the command line with 0 # when running pvcreate on new PVs which are to be added to large VGs.
  • Page 103: Lvm Object Tags

    Appendix C. LVM Object Tags An LVM tag is a word that can be used to group LVM2 objects of the same type together. Tags can be attached to objects such as physical volumes, volume groups, and logical volumes. Tags can be attached to hosts in a cluster configuration.
  • Page 104: Controlling Activation With Tags

    Appendix C. LVM Object Tags if the hostname is host1 tags { tag1 { } tag2 { host_list = ["host1"] } } 3. Controlling Activation with Tags You can specify in the configuration file that only certain logical volumes should be activated on that host.
  • Page 105: Lvm Volume Group Metadata

    Appendix D. LVM Volume Group Metadata The configuration details of a volume group are referred to as the metadata. By default, an identical copy of the metadata is maintained in every metadata area in every physical volume within the volume group. LVM volume group metadata is small and stored as ASCII. If a volume group contains many physical volumes, having many redundant copies of the metadata is inefficient.
  • Page 106: Metadata Contents

    Appendix D. LVM Volume Group Metadata 2. Metadata Contents The volume group metadata contains: • Information about how and when it was created • Information about the volume group: The volume group information contains: • Name and unique id • A version number which is incremented whenever the metadata gets updated •...
  • Page 107 Sample Metadata creation_host = "tng3-1" # Linux tng3-1 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 creation_time = 1170196095 # Tue Jan 30 16:28:15 2007 myvg { id = "0zd3UT-wbYT-lDHq-lMPs-EjoE-0o18-wL28X4" seqno = 3 status = ["RESIZEABLE", "READ", "WRITE"] extent_size = 8192 # 4 Megabytes max_lv = 0...
  • Page 108 Appendix D. LVM Volume Group Metadata id = "GhUYSF-qVM3-rzQo-a6D2-o0aV-LQet-Ur9OF9" status = ["READ", "WRITE", "VISIBLE"] segment_count = 2 segment1 { start_extent = 0 extent_count = 1280 # 5 Gigabytes type = "striped" stripe_count = 1 # linear stripes = [ "pv0", 0 segment2 { start_extent = 1280 extent_count = 1280...
  • Page 109: Index

    exclusive on one node, 30 Index local node only, 30 device numbers major, 38 minor, 38 persistent, 38 activating logical volumes device path names, 21 individual nodes, 46 device scan filters, 44 activating volume groups, 30 device size, maximum, 27 individual nodes, 30 device special file directory, 27 local node only, 30...
  • Page 110 Index converting to mirrored, 37 lvreduce command, 38, 43 creation, 33 lvremove command, 39 definition, 9 lvrename command, 39 logging, 19 lvs command, 47, 53 logical volume display arguments, 53 administration, general, 33 lvscan command, 40 changing parameters, 38 creation, 33 creation example, 59 man page display, 22 definition, 1, 9...
  • Page 111 pvdisplay command, 24 vgchange command, 29 pvmove command, 45 vgcreate command, 26 pvremove command, 26 vgdisplay command, 28 pvresize command, 25 vgexport command, 32 pvs command, 47 vgextend command, 27 display arguments, 50 vgimport command, 32 pvscan command, 25 vgmerge command, 31 vgmknodes command, 33 vgreduce command, 29 vgrename command, 31...

This manual is also suitable for:

Configuration and administration 4.5

Table of Contents