Logical Volume Red Hat Enterprise Linux 6 Manager .

Transcription

Red Hat Enterprise Linux 6Logical VolumeManager AdministrationLVM Administrator Guide

Logical Volume Manager AdministrationRed Hat Enterprise Linux 6 Logical Volume ManagerAdministrationLVM Administrator GuideEdition 1Copyright 2010 Red Hat Inc.The text of and illustrations in this document are licensed by Red Hat under a Creative CommonsAttribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is availableat http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute thisdocument or an adaptation of it, you must provide the URL for the original version.Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert,Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the InfinityLogo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.Linux is the registered trademark of Linus Torvalds in the United States and other countries.Java is a registered trademark of Oracle and/or its affiliates.XFS is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United Statesand/or other countries.MySQL is a registered trademark of MySQL AB in the United States, the European Union and othercountries.All other trademarks are the property of their respective owners.1801 Varsity DriveRaleigh, NC 27606-2072 USAPhone: 1 919 754 3700Phone: 888 733 4281Fax: 1 919 754 3701This book describes the LVM logical volume manager, including information on running LVM in aclustered environment.

Introductionvii1. About This Guide . vii2. Audience . vii3. Software Versions . vii4. Related Documentation . vii5. We Need Feedback! . viii6. Document Conventions . viii6.1. Typographic Conventions . viii6.2. Pull-quote Conventions . x6.3. Notes and Warnings . x1. The LVM Logical Volume Manager1.1. New and Changed Features .1.2. Logical Volumes .1.3. LVM Architecture Overview .1.4. The Clustered Logical Volume Manager (CLVM) .1.5. Document Overview .1122352. LVM Components72.1. Physical Volumes . 72.1.1. LVM Physical Volume Layout . 72.1.2. Multiple Partitions on a Disk . 82.2. Volume Groups . 82.3. LVM Logical Volumes . 92.3.1. Linear Volumes . 92.3.2. Striped Logical Volumes . 102.3.3. Mirrored Logical Volumes . 112.3.4. Snapshot Volumes . 123. LVM Administration Overview3.1. Creating LVM Volumes in a Cluster .3.2. Logical Volume Creation Overview .3.3. Growing a File System on a Logical Volume .3.4. Logical Volume Backup .3.5. Logging .1515151616174. LVM Administration with CLI Commands4.1. Using CLI Commands .4.2. Physical Volume Administration .4.2.1. Creating Physical Volumes .4.2.2. Displaying Physical Volumes .4.2.3. Preventing Allocation on a Physical Volume .4.2.4. Resizing a Physical Volume .4.2.5. Removing Physical Volumes .4.3. Volume Group Administration .4.3.1. Creating Volume Groups .4.3.2. Creating Volume Groups in a Cluster .4.3.3. Adding Physical Volumes to a Volume Group .4.3.4. Displaying Volume Groups .4.3.5. Scanning Disks for Volume Groups to Build the Cache File .4.3.6. Removing Physical Volumes from a Volume Group .4.3.7. Changing the Parameters of a Volume Group .4.3.8. Activating and Deactivating Volume Groups .4.3.9. Removing Volume Groups .4.3.10. Splitting a Volume Group .4.3.11. Combining Volume Groups .1919202022222323232324252525262727272728iii

Logical Volume Manager Administration4.3.12. Backing Up Volume Group Metadata .4.3.13. Renaming a Volume Group .4.3.14. Moving a Volume Group to Another System .4.3.15. Recreating a Volume Group Directory .Logical Volume Administration .4.4.1. Creating Linear Logical Volumes .4.4.2. Creating Striped Volumes .4.4.3. Creating Mirrored Volumes .4.4.4. Creating Snapshot Volumes .4.4.5. Merging Snapshot Volumes .4.4.6. Persistent Device Numbers .4.4.7. Resizing Logical Volumes .4.4.8. Changing the Parameters of a Logical Volume Group .4.4.9. Renaming Logical Volumes .4.4.10. Removing Logical Volumes .4.4.11. Displaying Logical Volumes .4.4.12. Growing Logical Volumes .4.4.13. Extending a Striped Volume .4.4.14. Shrinking Logical Volumes .Controlling LVM Device Scans with Filters .Online Data Relocation .Activating Logical Volumes on Individual Nodes in a Cluster .Customized Reporting for LVM .4.8.1. Format Control .4.8.2. Object Selection .4.8.3. Sorting LVM Reports .4.8.4. Specifying Units 551515. LVM Configuration Examples5.1. Creating an LVM Logical Volume on Three Disks .5.1.1. Creating the Physical Volumes .5.1.2. Creating the Volume Group .5.1.3. Creating the Logical Volume .5.1.4. Creating the File System .5.2. Creating a Striped Logical Volume .5.2.1. Creating the Physical Volumes .5.2.2. Creating the Volume Group .5.2.3. Creating the Logical Volume .5.2.4. Creating the File System .5.3. Splitting a Volume Group .5.3.1. Determining Free Space .5.3.2. Moving the Data .5.3.3. Splitting the Volume Group .5.3.4. Creating the New Logical Volume .5.3.5. Making a File System and Mounting the New Logical Volume .5.3.6. Activating and Mounting the Original Logical Volume .5.4. Removing a Disk from a Logical Volume .5.4.1. Moving Extents to Existing Physical Volumes .5.4.2. Moving Extents to a New Disk .5.5. Creating a Mirrored LVM Logical Volume in a Cluster .535353535353545454555555565656575757575758596. LVM Troubleshooting6.1. Troubleshooting Diagnostics .6.2. Displaying Information on Failed Devices .6.3. Recovering from LVM Mirror Failure .636363644.4.4.5.4.6.4.7.4.8.iv

6.4.6.5.6.6.6.7.Recovering Physical Volume Metadata .Replacing a Missing Physical Volume .Removing Lost Physical Volumes from a Volume Group .Insufficient Free Extents for a Logical Volume .676868697. LVM Administration with the LVM GUI71A. The Device MapperA.1. Device Table Mappings .A.1.1. The linear Mapping Target .A.1.2. The striped Mapping Target .A.1.3. The mirror Mapping Target .A.1.4. The snapshot and snapshot-origin Mapping Targets .A.1.5. The error Mapping Target .A.1.6. The zero Mapping Target .A.1.7. The multipath Mapping Target .A.1.8. The crypt Mapping Target .A.2. The dmsetup Command .A.2.1. The dmsetup info Command .A.2.2. The dmsetup ls Command .A.2.3. The dmsetup status Command .A.2.4. The dmsetup deps Command .A.3. Device Mapper Support for the udev Device Manager .A.3.1. udev Integration with the Device Mapper .A.3.2. Commands and Interfaces that Support udev .737374747677797980828383848585858687B. The LVM Configuration Files89B.1. The LVM Configuration Files . 89B.2. Sample lvm.conf File . 89C. LVM Object TagsC.1. Adding and Removing Object Tags .C.2. Host Tags .C.3. Controlling Activation with Tags .97979797D. LVM Volume Group Metadata99D.1. The Physical Volume Label . 99D.2. Metadata Contents . 99D.3. Sample Metadata . 100E. Revision History103Index105v

vi

Introduction1. About This GuideThis book describes the Logical Volume Manager (LVM), including information on running LVM in aclustered environment.2. AudienceThis book is intended to be used by system administrators managing systems running the Linuxoperating system. It requires familiarity with Red Hat Enterprise Linux 6 and GFS2 file systemadministration.3. Software VersionsTable 1. Software VersionsSoftwareDescriptionRHEL 6refers to RHEL 6 and higherGFS2refers to GFS2 for RHEL 6 and higher4. Related DocumentationFor more information about using Red Hat Enterprise Linux, refer to the following resources: Installation Guide — Documents relevant information regarding the installation of Red HatEnterprise Linux 6. Deployment Guide — Documents relevant information regarding the deployment, configuration andadministration of Red Hat Enterprise Linux 6. Storage Administration Guide — Provides instructions on how to effectively manage storage devicesand file systems on Red Hat Enterprise Linux 6.For more information about the High-Availabilty Add-On and the Resilient Storage Add-On for Red HatEnterprise Linux 6, refer to the following resources: Red Hat Cluster Suite Overview — Provides a high level overview of the High Availability Add-On,Resilient Storage Add-On, and the Load Balancer Add-On. Configuring and Managing a Red Hat Cluster — Provides information about installing, configuringand managing the High Availability Add-On. Global File System 2: Configuration and Administration — Provides information about installing,configuring, and maintaining Red Hat GFS2 (Red Hat Global File System 2), which is included in theResilient Storage Add-On. DM Multipath — Provides information about using the Device-Mapper Multipath feature of Red HatEnterprise Linux 6. Linux Virtual Server Administration — Provides information on configuring high-performancesystems and services with the Red Hat Load Balancer Add-On (Formerly known as Linux VirtualServer [LVS]),vii

Introduction Release Notes — Provides information about the current release of Red Hat products.High Availability Add-On documentation and other Red Hat documents are available in HTML,PDF, and RPM versions on the Red Hat Enterprise Linux Documentation CD and online at http://www.redhat.com/docs/.5. We Need Feedback!If you find a typographical error in this manual, or if you have thought of a way to make thismanual better, we would love to hear from you! Please submit a report in Bugzilla: http://bugzilla.redhat.com/ against the product Red Hat Enterprise Linux 6 and the component docLogical Volume Manager. When submitting a bug report, be sure to mention the manual's identifier:Logical Volume Manager Administration(EN)-6 (2010-10-14T15:20).If you have a suggestion for improving the documentation, try to be as specific as possible whendescribing it. If you have found an error, please include the section number and some of thesurrounding text so we can find it easily.6. Document ConventionsThis manual uses several conventions to highlight certain words and phrases and draw attention tospecific pieces of information.1In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts set. TheLiberation Fonts set is also used in HTML editions if the set is installed on your system. If not,alternative but equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later includesthe Liberation Fonts set by default.6.1. Typographic ConventionsFour typographic conventions are used to call attention to specific words and phrases. Theseconventions, and the circumstances they apply to, are as follows.Mono-spaced BoldUsed to highlight system input, including shell commands, file names and paths. Also used to highlightkeycaps and key combinations. For example:To see the contents of the file my next bestselling novel in your currentworking directory, enter the cat my next bestselling novel command at theshell prompt and press Enter to execute the command.The above includes a file name, a shell command and a keycap, all presented in mono-spaced boldand all distinguishable thanks to context.Key combinations can be distinguished from keycaps by the hyphen connecting each part of a keycombination. For example:Press Enter to execute the command.Press Ctrl Alt F2 to switch to the first virtual terminal. Press Ctrl Alt F1 toreturn to your X-Windows /viii

Typographic ConventionsThe first paragraph highlights the particular keycap to press. The second highlights two keycombinations (each a set of three keycaps with each set pressed simultaneously).If source code is discussed, class names, methods, functions, variable names and returned valuesmentioned within a paragraph will be presented as above, in mono-spaced bold. For example:File-related classes include filesystem for file systems, file for files, and dir fordirectories. Each class has its own associated set of permissions.Proportional BoldThis denotes words or phrases encountered on a system, including application names; dialog box text;labeled buttons; check-box and radio button labels; menu titles and sub-menu titles. For example:Choose System Preferences Mouse from the main menu bar to launch MousePreferences. In the Buttons tab, click the Left-handed mouse check box and clickClose to switch the primary mouse button from the left to the right (making the mousesuitable for use in the left hand).To insert a special character into a gedit file, choose Applications Accessories Character Map from the main menu bar. Next, choose Search Find from theCharacter Map menu bar, type the name of the character in the Search field and clickNext. The character you sought will be highlighted in the Character Table. Doubleclick this highlighted character to place it in the Text to copy field and then click theCopy button. Now switch back to your document and choose Edit Paste from thegedit menu bar.The above text includes application names; system-wide menu names and items; application-specificmenu names; and buttons and text found within a GUI interface, all presented in proportional bold andall distinguishable by context.Mono-spaced Bold Italic or Proportional Bold ItalicWhether mono-spaced bold or proportional bold, the addition of italics indicates replaceable orvariable text. Italics denotes text you do not input literally or displayed text that changes depending oncircumstance. For example:To connect to a remote machine using ssh, type ssh username@domain.name ata shell prompt. If the remote machine is example.com and your username on thatmachine is john, type ssh john@example.com.The mount -o remount file-system command remounts the named filesystem. For example, to remount the /home file system, the command is mount -oremount /home.To see the version of a currently installed package, use the rpm -q packagecommand. It will return a result as follows: package-version-release.Note the words in bold italics above — username, domain.name, file-system, package, version andrelease. Each word is a placeholder, either for text you enter when issuing a command or for textdisplayed by the system.Aside from standard usage for presenting the title of a work, italics denotes the first use of a new andimportant term. For example:Publican is a DocBook publishing system.ix

Introduction6.2. Pull-quote ConventionsTerminal output and source code listings are set off visually from the surrounding text.Output sent to a terminal is set in mono-spaced roman and presented thus:booksbooks agesmssnotesphotosscriptsstuffsvgssvnSource-code listings are also set in mono-spaced roman but add syntax highlighting as follows:package org.jboss.book.jca.ex1;import javax.naming.InitialContext;public class ExClient{public static void main(String args[])throws Exception{InitialContext iniCtx new InitialContext();Objectref iniCtx.lookup("EchoBean");EchoHomehome (EchoHome) ref;Echoecho home.create();System.out.println("Created Echo");System.out.println("Echo.echo('Hello') " echo.echo("Hello"));}}6.3. Notes and WarningsFinally, we use three visual styles to draw attention to information that might otherwise be overlooked.NoteNotes are tips, shortcuts or alternative approaches to the task at hand. Ignoring a note shouldhave no negative consequences, but you might miss out on a trick that makes your life easier.ImportantImportant boxes detail things that are easily missed: configuration changes that only apply tothe current session, or services that need restarting before an update will apply. Ignoring a boxlabeled 'Important' will not cause data loss but may cause irritation and frustration.WarningWarnings should not be ignored. Ignoring warnings will most likely cause data loss.x

Chapter 1.The LVM Logical Volume ManagerThis chapter provides a summary of the features of the LVM logical volume manager that are newfor the initial release of Red Hat Enterprise Linux 6. Following that, this chapter provides a high-leveloverview of the components of the Logical Volume Manager (LVM).1.1. New and Changed FeaturesThis section lists new and changed features of the LVM logical volume manager that are included withthe initial release of Red Hat Enterprise Linux 6. You can define how a mirrored logical volume behaves in the event of a device failure withthe mirror image fault policy and mirror log fault policy parameters in theactivation section of the lvm.conf file. When this parameter is set to remove, the systemattempts to remove the faulty device and run without it. When this parameter is set to allocate,the system attempts to remove the faulty device and tries to allocate space on a new device to bea replacement for the failed device; this policy acts like the remove policy if no suitable device andspace can be allocated for the replacement. For information on the LVM mirror failure policies, seeSection 4.4.3.1, “Mirrored Logical Volume Failure Policy”. For the Red Hat Enterprise Linux 6 release, the Linux I/O stack has been enhanced to processvendor-provided I/O limit information. This allows storage management tools, including LVM, tooptimize data placement and access. This support can be disabled by changing the default valuesof data alignment detection and data alignment offset detection in the lvm.conffile, although disabling this support is not recommended.For information on data alignment in LVM as well as information on changing the default valuesof data alignment detection and data alignment offset detection, see the inlinedocumentation for the /etc/lvm/lvm.conf file, which is also documented in Appendix B, TheLVM Configuration Files. For general information on support for the I/O Stack and I/O limits in RedHat Enterprise Linux 6, see the Storage Administration Guide. In Red Hat Enterprise Linux 6, the Device Mapper provides direct support for udev integration.This synchronizes the Device Mapper with all udev processing related to Device Mapper devices,including LVM devices. For information on Device Mapper support for the udev device manager,see Section A.3, “Device Mapper Support for the udev Device Manager”. For the Red Hat Enterprise Linux 6 release, you can use the lvconvert --repair command torepair a mirror after disk failure. This brings the mirror back into a consistent state. For informationon the lvconvert --repair command, see Section 4.4.3.3, “Repairing a Mirrored LogicalDevice”. As of the Red Hat Enterprise Linux 6 release, you can use the --merge option of the lvconvertcommand to merge a snapshot into its origin volume. For information on merging snapshots, seeSection 4.4.5, “Merging Snapshot Volumes”. As of the Red Hat Enterprise Linux 6 release, you can use the --splitmirrors argument of thelvconvert command to split off a redundant image of a mirrored logical volume to form a newlogical volume. For information on using this option, see Section 4.4.3.2, “Splitting Off a RedundantImage of a Mirrored Logical Volume”. You can now create a mirror log for a mirrored logical device that is itself mirrored by using the -mirrorlog mirrored argument of the lvcreate command when creating a mirrored logicaldevice. For information on using this option, see Section 4.4.3, “Creating Mirrored Volumes”.1

Chapter 1. The LVM Logical Volume Manager1.2. Logical VolumesVolume management creates a layer of abstraction over physical storage, allowing you to createlogical storage volumes. This provides much greater flexibility in a number of ways than using physicalstorage directly. With a logical volume, you are not restricted to physical disk sizes. In addition, thehardware storage configuration is hidden from the software so it can be resized and moved withoutstopping applications or unmounting file systems. This can reduce operational costs.Logical volumes provide the following advantages over using physical storage directly: Flexible capacityWhen using logical volumes, file systems can extend across multiple disks, since you can aggregatedisks and partitions into a single logical volume. Resizeable storage poolsYou can extend logical volumes or reduce logical volumes in size

RHEL 6 refers to RHEL 6 and higher GFS2 refers to GFS2 for RHEL 6 and higher 4. Related Documentation For more information about using Red Hat Enterprise Linux, refer to the following resources: Installation Guide — Documents relevant information regarding the installation of Red Hat Enterprise Linux 6