resize lvm reiserfs file system

In this example I am using CentOS 6 on lvm.

/dev/sda is the firs hard drive( I had install OS on /dev/sda1 with ext4 file system)
/dev/sdb is my second hard drive ( I had use it for tests)

/*First let’s install reiserfs system utils*/

[root@localhost ~]#rpm –import http://elrepo.org/RPM-GPG-KEY-elrepo.org
[root@localhost ~]#rpm -Uvh http://elrepo.org/elrepo-release-6-4.el6.elrepo.noarch.rpm
[root@localhost ~]#yum update
[root@localhost ~]#yum install kmod-reiserfs reiserfs-utils

/*load reiserfs modules in the kernel*/
[root@localhost ~]#modprobe reiserfs

/*list volume groups*/

[root@localhost ~]# lvdisplay
— Logical volume —
LV Path /dev/vg_bentoslack/bentoslack
LV Name bentoslack
VG Name vg_bentoslack
LV UUID TmzPUK-RJKN-xjRd-ydFs-uhaK-C1gk-QBtGvM
LV Write Access read/write
LV Creation host, time bentoslack, 2013-07-03 08:07:59 -0400
LV Status available
# open 1
LV Size 29.80 GiB
Current LE 7629
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0

/*create our reiserfs volume group*/

[root@localhost ~]# vgcreate reiserfsVolumeGroup /dev/sdb
Volume group “reiserfsVolumeGroup” successfully created

/*create our logical volume in this volume group*/

[root@localhost ~]# lvcreate -L 9G reiserfsVolumeGroup
Logical volume “lvol0” created

/*make the reiserfs filesystem*/

[root@localhost ~]# mkfs.reiserfs /dev/reiserfsVolumeGroup/lvol0

/*make a mount point*/

[root@localhost ~]# mkdir /mnt/reiserfs
[root@localhost ~]# mount /dev/reiserfsVolumeGroup/lvol0 /mnt/reiserfs/

/*show disk space usage*/

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_bentoslack-bentoslack
30G 2.0G 28G 7% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 194M 31M 153M 17% /boot
/dev/mapper/reiserfsVolumeGroup-lvol0
9.0G 33M 9.0G 1% /mnt/reiserfs

/*resize reiserfs file system (reduce size) */

[root@localhost ~]# resize_reiserfs -s -3G /dev/reiserfsVolumeGroup/lvol0

/*shrink the logical volume */

[root@localhost ~]# lvreduce -L -3G /dev/reiserfsVolumeGroup/lvol0
ARNING: Reducing active logical volume to 6.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvol0? [y/n]: y
Reducing logical volume lvol0 to 6.00 GiB
Logical volume lvol0 successfully resized

/*check the disk space usage after the resize operations*/

[root@localhost ~]# mount /dev/reiserfsVolumeGroup/lvol0 /mnt/reiserfs/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_bentoslack-bentoslack
30G 2.0G 28G 7% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 194M 31M 153M 17% /boot
/dev/mapper/reiserfsVolumeGroup-lvol0
6.0G 33M 6.0G 1% /mnt/reiserfs

/*let’s extend the logical volume*/

[root@localhost ~]# lvextend -L+2G /dev/reiserfsVolumeGroup/lvol0
Extending logical volume lvol0 to 8.00 GiB
Logical volume lvol0 successfully resized

/*resize the file system (extend) */

[root@localhost ~]# resize_reiserfs /dev/reiserfsVolumeGroup/lvol0
resize_reiserfs 3.6.21 (2009 www.namesys.com)

ReiserFS report:
blocksize 4096
block count 2097152 (1572864)
free blocks 2088877 (1564605)
bitmap block count 64 (48)

Syncing..done

resize_reiserfs: Resizing finished successfully.

/*check the disk space again*/

[root@localhost ~]# mount /dev/reiserfsVolumeGroup/lvol0 /mnt/reiserfs/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_bentoslack-bentoslack
30G 2.0G 28G 7% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 194M 31M 153M 17% /boot
/dev/mapper/reiserfsVolumeGroup-lvol0
8.0G 33M 8.0G 1% /mnt/reiserfs

Finito! 😉

root@localhost ~]# lvdisplay
— Logical volume —
LV Path /dev/reiserfsVolumeGroup/lvol0
LV Name lvol0
VG Name reiserfsVolumeGroup
LV UUID b1135F-nX9k-6ofl-MvCT-jTNW-AgZC-aX8gGV
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2013-07-03 08:21:31 -0400
LV Status available
# open 2
LV Size 8.00 GiB
Current LE 2048
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1

— Logical volume —
LV Path /dev/vg_bentoslack/bentoslack
LV Name bentoslack
VG Name vg_bentoslack
LV UUID TmzPUK-RJKN-xjRd-ydFs-uhaK-C1gk-QBtGvM
LV Write Access read/write
LV Creation host, time bentoslack, 2013-07-03 08:07:59 -0400
LV Status available
# open 1
LV Size 29.80 GiB
Current LE 7629
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0

Leave a Reply

Your email address will not be published. Required fields are marked *