Not as usal like extending logical volume, reducing the size of logical volume should be very very careful. Because you can extend lv with out any knowledge of logical extends. But while reducing you should take logical extends in to consideration. Lets see how
i'll take a lv of size 100 MB, lets check it
[root@san ~]# lvdisplay
--- Logical volume ---
LV Name /dev/subbu_vg/lv_1
VG Name subbu_vg
LV UUID xKe83f-zEtO-w1CI-mu7u-Gnfk-eUrr-sJ72fC
LV Write Access read/write
LV Status available
# open 0
LV Size 104.00 MiB
Current LE 26
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
We can reduce/resize lv in two types :
lvdisplay shows LVsize = 104.00 Mb and Current LE is 25 which means while you reduce the size in multiples of 26 0r another method is reducing logical extends. it means you can reduce this lv to either 78MB,52MB or 26 MB. You can not reduce it as you wish if don't follow this rule will lose your data and kernel finds failed file system for this lv and your system won't boot. Lets see how....
Resizing LV by reducing size in multiples of LE :
First check the file system
[root@san ~]#
[root@san ~]# e2fsck -f /dev/mapper/subbu_vg-lv_1
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/subbu_vg-lv_1: 51/24752 files (2.0% non-contiguous), 8486/106496 blocks
File system is ok
Resize it to desired size, make sure it's bit bigger than the data in it.
[root@san ~]# resize2fs /dev/mapper/subbu_vg-lv_1 78M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/subbu_vg-lv_1 to 79872 (1k) blocks.
The filesystem on /dev/mapper/subbu_vg-lv_1 is now 79872 blocks long.
Redcue the lv carefully
[root@san ~]# lvreduce -L -26M /dev/mapper/subbu_vg-lv_1
Rounding up size to full physical extent 24.00 MiB
WARNING: Reducing active and open logical volume to 80.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_1? [y/n]: y
Reducing logical volume lv_1 to 80.00 MiB
Logical volume lv_1 successfully resized
Don't forget to mention "-" before size you want to reduce, very important. Difference is "-26M" reduces 26M from your LV, but only "26M" reduces LV to 26M. you got to be very careful.
You should look at difference between -26M and 26M
Check the file system of resized LV
[root@san ~]# e2fsck -f /dev/mapper/subbu_vg-lv_1
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/subbu_vg-lv_1: 51/19040 files (2.0% non-contiguous), 7766/79872 blocks
Congratulations, no error found. Mount it back on folder to use it.
i'll take a lv of size 100 MB, lets check it
[root@san ~]# lvdisplay
--- Logical volume ---
LV Name /dev/subbu_vg/lv_1
VG Name subbu_vg
LV UUID xKe83f-zEtO-w1CI-mu7u-Gnfk-eUrr-sJ72fC
LV Write Access read/write
LV Status available
# open 0
LV Size 104.00 MiB
Current LE 26
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
We can reduce/resize lv in two types :
- Reducing by size of size in multiples of logical extends .
- Reducing by no of logical extends.
lvdisplay shows LVsize = 104.00 Mb and Current LE is 25 which means while you reduce the size in multiples of 26 0r another method is reducing logical extends. it means you can reduce this lv to either 78MB,52MB or 26 MB. You can not reduce it as you wish if don't follow this rule will lose your data and kernel finds failed file system for this lv and your system won't boot. Lets see how....
Resizing LV by reducing size in multiples of LE :
First check the file system
[root@san ~]#
[root@san ~]# e2fsck -f /dev/mapper/subbu_vg-lv_1
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/subbu_vg-lv_1: 51/24752 files (2.0% non-contiguous), 8486/106496 blocks
File system is ok
Resize it to desired size, make sure it's bit bigger than the data in it.
[root@san ~]# resize2fs /dev/mapper/subbu_vg-lv_1 78M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/subbu_vg-lv_1 to 79872 (1k) blocks.
The filesystem on /dev/mapper/subbu_vg-lv_1 is now 79872 blocks long.
Redcue the lv carefully
[root@san ~]# lvreduce -L -26M /dev/mapper/subbu_vg-lv_1
Rounding up size to full physical extent 24.00 MiB
WARNING: Reducing active and open logical volume to 80.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_1? [y/n]: y
Reducing logical volume lv_1 to 80.00 MiB
Logical volume lv_1 successfully resized
Don't forget to mention "-" before size you want to reduce, very important. Difference is "-26M" reduces 26M from your LV, but only "26M" reduces LV to 26M. you got to be very careful.
You should look at difference between -26M and 26M
Check the file system of resized LV
[root@san ~]# e2fsck -f /dev/mapper/subbu_vg-lv_1
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/subbu_vg-lv_1: 51/19040 files (2.0% non-contiguous), 7766/79872 blocks
Congratulations, no error found. Mount it back on folder to use it.
0 Comments