5
Initializing Physical Volumes # pvcreate /dev/sdd /dev/sde /dev/sdf To initialize partitions rather than whole disks: run the pvcreate command on the partition. The following example initializes the partition /dev/hdb1 as an LVM physical volume for later use as part of an LVM logical volume. # pvcreate /dev/hdb1 Scanning for Block Devices You can scan for block devices that may be used as physical volumes with the lvmdiskscan command, as shown in the following example. /dev/sda1 [ 17.14 GB] LVM physical volume /dev/sdd1 [ 17.14 GB] LVM physical volume /dev/sdc1 [ 17.14 GB] LVM physical volume Displaying Physical Volumes There are three commands you can use to display properties of LVM physical volumes: pvs , pvdisplay , and pvscan . # pvdisplay --- Physical volume --- PV Name /dev/sdc1 VG Name new_vg PV Size 17.14 GB / not usable 3.40 MB

Initializing Physical Volumes

Embed Size (px)

DESCRIPTION

aix lvm

Citation preview

Initializing Physical Volumes# pvcreate /dev/sdd /dev/sde /dev/sdfTo initialize partitions rather than whole disks: run thepvcreatecommand on the partition. The following example initializes the partition/dev/hdb1as an LVM physical volume for later use as part of an LVM logical volume.# pvcreate /dev/hdb1Scanning for Block DevicesYou can scan for block devices that may be used as physical volumes with thelvmdiskscancommand, as shown in the following example./dev/sda1 [ 17.14 GB] LVM physical volume/dev/sdd1 [ 17.14 GB] LVM physical volume /dev/sdc1 [ 17.14 GB] LVM physical volumeDisplaying Physical VolumesThere are three commands you can use to display properties of LVM physical volumes:pvs,pvdisplay, andpvscan.# pvdisplay --- Physical volume --- PV Name /dev/sdc1 VG Name new_vg PV Size 17.14 GB / not usable 3.40 MB Allocatable yes PE Size (KByte) 4096 Total PE 4388 Free PE 4375 Allocated PE 13 PV UUID Joqlch-yWSj-kuEn-IdwM-01S9-XO8M-mcpsVe

# 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]Preventing Allocation on a Physical VolumeThe following command disallows the allocation of physical extents on/dev/sdk1.# pvchange -x n /dev/sdk1You can also use the-xyarguments of thepvchangecommand to allow allocation where it had previously been disallowed.Removing Physical Volumes# pvremove /dev/ram15Creating Volume Groups# vgcreate vg1 /dev/sdd1 /dev/sde1LVM volume groups and underlying logical volumes are included in the device special file directory tree in the/devdirectory with the following layout:Adding Physical Volumes to a Volume Group# vgextend vg1 /dev/sdf1# vgs# vgdisplay new_vgNOTE:You may need to run thevgscancommand manually when you change your hardware configuration and add or delete a device from a node, causing new devices to be visible to the system that were not present at system bootup. This may be necessary, for example, when you add new disks to the system on a SAN or hotplug a new disk that has been labeled as a physical volume. LVM runs thevgscancommand automatically at system startup and at other times during LVM operation# vgscanRemoving Physical Volumes from a Volume Group# pvdisplay /dev/hda1# vgreduce my_volume_group /dev/hda1The following command changes the maximum number of logical volumes of volume groupvg00to 128.# vgchange -l 128 /dev/vg00Deactivating VG# vgchange -a n my_volume_groupRemoving Volume Groups# vgremove officevgSplitting a Volume GroupTo split the physical volumes of a volume group and create a new volume group, use thevgsplitcommand.# vgsplit bigvg smallvg /dev/ram15Combining Volume GroupsThe following command merges the inactive volume groupmy_vginto the active or inactive volume groupdatabasesgiving verbose runtime information.# vgmerge -v databases my_vgBy default, the metadata backup is stored in the/etc/lvm/backupfile. You can manually back up the metadata to the/etc/lvm/backupfile with thevgcfgbackupcommand.Renaming a Volume GroupEither of the following commands renames the existing volume groupvg02tomy_volume_group# vgrename /dev/vg02 /dev/my_volume_group# vgrename vg02 my_volume_groupThe following command creates a logical volume 10 gigabytes in size in the volume groupvg1.# lvcreate -L 10G vg1# lvcreate -L 1500 -n testlv testvg# lvcreate -L 50G -n gfslv vg0creating striped lv# lvcreate -L 50G -i2 -I64 -n gfslv vg0The following command creates a mirrored logical volume with a single mirror. The volume is 50 gigabytes in size, is namedmirrorlv, and is carved out of volume groupvg0:# lvcreate -L 50G -m1 -n mirrorlv vg0# lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1 /dev/sdb1 /dev/sdc1