Linux LVM Command

Add new LVM

fdisk /dev/sdb
g


x
pvcreate /dev/sdb1
vgcreate new /dev/sdb1
lvcreate --name vol -l 100%FREE new

# create ext4
mkfs.ext4 /dev/vg_newlvm/centos7_newvol

# create xfs
mkfs.xfs /dev/new/vol

#mount to /opt
mount /dev/new/vol /opt

# 
vi /etc/fstab

# ext4
/dev/mapper/new-vol     /opt                       ext4     defaults        0 0

# xfs
/dev/mapper/new-vol     /opt                       xfs     defaults        0 0

Extend LVM

############## recheck rescan HDD 
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
tail -f /var/log/message

fdisk /dev/sdc
g


x
pvcreate /dev/sdc1
vgextend vg  /dev/sdc1
vgdisplay
lvextend -l +4607 /dev/vg/vol

# ext4
resize2fs /dev/vg/vol

# xfs
xfs_growfs /dev/vg/vol

For Cloud Extend lvm

fdisk /dev/vdb
n
p
1
[enter]
[enter]
t
8e
w

pvcreate /dev/vdb1

# Centos7  #xfs
vgextend centos  /dev/vdb1
lvextend -l +100%FREE /dev/centos/root
xfs_growfs /dev/centos/root

# Centos6  # ext4
vgextend VolGroup /dev/vdb1
lvextend -l +100%FREE /dev/VolGroup/lv_root
resize2fs /dev/VolGroup/lv_root



### Delete vg 
vgdisplay

vgremove my_volume_group

parted -a optimal /dev/sda mkpart primary 0% 4096MB

align aligned alignment 4K for SSD