LVM Administrator's Guide Configuration and Administration
LVM Administrator's Guide: Configuration and Administration Copyright © 2007 Red Hat, Inc. 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. 1801 Varsity Drive Raleigh, NC 27606-2072 USA Phone: +1 919 754 3700 Phone: 888 733 4281 Fax: +1 919 754 3701 PO Box 13588 Research Triangle Park, NC 27709 USA Documentation-Deployment Copyright © 2007 by Red Hat, Inc.
Table of Contents Introduction .............................................................................................................. vii 1. About This Guide .......................................................................................... vii 2. Audience ...................................................................................................... vii 3. Software Versions ......................................................................................... vii 4.
LVM Administrator's Guide 3.10. Combining Volume Groups ...............................................................26 3.11. Backing Up Volume Group Metadata .................................................26 3.12. Renaming a Volume Group ...............................................................27 3.13. Moving a Volume Group to Another System .......................................27 3.14. Recreating a Volume Group Directory ................................................28 4.
LVM Administrator's Guide 4. Recovering Physical Volume Metadata ...........................................................63 5. Replacing a Missing Physical Volume ............................................................64 6. Removing Lost Physical Volumes from a Volume Group ..................................64 7. Insufficient Free Extents for a Logical Volume .................................................65 7. LVM Administration with the LVM GUI ...................................................
Introduction 1. About This Guide 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. 2. Audience This book is intended to be used by system administrators managing systems running the Linux operating system. It requires familiarity with Red Hat Enterprise Linux 5 and GFS file system administration. 3.
5. Document Conventions • Using GNBD with Global File System — Provides an overview on using Global Network Block Device (GNBD) with Red Hat GFS. • Linux Virtual Server Administration — Provides information on configuring high-performance systems and services with the Linux Virtual Server (LVS). • Red Hat Cluster Suite Release Notes — Provides information about the current release of Red Hat Cluster Suite. 5.
5. Document Conventions Tip A tip is typically an alternative way of performing a task. Important Important information is necessary, but possibly unexpected, such as a configuration change that will not persist after a reboot. Caution A caution indicates an act that would violate your support agreement, such as recompiling the kernel. Warning A warning indicates potential data loss, as may happen when tuning hardware for maximum performance.
Chapter 1. The LVM Logical Volume Manager This chapter provides a high-level overview of the components of the Logical Volume Manager (LVM). 1. Logical Volumes Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes. This provides much greater flexibility in a number of ways than using physical storage directly. A logical volume provides storage virtualization. With a logical volume, you are not restricted to physical disk sizes.
2. LVM Architecture Overview Using logical volumes, you can take device snapshots for consistent backups or to test the effect of changes without affecting the real data. The implementation of these features in LVM is described in the remainder of this document. 2. LVM Architecture Overview For the RHEL 4 release of the Linux operating system, the original LVM1 logical volume manager was replaced by LVM2, which has a more generic kernel framework than LVM1.
3. Running LVM in a Cluster Figure 1.1. LVM Logical Volume Components For detailed information on the components of an LVM logical volume, see Chapter 2, LVM Components. 3. Running LVM in a Cluster The Clustered Logical Volume Manager (CLVM) is a set of clustering extensions to LVM. These extensions allow a cluster of computers to manage shared storage (for example, on a SAN) using LVM. The clmvd daemon is the key clustering extension to LVM.
4. Document Overview 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. CLVM uses the locking services provided by the high availability symmetric infrastructure. Note CLVM requires changes to the lvm.conf file for cluster-wide locking.
4. Document Overview This remainder of this document includes the following chapters: • Chapter 2, LVM Components describes the components that make up an LVM logical volume. • Chapter 3, LVM Administration Overview provides an overview of the basic steps you perform to configure LVM logical volumes, whether you are using the LVM Command Line Interface (CLI) commands or the LVM Graphical User Interface (GUI).
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). Initializing a block device as a physical volume places a label near the start of the device. By default, the LVM label is placed in the second 512-byte sector.
1.2. Multiple Partitions on a Disk 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: • Administrative convenience It is easier to keep track of the hardware in a system if each real disk only appears once.
2. Volume Groups striped volumes. 2. Volume Groups Physical volumes are combined into volume groups (VGs). This creates a pool of disk space out of which logical volumes can be allocated. Within a volume group, the disk space available for allocation is divided into units of a fixed-size called extents. An extent is the smallest unit of space that can be allocated, Within a physical volume, extents are referred to as physical extents.
3.1. Linear Volumes 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 VG1 with a physical extent size of 4MB. This volume group includes 2 physical volumes named PV1 and PV2. The physical volumes are divided into 4MB units, since that is the extent size. In this example, PV1 is 100 extents in size (400MB) and PV2 is 200 extents in size (800MB).
3.2. Striped Logical 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 volumes have been carved out of the volume group: LV1, which is 250 extents in size (1000MB) and LV2 which is 50 extents in size (200MB).
3.2. Striped 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. For large sequential reads and writes, this can improve the efficiency of the data I/O. Striping enhances performance by writing data to a predetermined number of physical volumes in round-round fashion.
3.3. Mirrored Logical Volumes space on the underlying physical volumes that make up the volume group to support the stripe. For example, if you have a two-way stripe that uses up an entire volume group, adding a single physical volume to the volume group will not enable you to extend the stripe. Instead, you must add at least two physical volumes to the volume group. For more information on extending a striped volume, see Section 4.9, “Extending a Striped Volume”. 3.3.
3.4. Snapshot Volumes Note Mirrored logical volumes are not currently supported in a cluster. For information on creating and modifying mirrors, see Section 4.1.3, “Creating Mirrored Volumes”. 3.4. Snapshot Volumes The LVM snapshot feature provides the ability to create virtual images of a device at a particular instant without causing a service interruption.
3.4. Snapshot Volumes • You can execute the fsck command on a snapshot file system to check the file system integrity and determine whether the original file system requires file system repair. • Because the snapshot is read/write, you can test applications against production data by taking a snapshot and running tests against the snapshot, leaving the real data untouched. • You can create volumes for use with the Xen virtual machine monitor.
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. For descriptions of the CLI commands you can use to perform LVM administration, see Chapter 4, LVM Administration with CLI Commands.
3. Growing a File System on a Logical Volume that use the storage have local copies, but can recreate that from what is on the physical volumes. You can attach physical volumes to a different server if the LVM versions are compatible. 3. Growing a File System on a Logical Volume To grow a file system on a logical volume, perform the following steps: 1. Make a new physical volume. 2.
5. Logging • external log function The logging levels are set in the /etc/lvm/lvm.conf file, which is described in Appendix B, The LVM Configuration Files.
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. 1. Using CLI Commands There are several general features of all LVM CLI commands. When sizes are required in a command line argument, units can always be specified explicitly. If you do not specify a unit, then a default is assumed, usually KB or MB. LVM CLI commands do not accept fractions.
2. Physical Volume Administration tails about the command execution. The -vvvv argument provides the maximum amount of information at this time. The following example shows only the first few lines of output for the lvcreate command with the -vvvv argument specified. # lvcreate -vvvv -L 50MB new_vg #lvmcmdline.c:913 Processing: lvcreate -vvvv -L 50MB new_vg #lvmcmdline.c:916 O_DIRECT will be used #config/config.c:864 Setting global/locking_type to 1 #locking/locking.c:138 File-based locking selected.
2.2. Displaying Physical Volumes dd if=/dev/zero of=PhysicalVolume bs=512 count=1 2.1.2. Initializing Physical Volumes Use the pvcreate command to initialize a block device to be used as a physical volume. Initialization is analogous to formatting a file system. The following command initializes /dev/sdd1, /dev/sde1, and /dev/sdf1 for use as LVM physical volumes. pvcreate /dev/sdd1 /dev/sde1 /dev/sdf1 To initialize partitions rather than whole disks: run the pvcreate command on the partition.
2.3. Preventing Allocation on a Physical Volume 2.2. Displaying Physical Volumes There are three commands you can use to display properties of LVM physical volumes: pvs, pvdisplay, and pvscan. The pvs command provides physical volume information in a configurable form, displaying one line per physical volume. The pvs command provides a great deal of format control, and is useful for scripting. For information on using the pvs command to customize your output, see Section 9, “Customized Reporting for LVM”.
2.4. Resizing a Physical Volume previously been disallowed. 2.4. Resizing a Physical Volume If you need to change the size of an underlying block device for any reason, use the pvresize command to update LVM with the new size. You can execute this command while LVM is using 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 pvremove command.
3.2. Adding Physical Volumes to a Volume Group The contiguous policy requires that new extents are adjacent to existing extents. If there are sufficient free extents to satisfy an allocation request but a normal allocation policy would not use them, the anywhere allocation policy will, even if that reduces performance by placing two stripes on the same physical volume. The cling policy places new extents on the same physical volume as existing extents in the same stripe of the logical volume.
3.4. Scanning Disks for Volume Groups to Build the Cache File The vgdisplay command displays volume group properties (such as size, extents, number of physical volumes, etc.) in a fixed form. The following example shows the output of a vgdisplay command for the volume group new_vg. If you do not specify a volume group, all existing volume groups are displayed.
3.6. Changing the Parameters of a Volume Group command shrinks a volume group's capacity by removing one or more empty physical volumes. This frees those physical volumes to be used in different volume groups or to be removed from the system. vgreduce Before removing a physical volume from a volume group, you can make sure that the physical volume is not used by any logical volumes by using the pvdisplay command. # pvdisplay /dev/hda1 -- Physical volume --PV Name /dev/hda1 VG Name myvg PV Size 1.
3.8. Removing Volume Groups The following example deactivates the volume group my_volume_group. vgchange -a n my_volume_group If clustered locking is enabled, add ’e’ to activate or deactivate a volume group exclusively on one node or ’l’ to activate or/deactivate a volume group only on the local node. Logical volumes with single-host snapshots are always activated exclusively because they can only be used on one node at once.
3.12. Renaming a Volume Group Metadata backups and archives are automatically created on every volume group and logical volume configuration change unless disabled in the lvm.conf file. By default, the metadata backup is stored in the /etc/lvm/backup file and the metadata archives are stored in the / etc/lvm/archives file. You can manually back up the metadata to the /etc/lvm/backup file with the vgcfgbackup command.
3.14. Recreating a Volume Group Directory When the system is next shut down, you can unplug the disks that constitute the volume group and connect them to the new system. 4. When the disks are plugged into the new system, use the vgimport command to import the volume group, making it accessible to the new system. 5. Activate the volume group with the -a 6. Mount the file system to make it available for use. y argument of the vgchange command. 3.14.
4.1. Creating Logical Volumes The following command creates a 50 gigabyte logical volume named gfslv from the free extents in volume group vg0. lvcreate -L 50G -n gfslv vg0 You can use the -l argument of the lvcreate command to specify the size of the logical 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 mylv that uses 60% of the total space in volume group testvol.
4.1. Creating Logical Volumes 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 /dev/sda1 and then continues laying out the logical volume at extent 100. lvcreate -l 100 -n testlv testvg /dev/sda1:0-25:100- The default policy for how the extents of a logical volume are allocated is inherit, which applies the same policy as for the volume group.
4.1. Creating Logical Volumes copies of the file system: a linear logical volume plus one copy. Similarly, specifying -m2 creates two mirrors, yielding three copies of the file system. The following command creates a mirrored logical volume with a single mirror. The volume is 50 gigabytes in size, is named mirrorlv, and is carved out of volume group vg0: lvcreate -L 50G -m1 -n gfslv vg0 An LVM mirror divides the device being copied into regions that, by default, are 512KB in size.
4.2. Persistent Device Numbers 4.1.4. Changing Mirrored Volume Configuration You can convert a logical volume from a mirrored volume to a linear volume or from a linear volume to a mirrored volume with the lvconvert command. You can also use this command to reconfigure other mirror parameters of an existing logical volume, such as corelog. When you convert a logical volume to a mirrored volume, you are basically creating mirror legs for an existing volume.
4.4. Changing the Parameters of a Logical Volume Group lvreduce -l -3 vg00/lvol1 4.4. Changing the Parameters of a Logical Volume Group To change the parameters of a logical volume, use the lvchange command. For a listing of the parameters you can change, see the lvchange(8) man page. You can use the lvchange command to activate and deactivate logical volumes. To activate and deactivate all the logical volumes in a volume group at the same time, use the vgchange command, as described in Section 3.
4.8. Growing Logical Volumes There are three commands you can use to display properties of LVM logical volumes: lvs, lvdisplay, and lvscan. The lvs command provides logical volume information in a configurable form, displaying one line per logical volume. The lvs command provides a great deal of format control, and is useful for scripting. For information on using the lvs command to customize your output, see Section 9, “Customized Reporting for LVM”.
4.9. Extending a Striped Volume testlv to fill all of the unallocated space in the volume group myvg. [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.
4.10. Shrinking Logical Volumes At this point you cannot extend the striped logical volume to the full size of the volume group, because two underlying devices are needed in order to stripe the data. # lvextend vg/stripe1 -L 406G Using stripesize of last segment 64.00 KB Extending logical volume stripe1 to 406.00 GB Insufficient suitable allocatable extents for logical volume stripe1: 34480 more required To extend the striped logical volume, add another physical volume and then extend the logical volume.
5. Creating Snapshot Volumes al extents. lvreduce -l -3 vg00/lvol1 5. Creating Snapshot Volumes Use the -s argument of the lvcreate command to create a snapshot volume. A snapshot volume is writeable. LVM snapshots are not cluster-aware, so they require exclusive access to a volume. For information on activating logical volumes on individual nodes in a cluster, see Section 8, “Activating Logical Volumes on Individual Nodes in a Cluster”.
6. Controlling LVM Device Scans with Filters Note Because the snapshot increases in size as the origin volume changes, it is important to monitor the percentage of the snapshot volume regularly with the lvs command to be sure it does not fill. A snapshot that is 100% full is lost completely, as write to unchanged parts of the originin would be unable to succeed without corrupting the snapshot. 6.
7. Online Data Relocation filter = [ "a|^/dev/hda8$|", "r/.*/" ] For more information on the lvm.conf file, see Appendix B, The LVM Configuration Files and the lvm.conf(5) man page. 7. Online Data Relocation You can move data while the system is in use with the pvmove command. The pvmove command breaks up the data to be moved into sections and creates a temporary mirror to move each section. For more information on the operation of the pvmove command, see the pvmove(8) man page.
9. Customized Reporting for LVM To activate logical volumes exclusively on one node, use the lvchange -aey command. Alternatively, you can use lvchange -aly command to activate logical volumes only on the local node but not exclusively. You can later activate them on additional nodes concurrently. You can also activate logical volumes on individual nodes by using LVM tags, which are described in Appendix C, LVM Object Tags.
9.1. Format Control the -o argument. The following example displays the UUID of the physical volume in addition to the default fields. # pvs -o +pv_uuid PV VG /dev/sdb1 new_vg /dev/sdc1 new_vg /dev/sdd1 new_vg • Attr aaa- PSize 17.14G 17.14G 17.14G PFree 17.14G 17.09G 17.14G PV UUID onFF2w-1fLC-ughJ-D9eB-M7iv-6XqA-dqGeXY Joqlch-yWSj-kuEn-IdwM-01S9-XO8M-mcpsVe yvfvZK-Cf31-j75k-dECm-0RZ3-0dGW-tUqkCS Adding the -v argument to a command includes some extra fields.
9.2. Object Selection volume that would otherwise not appear in the output. For information on the output this argument yields, see Section 2, “Displaying Information on Failed Devices”. For a full listing of display arguments, see the pvs(8), vgs(8) and lvs(8) man pages. Volume group fields can be mixed with either physical volume (and physical volume segment) fields or with logical volume (and logical volume segment) fields, but physical volume and logical volume fields cannot be mixed.
9.2. Object Selection Argument Header Description pv_pe_count PE Number of physical extents pvseg_size SSize The segment size of the physical volume pvseg_start Start The starting physical extent of the physical volume segment pv_size PSize The size of the physical volume pv_tags PV Tags LVM tags attached to the physical volume pv_used Used The amount of space currently used on the physical volume pv_uuid PV UUID The UUID of the physical volume Table 4.1.
9.2. Object Selection /dev/sda1 /dev/sda1 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 vg vg vg vg vg vg vg vg vg lvm2 lvm2 lvm2 lvm2 lvm2 lvm2 lvm2 lvm2 lvm2 aaaaaaaaa- 17.14G 17.14G 17.14G 17.14G 17.14G 17.14G 17.14G 17.14G 17.14G 16.75G 16.75G 16.75G 17.14G 17.14G 17.14G 17.14G 17.14G 17.14G 126 150 172 0 0 0 0 0 0 24 22 4217 4389 4389 4389 4389 4389 4389 You can use the pvs -a command to see devices detected by LVM that have not been initialized as LVM physical volumes.
9.2.
9.2. Object Selection Argument Header Description physical volumes, logical volumes, and start physical extents and logical extents lv_attr Attr The status of the logical volume. The logical volume attribute bits are as follows: Bit 1: Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot, (v)irtual Bit2: Permissions: (w)riteable, (r)ead-only Bit 3: Allocation policy: (c)ontiguous, (n)ormal, (a)nywhere, (i)nherited.
9.2.
9.3. Sorting LVM Reports Using the -v argument with the lvs --segments command adds the following fields to the default display: seg_start, stripesize, chunksize. # lvs -v --segments Finding all logical volumes LV VG Attr Start SSize #Str Type Stripe Chunk lvol0 new_vg owi-a0 52.00M 1 linear 0 0 newvgsnap1 new_vg swi-a0 8.00M 1 linear 0 8.
9.4. Specifying Units To display a reverse sort, precede a field you specify after the -O argument with the - character. # pvs -o pv_name,pv_size,pv_free -O -pv_free PV 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 --units argument of the report command. You can specify (b)ytes, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (e)xabytes, (p)etabytes, and (h)uman-readable.
9.4. Specifying Units The following example displays the output of the pvs command in units of 4 megabytes. # pvs --units 4m PV VG /dev/sdb1 new_vg /dev/sdc1 new_vg /dev/sdd1 new_vg Fmt lvm2 lvm2 lvm2 Attr aaa- PSize 4388.00U 4388.00U 4388.00U PFree 4388.00U 4375.00U 4388.
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 new_logical_volume that consists of the disks at /dev/sda1, /dev/sdb1, and /dev/sdc1. 1.1. Creating the Physical Volumes To use disks in a volume group, you label them as LVM physical volumes. Caution This command destroys any data on /dev/sda1, /dev/sdb1, and /dev/sdc1.
1.4. Creating the File System 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.
2.3. Creating the Logical Volume [root@tng3-1 ~]# vgcreate striped_vol_group /dev/sda1 /dev/sdb1 /dev/sdc1 Volume group "striped_vol_group" successfully created You can use the vgs command to display the attributes of the new volume group. [root@tng3-1 ~]# vgs VG #PV #LV #SN Attr VSize VFree striped_vol_group 3 0 0 wz--n- 51.45G 51.45G 2.3. Creating the Logical Volume The following command creates the striped logical volume striped_logical_volume from the volume group striped_vol_group.
3.1. Determining Free Space unused space on the physical volumes, a new volume group can be created without adding new disks. In the initial set up, the logical volume mylv is carved from the volume group myvol, which in turn consists of the three physical volumes, /dev/sda1, /dev/sdb1, and /dev/sdc1. After completing this procedure, the volume group myvg will consist of /dev/sda1 and /dev/sdb1. A second volume group, yourvg, will consist of /dev/sdc1. 3.1.
3.4. Creating the New Logical Volume group yourvg. [root@tng3-1 ~]# lvchange -a n /dev/myvg/mylv [root@tng3-1 ~]# vgsplit myvg yourvg /dev/sdc1 Volume group "yourvg" successfully split from "myvg" You can use the vgs command to see the attributes of the two volume groups. [root@tng3-1 ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 2 1 0 wz--n- 34.30G 10.80G yourvg 1 0 0 wz--n- 17.15G 17.15G 3.4.
4. Removing a Disk from a Logical Volume 4. Removing a Disk from a Logical Volume This example shows how you can remove a disk from an existing logical volume, either to 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.
4.2. Moving Extents to a New Disk 4.2. Moving Extents to a New Disk In this example, the logical volume is distributed across three physical volumes in the volume group myvg as follows: [root@tng3-1]# pvs -o+pv_used PV VG Fmt Attr PSize PFree Used /dev/sda1 myvg lvm2 a17.15G 7.15G 10.00G /dev/sdb1 myvg lvm2 a17.15G 15.15G 2.00G /dev/sdc1 myvg lvm2 a17.15G 15.15G 2.00G We want to move the extents of /dev/sdb1 to a new device, /dev/sdd1. 4.2.1.
4.2. Moving Extents to a New Disk [root@tng3-1 ~]# vgreduce myvg /dev/sdb1 Removed "/dev/sdb1" from volume group "myvg" You can now reallocate the disk to another volume group or remove the disk from the system.
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 -v, -vv, -vvv, or -vvvv argument of any command for increasingly verbose levels of output. • If the problem is related to the logical volume activation, set 'activation = 1' in the 'log' section of the configuration file and run the command with the -vvvv argument.
3. Recovering from LVM Mirror Failure In this example, the failed device caused both a linear and a striped logical volume in the volume group to fail. The lvs command without the -P argument shows the following output. [root@link-07 tmp]# lvs -a -o +devices Volume group "vg" not found Using the -P argument shows the logical volumes that have failed. [root@link-07 tmp]# lvs -P -a -o +devices Partial mode. Incomplete volume groups will be activated read-only.
3. Recovering from LVM Mirror Failure Physical Physical Physical Physical Physical volume volume volume volume volume "/dev/sdf2" "/dev/sdg1" "/dev/sdg2" "/dev/sdh1" "/dev/sdh2" successfully successfully successfully successfully successfully created created created created created The following commands creates the volume group vg and the mirrored volume groupfs.
4. Recovering Physical Volume Metadata [root@link-08 ~]# pvcreate /dev/sda[12] Physical volume "/dev/sda1" successfully created Physical volume "/dev/sda2" successfully created [root@link-08 ~]# pvscan PV /dev/sdb1 VG vg lvm2 [67.83 GB / 67.10 GB free] PV /dev/sdb2 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdc1 VG vg lvm2 [67.83 GB / 67.83 GB free] 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.
4. Recovering Physical Volume Metadata 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. You may be able to recover the data the physical volume by writing a new metadata area on the physical volume specifying the same UUID as the lost metadata.
5. Replacing a Missing Physical Volume Physical volume "/dev/sdh1" successfully created You can then use the vgcfgrestore command to restore the volume group's metadata. [root@link-07 backup]# vgcfgrestore VG Restored volume group VG You can now display the logical volumes. [root@link-07 LV VG stripe VG stripe VG backup]# lvs -a -o +devices Attr LSize Origin Snap% -wi--- 300.00G -wi--- 300.
7. Insufficient Free Extents for a Logical Volume Like most LVM operations, the vgreduce command is reversible in a sense if you immediately use the vgcfgrestore command to restore the volume group metadata to its previous state.
Chapter 7. LVM Administration with the LVM GUI 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 system-config-lvm. The LVM chapter of the Red Hat Enterprise Linux Deployment Guide provides step-by-step instructions for configuring an LVM logical volume using this utility. In addition, the LVM GUI is availalbe as part of the Conga management interface.
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. In addition to LVM, device-mapper multipath and the dmraid command use the Device Mapper.
Appendix B. The LVM Configuration Files LVM supports multiple configuration files. At system startup, the lvm.conf configuration file is loaded from the directory specified by the environment variable LVM_SYSTEM_DIR, which is set to / etc/lvm by default. The lvm.conf file can specify additional configuration files to load. Settings in later files override settings from earlier ones. To display the settings in use after loading all the configuration files, execute the lvm dumpconfig command.
2. Sample lvm.conf File # # # # # # # # 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. Refer to 'man lvm.conf' for further information including the file layout. To put this file in a different directory and override /etc/lvm set the environment variable LVM_SYSTEM_DIR before running the tools. # This section allows you to configure which block devices should # be used by the LVM system.
2. Sample lvm.conf File # Advanced settings. # List of pairs of additional acceptable block device types found # in /proc/devices with maximum (non-zero) number of partitions. # types = [ "fd", 16 ] # If sysfs is mounted (2.6 kernels) restrict device scanning to # the block devices it believes are valid. # 1 enables; 0 disables. sysfs_scan = 1 # By default, LVM2 will ignore devices used as components of # software RAID (md) devices by looking for md superblocks. # 1 enables; 0 disables.
2. Sample lvm.conf File # Backups are stored in a human readable text format. backup { # Should we maintain a backup of the current metadata configuration ? # Use 1 for Yes; 0 for No. # Think very hard before turning this off! backup = 1 # Where shall we keep it ? # Remember to back up this directory regularly! backup_dir = "/etc/lvm/backup" # Should we maintain an archive of old metadata configurations. # Use 1 for Yes; 0 for No. # On by default. Think very hard before turning this off.
2. Sample lvm.conf File # # # # The default metadata format that commands should use - "lvm1" or "lvm2". The command line override is -M1 or -M2. Defaults to "lvm1" if compiled in, else "lvm2". format = "lvm1" # Location of proc filesystem proc = "/proc" # Type of locking to use. Defaults to local file-based locking (1). # Turn locking off by setting to 0 (dangerous: risks metadata corruption # if LVM2 commands get run concurrently). # Type 2 uses the external shared library locking_library.
2. Sample lvm.conf File # 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. A disk log ensures that a mirror does not need to be re-synced (all copies made the same) every time a machine reboots or crashes.
2. Sample lvm.conf File # pvmetadatasize = 255 # # # # # # # # # # # # List of directories holding live copies of text format metadata. These directories must not be on logical volumes! It's possible to use LVM2 with a couple of directories here, preferably on different (non-LV) filesystems, and with no other on-disk metadata (pvmetadatacopies = 0). Or this can be in addition to on-disk metadata areas.
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. Snapshots cannot be tagged. Tags can be given on the command line in place of PV, VG or LV arguments. Tags should be prefixed with @ to avoid ambiguity.
3. Controlling Activation with Tags 3. Controlling Activation with Tags You can specify in the configuration file that only certain logical volumes should be activated on that host. For example, the following entry acts as a filter for activation requests (such as vgchange -ay) and only activates vg1/lvol0 and any logical volumes or volume groups with the database tag in the metadata on that host.
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.
3.
3. Sample Metadata extent_size = 8192 max_lv = 0 max_pv = 0 # 4 Megabytes physical_volumes { pv0 { id = "ZBW5qW-dXF2-0bGw-ZCad-2RlV-phwu-1c1RFt" device = "/dev/sda" # Hint only status = dev_size pe_start pe_count ["ALLOCATABLE"] = 35964301 # 17.1491 Gigabytes = 384 = 4390 # 17.1484 Gigabytes } pv1 { id = "ZHEZJW-MR64-D3QM-Rv7V-Hxsa-zU24-wztY19" device = "/dev/sdb" # Hint only status = dev_size pe_start pe_count ["ALLOCATABLE"] = 35964301 # 17.1491 Gigabytes = 384 = 4390 # 17.
3.
major, 32 minor, 32 persistent, 32 device path names, 18 device scan filters, 38 device size, maximum, 23 device special file directory, 23 display sorting output, 48 displaying logical volumes, 33, 45 physical volumes, 21, 42 volume groups, 23, 44 Index A activating logical volumes individual nodes, 39 activating volume groups, 25 individual nodes, 26 local node only, 26 administrative procedures, 15 allocation policy, 22 preventing, 21 archive file, 16, 26 E extent allocation, 22 definition, 8, 22 B ba
creation example, 51 definition, 1, 8 displaying, 33, 40, 45 exclusive access, 39 extending, 34 growing, 34 linear, 28 local access, 39 lvs display arguments, 45 mirrored, 30 reducing, 36 removing, 33 renaming, 33 resizing, 32 shrinking, 36 snapshot, 37 striped, 30 lvchange command, 33 lvconvert command, 32 lvcreate command, 28 lvdisplay command, 34 lvextend command, 34 LVM architecture overview, 2 clustered, 3 components, 2, 6 custom report format, 40 directory structure, 23 help, 19 history, 2 label, 6 lo
renaming logical volume, 33 volume group, 27 report format, LVM devices, 40 resizing logical volume, 32 physical volume, 22 administration, general, 22 changing parameters, 25 combining, 26 creating, 22 deactivating, 25 definition, 8 displaying, 23, 40, 44 extending, 23 growing, 23 merging, 26 moving between systems, 27 reducing, 24 removing, 26 renaming, 27 shrinking, 24 splitting, 26 example procedure, 53 vgs display arguments, 44 S scanning block devices, 20 scanning devices, filters, 38 snapshot logic