Lets extend the size of testlv
[root@localhost ~]# lvdisplay /dev/testvg/testlv
--- Logical volume ---
LV Name /dev/testvg/testlv
VG Name testvg
LV UUID jFiX1B-SL0k-bZZ3-yHMb-zO4h-OySU-1Sw3a9
LV Write Access read/write
LV Status available
# open 0
LV Size 100.00 MB
Current LE 25
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@localhost ~]# umount /dev/testvg/testlv
[root@localhost ~]# fsck -f /dev/testvg/testlv
fsck 1.39 (29-May-2006)
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/testvg/testlv: 11/25792 files (9.1% non-contiguous), 8927/102400 blocks
[root@localhost ~]# lvextend -L +150M /dev/testvg/testlv
Rounding up size to full physical extent 152.00 MB
Extending logical volume testlv to 252.00 MB
Logical volume testlv successfully resized
[root@localhost ~]# resize2fs /dev/testvg/testlv
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/testvg/testlv to 258048 (1k) blocks.
The filesystem on /dev/testvg/testlv is now 258048 blocks long.
[root@localhost ~]# lvdisplay /dev/testvg/testlv
--- Logical volume ---
LV Name /dev/testvg/testlv
VG Name testvg
LV UUID jFiX1B-SL0k-bZZ3-yHMb-zO4h-OySU-1Sw3a9
LV Write Access read/write
LV Status available
# open 0
LV Size 252.00 MB
Current LE 63
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
****************************************************
After we are done with increasing the size of testlv, let's reduce the size of testlv
[root@localhost ~]# umount /dev/testvg/testlv
[root@localhost ~]# fsck -f /dev/testvg/testlv
fsck 1.39 (29-May-2006)
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/testvg/testlv: 11/63488 files (9.1% non-contiguous), 14193/258048 blocks
[root@localhost ~]# resize2fs /dev/testvg/testlv 150M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/testvg/testlv to 153600 (1k) blocks.
The filesystem on /dev/testvg/testlv is now 153600 blocks long.
[root@localhost ~]# lvreduce -L 150M /dev/testvg/testlv
Rounding up size to full physical extent 152.00 MB
WARNING: Reducing active logical volume to 152.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce testlv? [y/n]: y
Reducing logical volume testlv to 152.00 MB
Logical volume testlv successfully resized
[root@localhost ~]# lvdisplay /dev/testvg/testlv
--- Logical volume ---
LV Name /dev/testvg/testlv
VG Name testvg
LV UUID jFiX1B-SL0k-bZZ3-yHMb-zO4h-OySU-1Sw3a9
LV Write Access read/write
LV Status available
# open 0
LV Size 152.00 MB
Current LE 38
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
(have u noticed the sequence of commands: lvextend and resize2fs commands are in different order for two different operations. Keep only one thing in mind, resize2fs should be run before lvextend while reducing the size of LV )
No comments:
Post a Comment