Resize LVM ReiserFS Partition

Mucking about with LVM and partitions isn’t really taxing, it’s all well documented. Trusting it however is a different matter. I’ve resized loads of Ext3 LVM partitions in the past, but was asked to resize a ReiserFS one today, which made me ask the question:

Is there anything writing to it currently, as I will have to unmount it first ..

Wrong assumption, or so says the guy sat next to me! ReiserFS can be dynamically resized on the fly! Woohoo says I, lets have a look at the resize_reiserfs man page!


DESCRIPTION
The resize_reiserfs tool resizes an unmounted reiserfs file system.

“Are you sure?” I ask .. “Yes”, he promises!


anise:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lv_slot_bbocp
10G 6.0G 4.1G 60% /opt/sem/slot/bbocp
anise:~# lvdisplay /dev/vg00/lv_slot_bbocp
--- Logical volume ---
LV Name /dev/vg00/lv_slot_bbocp
VG Name vg00
LV UUID P9nb4N-ED0Q-jSWh-xLbs-zP72-5QXL-DbyHiM
LV Write Access read/write
LV Status available
# open 2
LV Size 10.00 GB
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:11
anise:~# vgdisplay vg00
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 35
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 13
Open LV 12
Max PV 0
Cur PV 1
Act PV 1
VG Size 219.83 GB
PE Size 4.00 MB
Total PE 56276
Alloc PE / Size 53762 / 210.01 GB
Free PE / Size 2514 / 9.82 GB
VG UUID HDU1Dc-5i7l-wyGE-cEdM-YpdG-kskb-nw0JWm

There is 9GB of free space in the volume group, and our partition wants to grow by 5GB so thats Ok! Lets do this!


anise:~# lvextend -L+5G /dev/vg00/lv_slot_bbocp
Extending logical volume lv_slot_bbocp to 15.00 GB
Logical volume lv_slot_bbocp successfully resized
anise:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lv_slot_bbocp
10G 6.0G 4.1G 60% /opt/sem/slot/bbocp

No change yet though! Lets do the resize, with it still mounted!!


anise:~# resize_reiserfs -f /dev/vg00/lv_slot_bbocp
resize_reiserfs 3.6.19 (2003 www.namesys.com)
resize_reiserfs: On-line resizing finished successfully.
anise:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lv_slot_bbocp
15G 6.0G 9.1G 40% /opt/sem/slot/bbocp

Woo hoo! We did it, well it’s 15GB in size, and apparently all the data is still there and working and not corrupt. Rejoice. Someone really needs to update that man page!!!

Resize Xen Filesystem

We run a lot of Xen instances for our development and test servers and a few were starting to get full. Fortunately the disks in the real servers were very large and the xenlet partitions were made using LVM so resizing them to add more space was possible!


root@dev-myfiles0:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 4.0G 3.8G 200M 95% /
varrun 257M 48K 257M 1% /var/run
varlock 257M 0 257M 0% /var/lock
udev 257M 40K 257M 1% /dev
devshm 257M 0 257M 0% /dev/shm

Basically we just have to shut down the xenlet, resize the partition and then restart the xenlet again, simple!


root@brandy:~# xm shutdown dev-myfiles0
root@brandy:~# lvextend -L40G /dev/vg0/dev-myfiles0-disk
Extending logical volume dev-myfiles0-disk to 40.00 GB
Logical volume dev-myfiles0-disk successfully resized
root@brandy:~# e2fsck -f /dev/vg0/dev-myfiles0-disk
e2fsck 1.40.2 (12-Jul-2007)
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/vg0/dev-myfiles0-disk: 16541/524288 files (0.9% non-contiguous), 138346/1048576 blocks
root@brandy:~# resize2fs /dev/vg0/dev-myfiles0-disk
resize2fs 1.40.2 (12-Jul-2007)
Resizing the filesystem on /dev/vg0/dev-myfiles0-disk to 10485760 (4k) blocks.
The filesystem on /dev/vg0/dev-myfiles0-disk is now 10485760 blocks long.
root@brandy:~# cd /etc/xen
root@brandy:/etc/xen# xm create dev-myfiles0.cfg
Using config file "./dev-myfiles0.cfg".
Started domain dev-myfiles0

Wee, lots of free space now!


root@dev-myfiles0:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 40G 3.8G 37G 10% /
varrun 257M 40K 257M 1% /var/run
varlock 257M 0 257M 0% /var/lock
udev 257M 40K 257M 1% /dev
devshm 257M 0 257M 0% /dev/shm