centostricks

Just another WordPress.com site

resize logical Volume (LV) with Risk


This blog shows how to reduce the LV and split the VG to create a VG with unused Space

Warning !!! Reducing LV is like playing with DATA !!!

This steps are done on CentOS 6.x OS EL

[root@localhost ~]# lvreduce -L 900M /dev/VG_00/song
WARNING: Reducing active and open logical volume to 900.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce song? [y/n]: y
Reducing logical volume song to 900.00 MiB
Logical volume song successfully resized
[root@localhost ~]# resize2fs /dev/VG_00/song
resize2fs 1.41.10 (10-Feb-2009)
Filesystem at /dev/VG_00/song is mounted on /striped; on-line resizing required
On-line shrinking from 393216 to 230400 not supported.
[root@localhost ~]# umount /striped/
[root@localhost ~]# resize2fs /dev/VG_00/song
resize2fs 1.41.10 (10-Feb-2009)
Please run ‘e2fsck -f /dev/VG_00/song’ first.

[root@localhost ~]# e2fsck -f /dev/VG_00/song
e2fsck 1.41.10 (10-Feb-2009)
The filesystem size (according to the superblock) is 393216 blocks
The physical size of the device is 230400 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? yes

[root@localhost ~]# resize2fs /dev/VG_00/song
resize2fs 1.41.10 (10-Feb-2009)
Please run ‘e2fsck -f /dev/VG_00/song’ first.

[root@localhost ~]# man re
[root@localhost ~]# man resize2fs
[root@localhost ~]# resize2fs -f /dev/VG_00/song
resize2fs 1.41.10 (10-Feb-2009)
Resizing the filesystem on /dev/VG_00/song to 230400 (4k) blocks.
The filesystem on /dev/VG_00/song is now 230400 blocks long.

[root@localhost ~]# e2fsck -f /dev/VG_00/song
e2fsck 1.41.10 (10-Feb-2009)
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/VG_00/song: 13/65536 files (7.7% non-contiguous), 23039/230400 blocks
[root@localhost ~]# mount /dev/VG_00/song /striped/
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
11G  4.5G  5.4G  46% /
tmpfs                 499M  524K  499M   1% /dev/shm
/dev/sda1             485M   33M  428M   7% /boot
/dev/sr0              4.1G  4.1G     0 100% /media/RHEL_6.0 x86_64 Disc 1
/dev/mapper/VG_00-song
884M   74M  766M   9% /striped
[root@localhost ~]# cd /striped/
[root@localhost striped]# ll
total 40992
-rw-r–r–. 1 root root       24 Aug 10 08:38 aa
drwx——. 2 root root    16384 Aug 10 08:35 lost+found
-rw-r–r–. 1 root root 41955328 Aug 10 08:36 test
[root@localhost striped]# cat aa
dnandsandlandtesteinggg

[root@localhost striped]#
[root@localhost striped]#
[root@localhost striped]# pvscan
PV /dev/sdb    VG VG_00           lvm2 [1020.00 MiB / 120.00 MiB free]
PV /dev/sdc    VG VG_00           lvm2 [1020.00 MiB / 1020.00 MiB free]
PV /dev/sda2   VG VolGroup        lvm2 [12.51 GiB / 0    free]
PV /dev/sdd                       lvm2 [1.00 GiB]
Total: 4 [15.50 GiB] / in use: 3 [14.50 GiB] / in no VG: 1 [1.00 GiB]
[root@localhost striped]# pvmove /dev/sdc /dev/sdb
No data to move for VG_00
[root@localhost striped]#
[root@localhost striped]# vgsplit VG_00 VG_01 /dev/sdc
Volume group VG_00 is not resizeable.
[root@localhost striped]# vgchange -x y VG_00
Volume group “VG_00” successfully changed
[root@localhost striped]# vgsplit VG_00 VG_01 /dev/sdc
New volume group “VG_01” successfully split from “VG_00”
[root@localhost striped]# vgscan
Reading all physical volumes.  This may take a while…
Found volume group “VG_01” using metadata type lvm2
Found volume group “VG_00” using metadata type lvm2
Found volume group “VolGroup” using metadata type lvm2
[root@localhost striped]# pvscan
PV /dev/sdc    VG VG_01           lvm2 [1020.00 MiB / 1020.00 MiB free]
PV /dev/sdb    VG VG_00           lvm2 [1020.00 MiB / 120.00 MiB free]
PV /dev/sda2   VG VolGroup        lvm2 [12.51 GiB / 0    free]
PV /dev/sdd                       lvm2 [1.00 GiB]
Total: 4 [15.50 GiB] / in use: 3 [14.50 GiB] / in no VG: 1 [1.00 GiB]
[root@localhost striped]# ls
aa  lost+found  test
[root@localhost striped]# cat aa
dnandsandlandtesteinggg

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: