User Tools

Site Tools


lvm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lvm [2011/06/01 20:59]
k2patel created
lvm [2020/08/10 02:35] (current)
Line 1: Line 1:
 ====== LVM ====== ====== LVM ======
  
-LVM you can increase / decrease size without any issue.+LVM you can increase / decrease size without any issue.\\
 But it is important you do it in proper steps. But it is important you do it in proper steps.
  
 +==== Steps to create LVM from drive ====
 +<code bash>
 +pvcreate /dev/xvdf1
 +pvdisplay /dev/xvdf1
 +vgcreate -s 16M vg0 /dev/xvdf1
 +vgdisplay /dev/xvdf
 +vgdisplay vg0
 +lvcreate -n lv-vol001 vg0
 +lvcreate --help
 +lvcreate -A n -L 24.5G -n lv-vol001 vg0
 +mkfs.ext3 /​dev/​vg0/​lv-vol001
 +</​code>​
  
-==== Reducing Size ====+==== Add drive to LVM ==== 
 +<code bash> 
 +# Rescan the machine if not found. 
 +echo "- - -" > /​sys/​class/​scsi_host/​host0/​scan 
 +# Cont. 
 +fdisk /dev/xvdk ## Comment "​Specify Type 8e by option t" 
 +mkfs.ext3 /dev/xvdk1  
 +pvcreate /dev/xvdk1  
 +vgextend vg0 /​dev/​xvdk1 
 +lvextend -L 300G /​dev/​vg0/​lv-vol001 
 +OR 
 +lvextend -L+99.91G /​dev/​vg0/​lv-vol001 
 +OR 
 +lvextend -l +100%FREE /​dev/​vg0/​lv-vol001 
 +resize2fs /​dev/​vg0/​lv-vol001 
 +</​code>​ 
 +==== Reducing Size ====
  
 <code bash> <code bash>
Line 11: Line 39:
 e2fsck -y /​dev/​mapper/​VolGroup00-LogVol00 e2fsck -y /​dev/​mapper/​VolGroup00-LogVol00
 resize2fs -f /​dev/​mapper/​VolGroup00-LogVol00 1536M resize2fs -f /​dev/​mapper/​VolGroup00-LogVol00 1536M
-lvreduce -L1536M ​/​dev/​mapper/​VolGroup00-LogVol00 ​+lvreduce -L-512M ​/​dev/​mapper/​VolGroup00-LogVol00 ​
 mount /home mount /home
 </​code>​ </​code>​
  
  
-==== Increasing Size ====+==== Increasing Size ====
 <code bash> <code bash>
 umount /opt/ umount /opt/
 e2fsck -y /​dev/​mapper/​VolGroup00-LogVol02 e2fsck -y /​dev/​mapper/​VolGroup00-LogVol02
 lvextend -L+512M /​dev/​mapper/​VolGroup00-LogVol02 lvextend -L+512M /​dev/​mapper/​VolGroup00-LogVol02
 +OR
 +lvextend -l +100%FREE /​dev/​mapper/​VolGroup00-LogVol02
 resize2fs /​dev/​mapper/​VolGroup00-LogVol02 resize2fs /​dev/​mapper/​VolGroup00-LogVol02
 mount /opt mount /opt
 </​code>​ </​code>​
 +
 +==== Worked Example on Live System ====
 +
 +<code bash | history>
 +#rescan the device
 +echo "- - -" > /​sys/​class/​scsi_device/​1\:​0\:​0\:​0/​device/​rescan
 +#list devices and confirm you are going to update which drive.
 +fdisk -l
 +### Delete and recreate the partition 'make sure start block is the same'
 +fdisk /dev/sda ## Comment "​Specify Type 8e by option t"
 +### Reprobe partition table.
 +partprobe -s
 +mkfs.ext3 /dev/sda1
 +vgextend VolGroup00 /dev/sda1
 +lvdisplay
 +vgdisplay ​
 +lvextend -l+1599 /​dev/​VolGroup00/​LogVol00
 +df -kh
 +vgdisplay
 +lvdisplay ​
 +resize2fs /​dev/​VolGroup00/​LogVol00 ​
 +df -kh
 +</​code>​
 +
lvm.1306961960.txt.gz · Last modified: 2020/08/10 02:30 (external edit)