LVM HOWTO

AJ Lewis


          
        

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, either expressed or implied. While every effort has been taken to ensure the accuracy of the information documented herein, the author(s)/editor(s)/maintainer(s)/contributor(s) assumes NO RESPONSIBILITY for any errors, or for any damages, direct or consequential, as a result of the use of the information documented herein.

Revision History
Revision 0.192006-11-27ajl
Clarified full snapshot conditions in Section 8, “Snapshots” and Section 4.1, “Create the snapshot volume” and added a note about resizing the origin of a snapshot; Fixed Rackable copyright; Fixed e-mail address
Revision 0.182006-11-27ajl
Clarify whole disk usage in Section 1, “Initializing disks or disk partitions”; Updated copyright; Updated e-mail address
Revision 0.172005-10-03ajl
Added FAQ entry for max size of LVs in LVM2; Did some cleanup of "Recover physical volume metadata" section; Updated e-mail address
Revision 0.162005-07-15ajl
Added lvm2 boot-time scripts info; Added "Recover physical volume metadata" section - thanks to Maximilian Attems for the patch
Revision 0.152005-06-09ajl
Removed references to xfs_freeze - it is no longer needed; Updated snapshots subsection in Anatomy of LVM section; Added a couple entries to the LVM2 FAQ; Fixed a couple typos
Revision 0.142004-10-06ajl
Added reference to lvm2_createinitrd in source tree; Adjusted lvcreate example slightly; Added 'vgchange -ay' in 'Moving a volume group to another system' recipe
Revision 0.132004-08-16ajl
Clarify symlink farm description; Fix dm control device major number; Remove /boot from vg in small lvm setup example; Add notes about /boot and / on LVM; Remove outdated link;
Revision 0.122004-06-07ajl
Updated LVM2 FAQ entries
Revision 0.112004-05-03ajl
Updated LVM2 FAQ entries
Revision 0.102004-04-22ajl
removed -print0 from find command after receiving reports that it doesn't work
Revision 0.92004-04-16ajl
Added -print0 to find command before piping it to cpio; Changed vgimport command line for LVM 2; Added ext3 to the ext2 resize section; Updated FAQ; Updated Links section
Revision 0.82004-02-25ajl
Updated CVS locations and FTP links; Added section on extending a JFS filesystem; Fixed typos - Ran aspell against document
Revision 0.72004-02-16ajl
Updated to include LVM 2 and device mapper information; Updated email addresses; Updated copyright; Added FAQ section; Added document license; Updated to docbook 4.2
Revision 0.62003-12-09ajl
Updated for LVM 1.0.8; fixed broken link; Clarified redhat init script section;
Revision 0.52003-02-10ajl
Updated Redhat initscript information for 7.0 and above; Added information on removing a partition table from a disk if pvcreate fails; Default PE size is 32MB now; Updated method for snapshotting under XFS.
Revision 0.42002-12-16ajl
Updated for LVM 1.0.6
Revision 0.32002-09-16ajl
removed example pvmove from Command Operations section - we now just point to the more detailed recipe on pvmove that contains various warnings and such
Revision 0.22002-09-11ajl
Updated for LVM 1.0.5 and converted to DocBook XML 4.1.2.
Revision 0.12002-04-28gf
Initial conversion from Sistina's LaTeX source and import to tLDP in LinuxDoc format.

Abstract

This document describes how to build, install, and configure LVM for Linux. A basic description of LVM is also included. This version of the HowTo is for LVM 2 with device-mapper, as well as LVM 1.0.8.


Table of Contents

Introduction
1. Latest Version
2. Disclaimer
3. Contributors
1. What is LVM?
2. What is Logical Volume Management?
1. Why would I want it?
2. Benefits of Logical Volume Management on a Small System
3. Benefits of Logical Volume Management on a Large System
3. Anatomy of LVM
1. volume group (VG)
2. physical volume (PV)
3. logical volume (LV)
4. physical extent (PE)
5. logical extent (LE)
6. Tying it all together
7. mapping modes (linear/striped)
8. Snapshots
4. Frequently Asked Questions
1. LVM 2 FAQ
2. LVM 1 FAQ
5. Acquiring LVM
1. Download the source
2. Download the development source via CVS
3. Before You Begin
4. Initial Setup
5. Checking Out Source Code
6. Code Updates
7. Starting a Project
8. Hacking the Code
9. Conflicts
6. Building the kernel modules
1. Building the device-mapper module
2. Build the LVM 1 kernel module
2.1. Building a patch for your kernel
2.2. Building the LVM module for Linux 2.2.17+
2.3. Building the LVM modules for Linux 2.4
2.4. Checking the proc file system
7. LVM 1 Boot time scripts
1. Caldera
2. Debian
3. Mandrake
4. Redhat
5. Slackware
6. SuSE
8. LVM 2 Boot Time Scripts
9. Building LVM from the Source
1. Make LVM library and tools
2. Install LVM library and tools
3. Removing LVM library and tools
10. Transitioning from previous versions of LVM to LVM 1.0.8
1. Upgrading to LVM 1.0.8 with a non-LVM root partition
2. Upgrading to LVM 1.0.8 with an LVM root partition and initrd
11. Common Tasks
1. Initializing disks or disk partitions
2. Creating a volume group
3. Activating a volume group
4. Removing a volume group
5. Adding physical volumes to a volume group
6. Removing physical volumes from a volume group
7. Creating a logical volume
8. Removing a logical volume
9. Extending a logical volume
10. Reducing a logical volume
11. Migrating data off of a physical volume
12. Disk partitioning
1. Multiple partitions on the same disk
2. Sun disk labels
13. Recipes
1. Setting up LVM on three SCSI disks
1.1. Preparing the disks
1.2. Setup a Volume Group
1.3. Creating the Logical Volume
1.4. Create the File System
1.5. Test the File System
2. Setting up LVM on three SCSI disks with striping
2.1. Preparing the disk partitions
2.2. Setup a Volume Group
2.3. Creating the Logical Volume
2.4. Create the File System
2.5. Test the File System
3. Add a new disk to a multi-disk SCSI system
3.1. Current situation
3.2. Prepare the disk partitions
3.3. Add the new disks to the volume groups
3.4. Extend the file systems
3.5. Remount the extended volumes
4. Taking a Backup Using Snapshots
4.1. Create the snapshot volume
4.2. Mount the snapshot volume
4.3. Do the backup
4.4. Remove the snapshot
5. Removing an Old Disk
5.1. Distributing Old Extents to Existing Disks in Volume Group
5.2. Distributing Old Extents to a New Replacement Disk
6. Moving a volume group to another system
6.1. Unmount the file system
6.2. Mark the volume group inactive
6.3. Export the volume group
6.4. Import the volume group
6.5. Activate the volume group
6.6. Mount the file system
7. Splitting a volume group
7.1. Determine free space
7.2. Move data off the disks to be used
7.3. Create the new volume group
7.4. Remove remaining volume
7.5. Create new logical volume
7.6. Make a file system on the volume
7.7. Mount the new volume
8. Converting a root filesystem to LVM 1
8.1. Boot single user
8.2. Run Parted
8.3. Reboot
8.4. Verify kernel config options
8.5. Adjust partition type
8.6. Set up LVM 1 for the new scheme
8.7. Create the Filesystem
8.8. Update /etc/fstab
8.9. Create an LVM 1 initial RAM disk
8.10. Update /etc/lilo.conf
8.11. Run LILO to write the new boot sector
8.12. Reboot to lvm
8.13. Add remainder of disk
9. Recover physical volume metadata
A. Dangerous Operations
1. Restoring the VG UUIDs using uuid_fixer
2. Sharing LVM volumes
B. Reporting Errors and Bugs
C. Contact and Links
1. Mail lists
2. Links
D. GNU Free Documentation License
1. PREAMBLE
2. APPLICABILITY AND DEFINITIONS
3. VERBATIM COPYING
4. COPYING IN QUANTITY
5. MODIFICATIONS
6. COMBINING DOCUMENTS
7. COLLECTIONS OF DOCUMENTS
8. AGGREGATION WITH INDEPENDENT WORKS
9. TRANSLATION
10. TERMINATION
11. FUTURE REVISIONS OF THIS LICENSE
12. ADDENDUM: How to use this License for your documents