Author Subject Change / Reviewer: Amit Kumar Linux Volume Manager Arun Nayak 1.0
Author Subject Change / Reviewer: Amit Kumar Linux Volume Manager Arun Nayak 1.0
Version 1.0
LVM
Subject
Version 1.0
Page
LVM
Linux Volume Manager 2
Version 1.0
1. Creating and initializing physical volume group; #pvcreate /dev/hda1 /dev/hdb2 This will create a volume group descriptor at the start of the disk. 2. Creating a volume group; #vgcreate my_vol_group /dev/hda1 /dev/hdb2 and so on. 3. Activating a volume group: #vgchange a y my_vol_group 4. Removing a volume group: Make sure that no logical volumes are present on the volume group. Deactivate the volume group #vgchange a n my_vol_group Now actually you will remove the volume group. #vgremove my_vol_group 5. Adding physical volume to a existing volume group Use vgextentd to add and initialized physical volume to an existing volume group. #vgextentd my_vol_group /dev/hdc1 6. Removing physical volume from a existing volume group Make sure that the physical volume isn't used by any logical volumes by using then 'pvdisplay' command #pvdisplay /dev/hda1 --- Physical volume --PV Name /dev/hda1
Page
LVM
Version 1.0
VG Name myvg PV Size 1.95 GB / NOT usable 4 MB [LVM: 122 KB] PV# 1 PV Status available Allocatable yes (but full) Cur LV 1 PE Size (KByte) 4096 Total PE 499 Free PE 0 Allocated PE 499 PV UUID Sd44tK-9IRw-SrMC-MOkn-76iP-iftz-OVSen7
Once you are sure that the physical volume is not in used you can remove that from the volume group by the below command. If the physical volume is still used you will have to migrate the data to another physical volume using pvmove. Then use 'vgreduce' to remove the physical volume: # vgreduce my_volume_group /dev/hda1 7. Creating a logical volume To create a 1500MB linear LV named 'testlv' and its block device special '/dev/testvg (This is the name of voume group)/testlv (this is the name of logical volume)': # lvcreate -L1500 -ntestlv testvg 8. Removing a Logical volume: A logical volume must be closed before it can be removed: # umount /dev/myvg/homevol # lvremove /dev/myvg/homevol lvremove -- do you really want to remove "/dev/myvg/homevol"? [y/n]: y lvremove -- doing automatic backup of volume group "myvg" lvremove -- logical volume "/dev/myvg/homevol" successfully removed
Page