background image

ignored.

The following command creates a mirrored logical volume with a single mirror. The volume is

500 megabytes in size, it is named

mirrorlv

, and it is carved out of volume group

vg0

. The first

leg of the mirror is on device

/dev/sda1

, the second leg of the mirror is on device

/dev/sdb1

,

and the mirror log is on

/dev/sdc1

.

lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1 /dev/sdb1 /dev/sdc1

The following command creates a mirrored logical volume with a single mirror. The volume is

500 megabytes in size, it is named

mirrorlv

, and it is carved out of volume group

vg0

. The first

leg of the mirror is on extents 0 through 499 of device

/dev/sda1

, the second leg of the mirror is

on extents 0 through 499 of device

/dev/sdb1

, and the mirror log starts on extent 0 of device

/dev/sdc1

. These are 1MB extents. If any of the specified extents have already been allocated,

they will be ignored.

lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1:0-499 /dev/sdb1:0-499

/dev/sdc1:0

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. This means that your volume group must contain the devices and space

for the mirror legs and for the mirror log.

If you lose a leg of a mirror, LVM converts the volume to a linear volume so that you still have

access to the volume, without the mirror redundancy. After you replace the leg, you can use the

lvconvert

command to restore the mirror. This procedure is provided in

Section 3, “Recovering

from LVM Mirror Failure”

.

The following command converts the linear logical volume

vg00/lvol1

to a mirrored logical

volume.

lvconvert -m1 vg00/lvol1

The following command converts the mirrored logical volume

vg00/lvol1

to a linear logical

volume, removing the mirror leg.

lvconvert -m0 vg00/lvol1

Creating Logical Volumes

37

Summary of Contents for GLOBAL FILE SYSTEM 5.0

Page 1: ...LVM Administrator s Guide Configuration and Administration 5 0 ISBN N A Publication date...

Page 2: ...his 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 LVM Administrator s Guide...

Page 3: ...cument is prohibited without the explicit permission of the copyright holder Distribution of the work or derivative of the work in any standard paper book form for commercial purposes is prohibited un...

Page 4: ...LVM Administrator s Guide...

Page 5: ...ume Creation Overview 17 3 Growing a File System on a Logical Volume 18 4 Logical Volume Backup 18 5 Logging 19 4 LVM Administration with CLI Commands 21 1 Using CLI Commands 21 2 Physical Volume Admi...

Page 6: ...ting for LVM 47 9 1 Format Control 47 9 2 Object Selection 49 9 3 Sorting LVM Reports 56 9 4 Specifying Units 57 5 LVM Configuration Examples 59 1 Creating an LVM Logical Volume on Three Disks 59 1 1...

Page 7: ...Group 76 7 Insufficient Free Extents for a Logical Volume 76 7 LVM Administration with the LVM GUI 79 A The Device Mapper 81 B The LVM Configuration Files 83 1 The LVM Configuration Files 83 2 Sample...

Page 8: ...viii...

Page 9: ...Hat Enterprise Linux refer to the following resources Red Hat Enterprise Linux Installation Guide Provides information regarding installation of Red Hat Enterprise Linux 5 Red Hat Enterprise Linux Dep...

Page 10: ...s file names and paths and prompts When shown as below it indicates computer output Desktop about html logs paulwesterberg png Mail backupfiles mail reports bold Courier font Bold Courier font represe...

Page 11: ...tion 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 performanc...

Page 12: ...h version of the guide you have If you have a suggestion for improving the documentation try to be as specific as possible If you have found an error please include the section number and some of the...

Page 13: ...hen using logical volumes file systems can extend across multiple disks since you can aggregate disks and partitions into a single logical volume Resizeable storage pools You can extend logical volume...

Page 14: ...LVM1 with the exception of snapshot and cluster support You can convert a volume group from LVM1 format to LVM2 format with the vgconvert command For information on converting LVM metadata format see...

Page 15: ...ions 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 The clvmd daemon runs in each...

Page 16: ...ric infrastructure Note Shared storage for use in Red Hat Cluster Suite requires that you be running the cluster logical volume manager daemon clvmd or the High Availability Logical Volume Management...

Page 17: ...configure LVM logical volumes whether you are using the LVM Command Line Interface CLI commands or the LVM Graphical User Interface GUI Chapter 4 LVM Administration with CLI Commands summarizes the in...

Page 18: ...6...

Page 19: ...the LVM metadata will be stored on the device The LVM metadata contains the configuration details of the LVM volume groups on your system By default an identical copy of the metadata is maintained in...

Page 20: ...is becomes particularly true if a disk fails In addition multiple physical volumes on a single disk may cause a kernel warning about unknown partition types at boot up Striping performance LVM can not...

Page 21: ...sical extents 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...

Page 22: ...ze 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...

Page 23: ...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...

Page 24: ...a 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...

Page 25: ...9 Extending a Striped Volume 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...

Page 26: ...te 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...

Page 27: ...ee up space that is needed by other logical volumes When you create a snapshot file system full read and write access to the origin stays possible If a chunk on a snapshot is changed that chunk is mar...

Page 28: ...16...

Page 29: ...infrastructure must be running and the cluster must be quorate Note Shared storage for use in Red Hat Cluster Suite requires that you be running the cluster logical volume manager daemon clvmd or the...

Page 30: ...growing to include the new physical volume 3 Extend the logical volume to include the new physical volume 4 Grow the file system If you have sufficient unallocated space in the volume group you can us...

Page 31: ...ging All message output passes through a logging module with independent choices of logging levels for standard output error syslog log file external log function The logging levels are set in the etc...

Page 32: ...20...

Page 33: ...units argument in a command lower case indicates that units are in multiples of 1024 while upper case indicates that units are in multiples of 1000 Where commands take volume group or logical volume n...

Page 34: ...te 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 bas...

Page 35: ...t 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 For whole disk devices only the partition table must be eras...

Page 36: ...hysical volume dev sdd 17 15 GB dev sdd1 17 14 GB LVM physical volume 7 disks 17 partitions 0 LVM physical volume whole disks 4 LVM physical volumes 2 2 Displaying Physical Volumes There are three com...

Page 37: ...information on using filters to control which devices are scanned see Section 6 Controlling LVM Device Scans with Filters 2 3 Preventing Allocation on a Physical Volume You can prevent allocation of p...

Page 38: ...volume to it The following command creates a volume group named vg1 that contains physical volumes dev sdd1 and dev sde1 vgcreate vg1 dev sdd1 dev sde1 When physical volumes are used to create a volum...

Page 39: ...out dev vg lv For example if you create two volume groups myvg1 and myvg2 each with three logical volumes named lvo1 lvo2 and lvo3 this create six device special files dev myvg1 lv01 dev myvg1 lv02 de...

Page 40: ...13164 Alloc PE Size 13 52 00 MB Free PE Size 13151 51 37 GB VG UUID jxQJ0a ZKk0 OpMO 0118 nlwO wwqd fD5D32 3 4 Scanning Disks for Volume Groups to Build the Cache File The vgscan command scans all sup...

Page 41: ...ing 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 hd...

Page 42: ...To deactivate or activate a volume group use the a available argument of the vgchange command The following example deactivates the volume group my_volume_group vgchange a n my_volume_group If cluste...

Page 43: ...nation volume groups limits The following command merges the inactive volume group my_vg into the active or inactive volume group databases giving verbose runtime information vgmerge v databases my_vg...

Page 44: ...prevents any further activity on the volume group 3 Use the vgexport command to export the volume group This prevents it from being accessed by the system from which you are removing it After you expo...

Page 45: ...sed where is the internal number of the logical volume The following sections provide examples of logical volume creation for the three types of logical volumes you can create with LVM 4 1 1 Creating...

Page 46: ...command to find the Total PE size and to use those results as input to the the lvcreate command The following commands create a logical volume called mylv that fills the volume group named testvg vgd...

Page 47: ...the lvcreate command This determines over how many physical volumes the logical volume will be striped The number of stripes cannot be greater than the number of physical volumes in the volume group u...

Page 48: ...t persistent across reboots You can specify instead that this log be kept in memory with the corelog argument this eliminates the need for an extra log device but it requires that the entire mirror be...

Page 49: ...0 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 c...

Page 50: ...contains a file system be sure to reduce the file system first or use the LVM GUI so that the logical volume is always at least as large as the file system expects it to be The following command reduc...

Page 51: ...stvg testlv from the volume group testvg Note that in this case the logical volume has not been deactivated root tng3 1 lvm lvremove dev testvg testlv Do you really want to remove active logical volum...

Page 52: ...ogical volumne dev myvg homevol to 12 gigabytes lvextend L12G dev myvg homevol lvextend extending logical volume dev myvg homevol to 12 GB lvextend doing automatic backup of volume group myvg lvextend...

Page 53: ...way stripe that 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...

Page 54: ...sdd1 Volume group vg successfully extended vgs VG PV LV SN Attr VSize VFree vg 4 1 0 wz n 542 62G 271 31G lvextend vg stripe1 L 542G Using stripesize of last segment 64 00 KB Extending logical volume...

Page 55: ...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 Sectio...

Page 56: ...pshot volume dev new_vg newvgsnap has been created lvs LV VG Attr LSize Origin Snap Move Log Copy lvol0 new_vg owi a 52 00M newvgsnap1 new_vg swi a 8 00M lvol0 0 20 Note Because the snapshot increases...

Page 57: ...following filter adds all discovered devices which is the default behavior as there is no filter configured in the configuration file filter a The following filter removes the cdrom device in order t...

Page 58: ...mand in the background to avoid display of progress updates in the foreground The following command moves all extents allocated to to the physical volume dev sdc1 over to dev sdf1 in the background pv...

Page 59: ...ontrol the format of the generated report A list of the fields you can select for each LVM object A summary of command arguments you can use to sort the generated report Instructions for specifying th...

Page 60: ...PV VG Fmt Attr PSize PFree DevSize PV UUID dev sdb1 new_vg lvm2 a 17 14G 17 14G 17 14G onFF2w 1fLC ughJ D9eB M7iv 6XqA dqGeXY dev sdc1 new_vg lvm2 a 17 14G 17 09G 17 14G Joqlch yWSj kuEn IdwM 01S9 XO...

Page 61: ...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 c...

Page 62: ...physical extents 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_si...

Page 63: ...Size PFree Start SSize dev hda2 VolGroup00 lvm2 a 37 16G 32 00M 0 1172 dev hda2 VolGroup00 lvm2 a 37 16G 32 00M 1172 16 dev hda2 VolGroup00 lvm2 a 37 16G 32 00M 1188 1 dev sda1 vg lvm2 a 17 14G 16 75G...

Page 64: ...he volume group contains vg_attr Attr Status of the volume group w riteable r eadonly resi z eable e x ported p artial and c lustered vg_extent_count Ext The number of physical extents in the volume g...

Page 65: ...ical volume also used when physical extents are being moved with the pv_move command devices Devices The underlying devices that make up the logical volume the physical volumes logical volumes and sta...

Page 66: ...e pvmove command origin Origin The origin device of a snapshot volume regionsize region_size Region The unit size of a mirrored logical volume seg_count Seg The number of segments in the logical volum...

Page 67: ...s by default lv_name vg_name lv_attr stripes segtype seg_size The default display is sorted by vg_name lv_name within the volume group and seg_start within the logical volume If the logical volumes we...

Page 68: ...elds within the output itself The following example shows the output of the pvs command that displays the physical volume name size and free space pvs o pv_name pv_size pv_free PV PSize PFree dev sdb1...

Page 69: ...555 40M 17555 40M dev sdb1 new_vg lvm2 a 17552 00M 17552 00M dev sdc1 new_vg lvm2 a 17552 00M 17500 00M dev sdd1 new_vg lvm2 a 17552 00M 17552 00M By default units are displayed in powers of 2 multipl...

Page 70: ...new_vg lvm2 a 35946496S 35840000S 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 PV VG Fmt Attr PSize PFre...

Page 71: ...dev sda1 successfully created Physical volume dev sdb1 successfully created Physical volume dev sdc1 successfully created 1 2 Creating the Volume Group The following command creates the volume group n...

Page 72: ...roups 8 Locking Protocol lock_nolock Lock Table Syncing All Done The following commands mount the logical volume and report the file system disk space usage root tng3 1 mount dev new_vol_group new_log...

Page 73: ...e 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 Thi...

Page 74: ...xample an existing volume group consists of three physical volumes If there is enough unused space on the physical volumes a new volume group can be created without adding new disks In the initial set...

Page 75: ...ume group yourvg use the vgsplit command to split the volume group myvg Before you can split the volume group the logical volume must be inactive If the file system is mounted you must unmount the fil...

Page 76: ...Filesystem Size 1277816 Journals 1 Resource Groups 20 Locking Protocol lock_nolock Lock Table Syncing All Done root tng3 1 mount dev yourvg yourlv mnt 3 6 Activating and Mounting the Original Logical...

Page 77: ...lumes 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 root tng3 1 pvmove dev sdb1...

Page 78: ...w Physical Volume Create a new physical volume from dev sdd1 root tng3 1 pvcreate dev sdd1 Physical volume dev sdd1 successfully created 4 2 2 Adding the New Physical Volume to the Volume Group Add de...

Page 79: ...g lvm2 a 17 15G 15 15G 2 00G dev sdd1 myvg lvm2 a 17 15G 15 15G 2 00G 4 2 4 Removing the Old Physical Volume from the Volume Group After you have moved the data off dev sdb1 you can remove it from the...

Page 80: ...68...

Page 81: ...command for additional system information Examine the last backup of the metadata in the etc lvm backup file and archived versions in the etc lvm archive file Check the current configuration informat...

Page 82: ...ce 5120 dev sda1 0 The following examples show the output of the pvs and lvs commands with the P argument specified when a leg of a mirrored logical volume has failed root link 08 vgs a o devices P Pa...

Page 83: ...y created Physical volume dev sde2 successfully created Physical volume dev sdf1 successfully created Physical volume dev sdf2 successfully created Physical volume dev sdg1 successfully created Physic...

Page 84: ...device is now a linear device Because of the failed disk I O errors occur root link 08 lvs a o devices dev sda1 read failed after 0 of 2048 at 0 Input output error dev sda2 read failed after 0 of 2048...

Page 85: ...7 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 83 GB...

Page 86: ...shows the sort of output you may see if the metadata area is missing or corrupted root link 07 backup lvs a o devices Couldn t find device with uuid FmGRh3 zhok iVI8 7qTD S5BI MAEN NYM5Sk Couldn t fi...

Page 87: ...version of the software that used different defaults The pvcreate command overwrites only the LVM metadata areas and does not affect the existing data areas root link 07 backup pvcreate uuid FmGRh3 z...

Page 88: ...ical volumes in the volume group with the partial argument of the vgchange command You can remove all the logical volumes that used that physical volume from the volume group with the removemissing ar...

Page 89: ...tents you can run the following command using the lower case l argument to use extents instead of bytes lvcreate l8780 n testlv testvg This uses all the free extents in the volume group vgs o vg_free_...

Page 90: ...78...

Page 91: ...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 th...

Page 92: ...80...

Page 93: ...e activated using the Device Mapper Each logical volume is translated into a mapped device Each segment translates into a line in the mapping table that describes the device The Device Mapper provides...

Page 94: ...82...

Page 95: ...ration file read by the tools etc lvm lvm_hosttag conf For each host tag an extra configuration file is read if it exists lvm_hosttag conf If that file defines new tags then further configuration file...

Page 96: ...prefixed with either an a for accept or r for reject The first expression found to match a device name determines if the device will be accepted or rejected ignored Devices that don t match any patte...

Page 97: ...tions 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 comp...

Page 98: ...kups and archiving In LVM2 when we talk about a backup we mean making a copy of the metadata for the current system The archive contains old metadata configurations Backups are stored in a human reada...

Page 99: ...uld suppress the error messages activation 1 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...

Page 100: ...1 metadata was compiled as a shared library use format_libraries liblvm2format1 so Full pathnames can be given Search this directory first for shared libraries library_dir lib The external locking lib...

Page 101: ...cement for the failed device Using this policy for the log is fast and maintains the ability to remember sync state through crashes reboots Using this policy for a mirror device is slow as it requires...

Page 102: ...eferably 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 The feature was originally added to simplify testing...

Page 103: ...e database tag lvs database 1 Adding and Removing Object Tags To add or delete tags from physical volumes use the addtag or deltag option of the pvchange command To add or delete tags from volume grou...

Page 104: ...in the metadata on that host activation volume_list vg1 lvol0 database There is a special match that causes a match only if any metadata tag matches any host tag on that machine As another example co...

Page 105: ...m If you intend to split the volume group in the future every volume group needs at least one metadata copy The core metadata is stored in ASCII A metadata area is a circular buffer New metadata is ap...

Page 106: ...to determine the block device containing it Any properties such as whether the physical volume is allocatable The offset to the start of the first extent within the physical volume in sectors The numb...

Page 107: ...abytes 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 pe_count...

Page 108: ...E segment_count 2 segment1 start_extent 0 extent_count 1280 5 Gigabytes type striped stripe_count 1 linear stripes pv0 0 segment2 start_extent 1280 extent_count 1280 5 Gigabytes type striped stripe_co...

Page 109: ...60 volume groups 26 creating LVM volumes overview 17 D data relocation online 45 deactivating volume groups 30 exclusive on one node 30 local node only 30 device numbers major 38 minor 38 persistent 3...

Page 110: ...tion 23 physical volume definition 7 volume group definition 9 LVM1 2 LVM2 2 lvmdiskscan command 23 lvreduce command 38 43 lvremove command 39 lvrename command 39 lvs command 47 53 display arguments 5...

Page 111: ...owing 41 T troubleshooting 69 U units command line 21 V verbose output 21 vgcfbackup command 31 vgcfrestore command 31 vgchange command 29 vgcreate command 26 vgdisplay command 28 vgexport command 32...

Page 112: ...100...

Reviews: