Table of Contents

Advertisement

Quick Links

Red Hat Enterprise
Linux 5.1
Cluster Logical
Volume Manager
LVM Administrator's Guide

Advertisement

Table of Contents
loading

Summary of Contents for Red Hat ENTERPRISE LINUX 5.1 - LVM ADMINISTRATION

  • Page 1 Red Hat Enterprise Linux 5.1 Cluster Logical Volume Manager LVM Administrator's Guide...
  • Page 2 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 3: Table Of Contents

    Introduction 1. About This Guide ......................vii 2. Audience ........................vii 3. Software Versions ......................vii 4. Related Documentation ....................vii 5. Feedback ........................viii 6. Document Conventions ....................viii 6.1. Typographic Conventions ..................viii 6.2. Pull-quote Conventions ..................x 6.3.
  • Page 4 Cluster Logical Volume Manager 4.3.10. Combining Volume Groups ................24 4.3.11. Backing Up Volume Group Metadata ............... 24 4.3.12. Renaming a Volume Group ................25 4.3.13. Moving a Volume Group to Another System ............ 25 4.3.14. Recreating a Volume Group Directory ............. 26 4.4.
  • Page 5 6.4. Recovering Physical Volume Metadata ................ 66 6.5. Replacing a Missing Physical Volume ................67 6.6. Removing Lost Physical Volumes from a Volume Group ..........68 6.7. Insufficient Free Extents for a Logical Volume .............. 68 7. LVM Administration with the LVM GUI A.
  • Page 7: Introduction

    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.
  • Page 8: Feedback

    5. Feedback 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)-5.1 (2008-07-31T15:15)
  • Page 9 Typographic Conventions Key-combinations can be distinguished from key caps by the hyphen connecting each part of a key- combination. For example: Press Enter to execute the command. Press Ctrl-Alt-F1 to switch to the first virtual terminal. Press Ctrl-Alt-F7 to return to your X-Windows session.
  • Page 10: Pull-Quote Conventions

    Introduction To see the version of a currently installed package, use the rpm -q package command. It will return a result as follows: package-version-release. Note the words in bold italics above — username, domain.name, file-system, package, version and release. Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system.
  • Page 11: Notes And Warnings

    Notes and Warnings 6.3. Notes and Warnings Finally, we use three visual styles to draw attention to information that might otherwise be overlooked. Note A note is a tip or shortcut or alternative approach to the task at hand. Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier.
  • 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). 1.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.
  • Page 14: Lvm Architecture Overview

    Chapter 1. The LVM Logical Volume Manager 1.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. LVM2 provides the following improvements over LVM1: •...
  • Page 15: Running Lvm In A Cluster

    Running LVM in a Cluster 1.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.
  • Page 16: Document Overview

    Chapter 1. The LVM Logical Volume Manager result in data corruption. If you have any concerns please contact your Red Hat service representative. Note CLVM requires changes to the lvm.conf file for cluster-wide locking. For information Section 3.1, “Creating LVM on configuring the lvm.conf file to support CLVM, see Volumes in a Cluster”.
  • Page 17: Lvm Components

    Chapter 2. LVM Components This chapter describes the components of an LVM Logical volume. 2.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 18: Multiple Partitions On A Disk

    Chapter 2. LVM Components Figure 2.1. Physical Volume layout 2.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 19: Lvm Logical Volumes

    LVM Logical Volumes A logical volume is allocated into logical extents of the same size as the physical extents. The extent size is thus the same for all logical volumes in the volume group. The volume group maps the logical extents to physical extents.
  • Page 20: Striped Logical Volumes

    Chapter 2. LVM Components 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).
  • Page 21 Striped Logical Volumes 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. With striping, I/O can be done in parallel. In some situations, this can result in near-linear performance gain for each additional physical volume in the stripe.
  • Page 22: Mirrored Logical Volumes

    Chapter 2. LVM Components 2.3.3. Mirrored Logical Volumes A mirror maintains identical copies of data on different devices. When data is written to one device, it is written to a second device as well, mirroring the data. This provides protection for device failures. When one leg of a mirror fails, the logical volume becomes a linear volume and can still be accessed.
  • Page 23 Snapshot Volumes Note LVM snapshots are not supported across the nodes in a cluster. 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.
  • Page 25: 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 Chapter 5, LVM specific step-by-step examples of common LVM configuration procedures, see Configuration Examples.
  • Page 26: Growing A File System On A Logical Volume

    Chapter 3. LVM Administration Overview Creating the LVM volume is machine independent, since the storage area for LVM setup information is on the physical volumes and not the machine where the volume was created. Servers 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.
  • Page 27: 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 Section 3.1, ensure that you are running the clvmd daemon.
  • Page 28: Physical Volume Administration

    Chapter 4. LVM Administration with CLI Commands Found volume group "new_vg" Creating new_vg-lvol0 Loading new_vg-lvol0 table Resuming new_vg-lvol0 (253:2) Clearing start of logical volume "lvol0" Creating volume group backup "/etc/lvm/backup/new_vg" (seqno 5). Logical volume "lvol0" created You could also have used the -vv, -vvv or the -vvvv argument to display increasingly more details about the command execution.
  • Page 29: Creating Physical Volumes

    Creating Physical Volumes 4.2.1. Creating Physical Volumes The following subsections describe the commands used for creating physical volumes. 4.2.1.1. Setting the Partition Type If you are using a whole disk device for your physical volume, the disk must have no partition table. For DOS disk partitions, the partition id should be set to 0x8e using the fdisk or cfdisk command or an equivalent.
  • Page 30: Displaying Physical Volumes

    Chapter 4. LVM Administration with CLI Commands /dev/ram5 16.00 MB] /dev/ram6 16.00 MB] /dev/ram7 16.00 MB] /dev/ram8 16.00 MB] /dev/ram9 16.00 MB] /dev/ram10 16.00 MB] /dev/ram11 16.00 MB] /dev/ram12 16.00 MB] /dev/ram13 16.00 MB] /dev/ram14 16.00 MB] /dev/ram15 16.00 MB] /dev/sdb 17.15 GB] /dev/sdb1...
  • Page 31: Preventing Allocation On A Physical Volume

    Preventing Allocation on a Physical Volume The following command shows all physical devices found: # pvscan PV /dev/sdb2 VG vg0 lvm2 [964.00 MB / 0 free] PV /dev/sdc1 VG vg0 lvm2 [964.00 MB / 428.00 MB free] PV /dev/sdc2 lvm2 [964.84 MB] Total: 3 [2.83 GB] / in use: 2 [1.88 GB] / in no VG: 1 [964.84 MB] You can define a filter in the lvm.conf so that this command will avoid scanning specific physical Section 4.6,...
  • Page 32: Creating Volume Groups

    Chapter 4. LVM Administration with CLI Commands 4.3.1. Creating Volume Groups To create a volume group from one or more physical volumes, use the vgcreate command. The vgcreate command creates a new volume group by name and adds at least one physical volume to The following command creates a volume group named vg1 that contains physical volumes /dev/ sdd1 and /dev/sde1.
  • Page 33: Adding Physical Volumes To A Volume Group

    Adding Physical Volumes to a Volume Group /dev/myvg2/lv03 The maximum device size with LVM is 8 Exabytes on 64-bit CPUs. 4.3.2. Adding Physical Volumes to a Volume Group To add additional physical volumes to an existing volume group, use the vgextend command. The vgextend command increases a volume group's capacity by adding one or more free physical volumes.
  • Page 34: Scanning Disks For Volume Groups To Build The Cache File

    Chapter 4. LVM Administration with CLI Commands PE Size 4.00 MB Total PE 13164 Alloc PE / Size 13 / 52.00 MB Free PE / Size 13151 / 51.37 GB VG UUID jxQJ0a-ZKk0-OpMO-0118-nlwO-wwqd-fD5D32 4.3.4. Scanning Disks for Volume Groups to Build the Cache File The vgscan command scans all supported disk devices in the system looking for LVM physical volumes and volume groups.
  • Page 35: Changing The Parameters Of A Volume Group

    Changing the Parameters of a Volume Group Cur LV PE Size (KByte) 4096 Total PE Free PE Allocated PE PV UUID Sd44tK-9IRw-SrMC-MOkn-76iP-iftz-OVSen7 If the physical volume is still being used you will have to migrate the data to another physical volume using the pvmove command.
  • Page 36: Removing Volume Groups

    Chapter 4. LVM Administration with CLI Commands Section 4.8, “Activating Logical Volumes on logical volumes on individual nodes in a cluster, see Individual Nodes in a Cluster”. 4.3.8. Removing Volume Groups To remove a volume group that contains no logical volumes, use the vgremove command. # vgremove officevg Volume group "officevg"...
  • Page 37: Renaming A Volume Group

    Renaming a Volume Group For an example of using the vgcfgrestore command to recover physical volume metadata, see Section 6.4, “Recovering Physical Volume Metadata”. 4.3.12. Renaming a Volume Group Use the vgrename command to rename an existing volume group. Either of the following commands renames the existing volume group vg02 to my_volume_group vgrename /dev/vg02 /dev/my_volume_group vgrename vg02 my_volume_group 4.3.13.
  • Page 38: Recreating A Volume Group Directory

    Chapter 4. LVM Administration with CLI Commands 6. Mount the file system to make it available for use. 4.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 /dev directory that are needed for active logical volumes.
  • Page 39 Creating Logical Volumes 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.
  • Page 40 Chapter 4. LVM Administration with CLI Commands 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.
  • Page 41 Creating Logical Volumes 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.
  • Page 42: Persistent Device Numbers

    Chapter 4. LVM Administration with CLI Commands lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1:0-499 /dev/sdb1:0-499 / dev/sdc1:0 4.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.
  • Page 43: Changing The Parameters Of A Logical Volume Group

    Changing the Parameters of a Logical Volume Group The following command reduces the size of logical volume lvol1 in volume group vg00 by 3 logical extents. lvreduce -l -3 vg00/lvol1 4.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.
  • Page 44: Displaying Logical Volumes

    Chapter 4. LVM Administration with CLI Commands Logical volume "testlv" successfully removed You could explicitly deactivate the logical volume before removing it with the lvchange -an command, in which case you would not see the prompt verifying whether you want to remove an active logical volume.
  • Page 45: Extending A Striped Volume

    Extending a Striped Volume The following command adds another gigabyte to the logical volume /dev/myvg/homevol. # lvextend -L+1G /dev/myvg/homevol lvextend -- extending logical volume "/dev/myvg/homevol" to 13 GB lvextend -- doing automatic backup of volume group "myvg" lvextend -- logical volume "/dev/myvg/homevol" successfully extended As with the lvcreate command, you can use the -l argument of the lvextend command to specify the number of extents by which to increase the size of the logical volume.
  • Page 46 Chapter 4. LVM Administration with CLI Commands stripe1 vg -wi-a- 271.31G /dev/ sda1(0),/dev/sdb1(0) Note that the volume group now has no more free space. # vgs #PV #LV #SN Attr VSize VFree 0 wz--n- 271.31G The following command adds another physical volume to the volume group, which then has 135G of additional space.
  • Page 47: Shrinking Logical Volumes

    Shrinking Logical Volumes is to use the same striping parameters of the last segment of the existing logical volume, but you can override those parameters. The following example extends the existing striped logical volume to use the remaining free space after the initial lvextend command fails. # lvextend vg/stripe1 -L 406G Using stripesize of last segment 64.00 KB Extending logical volume stripe1 to 406.00 GB...
  • Page 48: Controlling Lvm Device Scans With Filters

    Chapter 4. LVM Administration with CLI Commands After you create a snapshot logical volume, specifying the origin volume on the lvdisplay command yields output that includes a a list of all snapshot logical volumes and their status (active or inactive). The following example shows the status of the logical volume /dev/new_vg/lvol0, for which a snapshot volume /dev/new_vg/newvgsnap has been created.
  • Page 49: Online Data Relocation

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

    Chapter 4. LVM Administration with CLI Commands pvmove /dev/sdc1 The following command moves just the extents of the logical volume MyLV. pvmove -n MyLV /dev/sdc1 Since the pvmove command can take a long time to execute, you may want to run the command in the background to avoid display of progress updates in the foreground.
  • Page 51: Format Control

    Format Control • Instructions for specifying the units of the report output. 4.9.1. Format Control Whether you use the pvs, lvs, or vgs command determines the default set of fields displayed and the sort order. You can control the output of these commands with the following arguments: •...
  • Page 52 Chapter 4. LVM Administration with CLI Commands /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.14G 17.14G yvfvZK-Cf31-j75k- dECm-0RZ3-0dGW-tUqkCS • The --noheadings argument suppresses the headings line. This can be useful for writing scripts. The following example uses the --noheadings argument in combination with the pv_name argument, which will generate a list of all physical volumes.
  • Page 53: Object Selection

    Object Selection # vgs -o +pv_name #PV #LV #SN Attr VSize VFree new_vg 0 wz--n- 51.42G 51.37G /dev/sdc1 new_vg 0 wz--n- 51.42G 51.37G /dev/sdd1 new_vg 0 wz--n- 51.42G 51.37G /dev/sdb1 4.9.2. Object Selection This section provides a series of tables that list the information you can display about the LVM objects with the pvs, vgs, and lvs commands.
  • Page 54 Chapter 4. LVM Administration with CLI Commands The pvs command displays the following fields by default: pv_name, vg_name, pv_fmt, pv_attr, pv_size, pv_free. The display is sorted by pv_name. # pvs 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...
  • Page 55 Object Selection /dev/sdg1 lvm2 a- 17.14G 17.14G 4389 You can use the pvs -a command to see devices detected by LVM that have not been initialized as LVM physical volumes. # pvs -a Attr PSize PFree /dev/VolGroup00/LogVol01 /dev/new_vg/lvol0 /dev/ram /dev/ram0 /dev/ram2 /dev/ram3 /dev/ram4...
  • Page 56 Chapter 4. LVM Administration with CLI Commands Argument Header Description Number representing the revision of the volume group vg_seqno VSize The size of the volume group vg_size SYS ID LVM1 System ID vg_sysid VG Tags LVM tags attached to the volume group vg_tags VG UUID The UUID of the volume group...
  • Page 57 Object Selection Argument Header Description against allocation changes, for example while executing the pvmove command. Bit 4: fixed (m)inor Bit 5 State: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present without tables, mapped device present with (i)nactive table Bit 6: device (o)pen KMaj Actual major device number of the logical volume (-1 if inactive)
  • Page 58 Chapter 4. LVM Administration with CLI Commands 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 -v argauament with the lvs command adds the following fields to the default display: seg_count, lv_major, lv_minor, lv_kernel_major, lv_kernel_minor, lv_uuid.
  • Page 59: Sorting Lvm Reports

    Sorting LVM Reports 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 4.9.3. Sorting LVM Reports Normally the entire output of the lvs, vgs, or pvs command has to be generated and stored internally before it can be sorted and columns aligned correctly.
  • Page 60: Specifying Units

    Chapter 4. LVM Administration with CLI Commands /dev/sdc1 17.14G 17.09G 4.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.
  • Page 61 Specifying Units /dev/sdd1 new_vg lvm2 a- 35946496S 35946496S The following example displays the output of the pvs command in units of 4 megabytes. # pvs --units 4m Attr PSize PFree /dev/sdb1 new_vg lvm2 a- 4388.00U 4388.00U /dev/sdc1 new_vg lvm2 a- 4388.00U 4375.00U /dev/sdd1 new_vg lvm2 a-...
  • Page 63: Lvm Configuration Examples

    Chapter 5. LVM Configuration Examples This chapter provides some basic LVM configuration examples. 5.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. 5.1.1.
  • Page 64: Creating The File System

    Chapter 5. LVM Configuration Examples 5.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. Are you sure you want to proceed? [y/n] y Device: /dev/new_vol_group/new_logical_volume Blocksize:...
  • Page 65: Creating The Volume Group

    Creating the Volume Group Physical volume "/dev/sdc1" successfully created 5.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 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 #PV #LV #SN Attr VSize...
  • Page 66: Splitting A Volume Group

    Chapter 5. LVM Configuration Examples 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 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 13902624 1656776 11528232 13% /...
  • Page 67: Splitting The Volume Group

    Splitting the Volume Group /dev/sdc1: Moved: 76.6% /dev/sdc1: Moved: 92.2% /dev/sdc1: Moved: 100.0% After moving the data, you can see that all of the space on /dev/sdc1 is free. [root@tng3-1 ~]# pvscan PV /dev/sda1 VG myvg lvm2 [17.15 GB / 0 free] PV /dev/sdb1 VG myvg...
  • Page 68: Activating And Mounting The Original Logical Volume

    Chapter 5. LVM Configuration Examples [root@tng3-1 ~]# gfs_mkfs -plock_nolock -j 1 /dev/yourvg/yourlv This will destroy any data on /dev/yourvg/yourlv. Are you sure you want to proceed? [y/n] y Device: /dev/yourvg/yourlv Blocksize: 4096 Filesystem Size: 1277816 Journals: Resource Groups: Locking Protocol: lock_nolock Lock Table: Syncing...
  • Page 69: Moving Extents To A New Disk

    Moving Extents to a New Disk /dev/sdc1 myvg lvm2 a- 17.15G 12.15G 5.00G /dev/sdd1 myvg lvm2 a- 17.15G 2.15G 15.00G We want to move the extents off of /dev/sdb1 so that we can remove it from the volume group. If there are enough free extents on the other physical volumes in the volume group, you can execute the pvmove command on the device you want to remove with no other options and the extents will be distributed to the other devices.
  • Page 70 Chapter 5. LVM Configuration Examples /dev/sdb1 myvg lvm2 a- 17.15G 15.15G 2.00G /dev/sdc1 myvg lvm2 a- 17.15G 15.15G 2.00G We want to move the extents of /dev/sdb1 to a new device, /dev/sdd1. 5.4.2.1. Creating the New Physical Volume Create a new physical volume from /dev/sdd1. [root@tng3-1 ~]# pvcreate /dev/sdd1 Physical volume "/dev/sdd1"...
  • Page 71 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.
  • Page 73: Lvm Troubleshooting

    Chapter 6. LVM Troubleshooting This chapter provide instructions for troubleshooting a variety of LVM issues. 6.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.
  • Page 74: Recovering From Lvm Mirror Failure

    Chapter 6. LVM Troubleshooting [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. Attr LSize Origin Snap%...
  • Page 75 Recovering from LVM Mirror Failure The following command creates the physical volumes which will be used for the mirror. [root@link-08 ~]# pvcreate /dev/sd[abcdefgh][12] Physical volume "/dev/sda1" successfully created Physical volume "/dev/sda2" successfully created Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdb2" successfully created Physical volume "/dev/sdc1"...
  • Page 76 Chapter 6. LVM Troubleshooting 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) In this example, the primary leg of the mirror /dev/sda1 fails. Any write activity to the mirrored volume causes LVM to detect the failed mirror.
  • Page 77 Recovering from LVM Mirror Failure PV /dev/sdg1 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdg2 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdh1 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdh2 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sda1...
  • Page 78: Recovering Physical Volume Metadata

    Chapter 6. LVM Troubleshooting [groupfs_mimage_1] vg iwi-ao 752.00M /dev/sda1(0) [groupfs_mlog] lwi-ao 4.00M /dev/sdc1(0) 6.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 79: Replacing A Missing Physical Volume

    Replacing a Missing Physical Volume physical volume label with the metadata information contained in VG_00050.vg, the most recent good archived metatdata for volume group . The restorefile argument instructs the pvcreate command to make the new physical volume compatible with the old one on the volume group, ensuring that the the new metadata will not be placed where the old physical volume contained data (which could happen, for example, if the original pvcreate command had used the command line arguments that control metadata placement, or it the physical volume was originally created using a...
  • Page 80: Removing Lost Physical Volumes From A Volume Group

    Chapter 6. LVM Troubleshooting Section 6.4, “Recovering Physical you would for recovering physical volume metadata, described in Volume Metadata”. You can use the --partial and --verbose arguments of the vgdisplay command to display the UUIDs and sizes of any physical volumes that are no longer present. If you wish to substitute another physical volume of the same size, you can use the pvcreate command with the --restorefile and --uuid arguments to initialize a new device with the same UUID as the missing physical volume.
  • Page 81 Insufficient Free Extents for a Logical Volume # lvcreate -l8780 -n testlv testvg This uses all the free extents in the volume group. # vgs -o +vg_free_count,vg_extent_count #PV #LV #SN Attr VSize VFree Free #Ext testvg 0 wz--n- 34.30G 0 8780 Alternately, you can extend the logical volume to use a percentage of the remaining free space in the volume group by using the -l argument of the lvcreate command.
  • Page 83: Lvm Administration With The Lvm Gui

    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.
  • Page 85: 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 87: The Lvm Configuration Files

    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.
  • Page 88 Appendix B. The LVM Configuration Files # 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.
  • Page 89 Sample lvm.conf File # Exclude the cdrom drive # filter = [ "r|/dev/cdrom|" ] # 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|.*|"...
  • Page 90 Appendix B. The LVM Configuration Files # Should we log error and debug messages to a file? # By default there is no log file. #file = "/var/log/lvm2.log" # Should we overwrite the log file each time the program is run? # By default we append.
  • Page 91 Sample lvm.conf File # 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.
  • Page 92 Appendix B. The LVM Configuration Files # If we can't communicate with device-mapper, should we try running # the LVM1 tools? # This option only applies to 2.4 kernels and is provided to help you # switch between device-mapper kernels and LVM1 kernels. # The LVM1 tools need to be installed with .lvm1 suffices # e.g.
  • Page 93 Sample lvm.conf File # Other entries can go here to allow you to load shared libraries # e.g. if support for LVM1 metadata was compiled as a shared library format_libraries = "liblvm2format1.so" # Full pathnames can be given. # Search this directory first for shared libraries. library_dir = "/lib"...
  • Page 94 Appendix B. The LVM Configuration Files # determine what happens: # "remove" - Simply remove the faulty device and run without it. the log device fails, the mirror would convert to using an in-memory log. This means the mirror will not remember its sync status across crashes/reboots and the entire mirror will be re-synced.
  • Page 95 Sample lvm.conf File # when running pvcreate on new PVs which are to be added to large VGs. # pvmetadatacopies = 1 # Approximate default size of on-disk metadata areas in sectors. # You should increase this if you have large volume groups or # you want to retain a large on-disk history of your metadata changes.
  • Page 97: 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 98: Controlling Activation With Tags

    Appendix C. LVM Object Tags C.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.
  • Page 99: 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.
  • Page 100: Sample Metadata

    Appendix D. LVM Volume Group Metadata • Name and unique id • A version number which is incremented whenever the metadata gets updated • Any properties: Read/Write? Resizeable? • Any administrative limit on the number of physical volumes and logical volumes it may contain •...
  • Page 101 Sample Metadata device = "/dev/sda" # Hint only status = ["ALLOCATABLE"] dev_size = 35964301 # 17.1491 Gigabytes pe_start = 384 pe_count = 4390 # 17.1484 Gigabytes pv1 { id = "ZHEZJW-MR64-D3QM-Rv7V-Hxsa-zU24-wztY19" device = "/dev/sdb" # Hint only status = ["ALLOCATABLE"] dev_size = 35964301 # 17.1491 Gigabytes pe_start = 384...
  • Page 102 Appendix D. LVM Volume Group Metadata stripes = [ "pv0", 0 segment2 { start_extent = 1280 extent_count = 1280 # 5 Gigabytes type = "striped" stripe_count = 1 # linear stripes = [ "pv1", 0...
  • Page 103: Revision History

    Appendix E. Revision History Revision History Revision 1.0...
  • Page 105: Index

    Index persistent, 30 device path names, 15 device scan filters, 36 device size, maximum, 21 device special file directory, 20 activating logical volumes display individual nodes, 38 sorting output, 47 activating volume groups, 23 displaying individual nodes, 23 logical volumes, 32, 44 local node only, 23 physical volumes, 18, 41 administrative procedures, 13...
  • Page 106 Index exclusive access, 38 definition, 10 extending, 32 failure recovery, 62 growing, 32 reconfiguration, 30 linear, 26 local access, 38 lvs display arguments, 44 online data relocation, 37 mirrored, 28 reducing, 35 removing, 31 partition type, setting, 17 renaming, 31 partitions resizing, 30 multiple, 6...
  • Page 107 moving between systems, 25 reducing, 22 scanning removing, 24 block devices, 17 renaming, 25 scanning devices, filters, 36 shrinking, 22 snapshot logical volume splitting, 24 creation, 35 example procedure, 54 snapshot volume vgs display arguments, 43 definition, 10 striped logical volume creation, 28 creation example, 52 definition, 8...

This manual is also suitable for:

Enterprise linux 5.1 cluster logical volume manager

Table of Contents