Monday, December 2, 2013

How to reduce LV in Linux….

How to reduce LV in Linux….

#I had a request to reduce FS size which is created in LVM.  The request was to reduce /ucm   to 50GB.
uktc19zr:root:/root # cat /etc/fstab | grep ucm
/dev/vg1/ucmvol /ucm    ext3    defaults        1 2
#

# df -h /ucm
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg1-ucmvol
                       71G   46G   22G  69% /ucm
 #
#Before reducing file system, please make sure you have taken FULL backup of the file system, only after that proceed with reducing FS.

 # umount /ucm
#

# Check the file system via e2fsck. This command may take some time depending the FS size so be patient.
# e2fsck  -f /dev/vg1/ucmvol
e2fsck 1.39 (29-May-2006)
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/vg1/ucmvol: 380728/9437184 files (0.6% non-contiguous), 12304443/18874368 blocks

#Resize the file system to the size as per requirement.
    I had to make it to 50GB, I used below.
This command may take some time depending the FS size so be patient.
uktc19zr:root:/root # resize2fs -f /dev/vg1/ucmvol 52000M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg1/ucmvol to 13312000 (4k) blocks.
The filesystem on /dev/vg1/ucmvol is now 13312000 blocks long.

#Resize the volume to the size as per requirement.  
# lvresize -L 52G /dev/vg1/ucmvol
  WARNING: Reducing active logical volume to 52.00 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce ucmvol? [y/n]: y
  Reducing logical volume ucmvol to 52.00 GB
  Logical volume ucmvol successfully resized
#
#check the size of volume..
# lvdisplay  /dev/vg1/ucmvol
  --- Logical volume ---
  LV Name                /dev/vg1/ucmvol
  VG Name                vg1
  LV UUID                q2NnGB-aZAF-cwsO-Ad3I-0vpT-vg08-WLy2y4
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                52.00 GB
  Current LE             13312
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:14
  
#

Mount the FS and verify.

uktc19zr:root:/root # mount /ucm
uktc19zr:root:/root # df -h /ucm
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg1-ucmvol
                       50G   46G  2.2G  96% /ucm
#

No comments:

Post a Comment