#########################################################################################################################
#
# LVM - SHRINKING A VOLUME AND EXT4 FILESYSTEM
#
#########################################################################################################################
root@system1:~# df -h /scratch
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-scratchlv 74G 53M 70G 1% /scratch
root@system1:~# umount /scratch
root@system1:~# e2fsck -f /dev/mapper/vg00-scratchlv
e2fsck 1.44.1 (24-Mar-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg00-scratchlv: 12/4898816 files (0.0% non-contiguous), 451906/19589120 blocks
root@system1:~#
root@system1:~# resize2fs /dev/mapper/vg00-scratchlv 1G
resize2fs 1.44.1 (24-Mar-2018)
Resizing the filesystem on /dev/mapper/vg00-scratchlv to 262144 (4k) blocks.
The filesystem on /dev/mapper/vg00-scratchlv is now 262144 (4k) blocks long.
root@system1:~# lvreduce -L 1G /dev/mapper/vg00-scratchlv
WARNING: Reducing active logical volume to 1.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg00/scratchlv? [y/n]: y
Size of logical volume vg00/scratchlv changed from <74.73 GiB (19130 extents) to 1.00 GiB (256 extents).
Logical volume vg00/scratchlv successfully resized.
root@system1:~#
root@system1:~# e2fsck -f /dev/mapper/vg00-scratchlv
e2fsck 1.44.1 (24-Mar-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg00-scratchlv: 12/65536 files (0.0% non-contiguous), 140322/262144 blocks
root@system1:~# mount /scratch
root@system1:~# df -h /scratch
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-scratchlv 496M 21M 409M 5% /scratch
#########################################################################################################################
#
# LVM - EXPANDING A VOLUME AND EXT4 FILESYSTEM
#
#########################################################################################################################
root@system1:~# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-rootlv 19G 18G 0 100% /
root@system1:~# blkid /dev/mapper/vg00-rootlv
/dev/mapper/vg00-rootlv: UUID="5f562e25-6fa0-4cea-8058-6506dbc1dfde" TYPE="ext4"
root@system1:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda6 vg00 lvm2 a-- <99.52g <73.73g
root@system1:~# vgs
VG #PV #LV #SN Attr VSize VFree
vg00 1 4 0 wz--n- <99.52g <73.73g
root@system1:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
rootlv vg00 -wi-ao---- 19.07g
scratchlv vg00 -wi-ao---- 1.00g
swaplv vg00 -wi-ao---- <1.91g
tmplv vg00 -wi-ao---- 3.81g
root@system1:~#
root@system1:~# lvextend -l +100%FREE /dev/mapper/vg00-rootlv
Size of logical volume vg00/rootlv changed from 19.07 GiB (4882 extents) to <92.80 GiB (23756 extents).
Logical volume vg00/rootlv successfully resized.
root@system1:~# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-rootlv 19G 18G 0 100% /
root@system1:~# resize2fs /dev/mapper/vg00-rootlv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mapper/vg00-rootlv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 12
The filesystem on /dev/mapper/vg00-rootlv is now 24326144 (4k) blocks long.
root@system1:~# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-rootlv 92G 18G 70G 21% /
root@system1:~#
root@system1:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
rootlv vg00 -wi-ao---- <92.80g
scratchlv vg00 -wi-ao---- 1.00g
swaplv vg00 -wi-ao---- <1.91g
tmplv vg00 -wi-ao---- 3.81g
No comments:
Post a Comment