swapoff -v /dev/centos/swap
lvreduce -L -100m /dev/centos/swap
mkswap /dev/centos/swap
swapon -v /dev/centos/swap
With earlier version of Red Hat 5, the -r option was not available in LVM tools which would automatically use resize2fs to resize the underlying file system. So the process for extending LV's is as follows.
lvextend -L +1G /dev/mapper/vg_root-lv_usr
resize2fs /dev/mapper/vg_root-lv_usr
With later versions of Red Hat 5 and onwards, you could do this in one command.
lvextend -r -L +1G /dev/mapper/vg_root-lv_usr
Login to VMWare, find the virtual machine which requires the additional disk space, edit settings and increase disk space.
Once the disk size has been increased in VMWare, you need to get Linux to see and use the additional space.
This will be dependent on which device the space is on.
Rescan Linux Disks
echo 1 > /sys/block/sdb/device/rescan
# Or
ls -1d /sys/class/scsi_host/*
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "1" > /sys/class/scsi_host/host0/device/rescan
Check for the increase size using fdisk
fdsik -l /dev/sdb
Increase Physical Volume size
pvresize /dev/sdb
pvdisplay
The VG will automatically see the extra space. Extend the LV. The -r flag is important. If you do not use it you will need to use resize2fs.
lvextend -r -l +100%FREE /dev/vg01/apps
Check to see your additional space
lvdisplay
df -h
A thin pool LV must be created before thin LVs can be created within it. A thin pool LV is created by combining two standard LVs: a large data LV that will hold blocks for thin LVs, and a meta‐data LV that will hold metadata. The metadata tracks which data blocks belong to each thin LV.
Freeing space in a thin pool
When you remove files from a thin pool, it does not automatically free up space from the pool. You need to run fstrim to do this.
[root@gfs2 ~]# lvs -a
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
gfs_pool_data gfs_vg1 twi-aotz-- <7.48g 61.38 57.13
[gfs_pool_data_tdata] gfs_vg1 Twi-ao---- <7.48g
[gfs_pool_data_tmeta] gfs_vg1 ewi-ao---- 4.00m
gfs_thin_lv1 gfs_vg1 Vwi-aotz-- 5.00g gfs_pool_data 91.78
[lvol0_pmspare] gfs_vg1 ewi------- 4.00m
root rhel -wi-ao---- <6.20g
swap rhel -wi-ao---- 820.00m
[root@gfs2 ~]# fstrim -v /mnt/gfs/apps/
/mnt/gfs/apps/: 4 GiB (4267118592 bytes) trimmed
[root@gfs2 ~]# lvs -a
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
gfs_pool_data gfs_vg1 twi-aotz-- <7.48g 14.82 15.53
[gfs_pool_data_tdata] gfs_vg1 Twi-ao---- <7.48g
[gfs_pool_data_tmeta] gfs_vg1 ewi-ao---- 4.00m
gfs_thin_lv1 gfs_vg1 Vwi-aotz-- 5.00g gfs_pool_data 22.15
[lvol0_pmspare] gfs_vg1 ewi------- 4.00m
root rhel -wi-ao---- <6.20g
swap rhel -wi-ao---- 820.00m