lvm – shrink lvm partition size

[root@rhelA ~]# findmnt
TARGET                       SOURCE                       FSTYPE      OPTIONS
/                            /dev/mapper/vg_rhela-lv_root ext4        rw,relatime,seclabel,barrier=1,data=ordered
├─/proc                      proc                         proc        rw,relatime
│ ├─/proc/bus/usb            /proc/bus/usb                usbfs       rw,relatime
│ └─/proc/sys/fs/binfmt_misc                              binfmt_misc rw,relatime
├─/sys                       sysfs                        sysfs       rw,relatime,seclabel
├─/selinux                                                selinuxfs   rw,relatime
├─/dev                       devtmpfs                     devtmpfs    rw,relatime,seclabel,size=946208k,nr_inodes=236552,mode=755
│ └─/dev                     devtmpfs                     devtmpfs    rw,relatime,seclabel,size=946208k,nr_inodes=236552,mode=755
│   ├─/dev/pts               devpts                       devpts      rw,relatime,seclabel,gid=5,mode=620,ptmxmode=000
│   └─/dev/shm               tmpfs                        tmpfs       rw,relatime,seclabel
├─/boot                      /dev/sda1                    ext4        rw,relatime,seclabel,barrier=1,data=ordered
├─/home                      /dev/mapper/vg_rhela-lv_home ext4        rw,relatime,seclabel,barrier=1,data=ordered
├─/misc                      /etc/auto.misc               autofs      rw,relatime,fd=7,pgrp=1649,timeout=300,minproto=5,maxproto=5,indirect
└─/net                       -hosts                       autofs      rw,relatime,fd=13,pgrp=1649,timeout=300,minproto=5,maxproto=5,indirect

[root@rhelA ~]# umount /home

[root@rhelA ~]# e2fsck -f /dev/mapper/vg_rhela-lv_home 
e2fsck 1.41.12 (17-May-2010)
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/vg_rhela-lv_home: 656/4300800 files (17.8% non-contiguous), 4124861/17188864 blocks

[root@rhelA ~]# e2fsck -fy /dev/mapper/vg_rhela-lv_home 
e2fsck 1.41.12 (17-May-2010)
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/vg_rhela-lv_home: 656/4300800 files (17.8% non-contiguous), 4124861/17188864 blocks

[root@rhelA ~]# resize2fs /dev/mapper/vg_rhela-lv_home 25G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_rhela-lv_home to 6553600 (4k) blocks.
The filesystem on /dev/mapper/vg_rhela-lv_home is now 6553600 blocks long.

[root@rhelA ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_rhela
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               119.51 GiB
  PE Size               4.00 MiB
  Total PE              30594
  Alloc PE / Size       30594 / 119.51 GiB
  Free  PE / Size       0 / 0   
  VG UUID               DOXFrI-vdc8-KjtT-qN4N-oGj3-Yf8K-suupSe

[root@rhelA ~]# lvreduce -L 25G /dev/vg_rhela/lv_home 
  WARNING: Reducing active logical volume to 25.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
  Size of logical volume vg_rhela/lv_home changed from 65.57 GiB (16786 extents) to 25.00 GiB (6400 extents).
  Logical volume lv_home successfully resized
[root@rhelA ~]# resize2fs /dev/mapper/vg_rhela-lv_home 
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 6553600 blocks long.  Nothing to do!

[root@rhelA ~]# mount /dev/mapper/vg_rhela-lv_home /home

[root@rhelA ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_rhela-lv_root
                       50G  4.2G   43G   9% /
tmpfs                 940M  296K  939M   1% /dev/shm
/dev/sda1             477M   42M  410M  10% /boot
/dev/mapper/vg_rhela-lv_home
                       25G   15G  8.7G  63% /home

[root@rhelA ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_rhela
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               119.51 GiB
  PE Size               4.00 MiB
  Total PE              30594
  Alloc PE / Size       20208 / 78.94 GiB
  Free  PE / Size       10386 / 40.57 GiB
  VG UUID               DOXFrI-vdc8-KjtT-qN4N-oGj3-Yf8K-suupSe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s