Thursday, August 11, 2011

resize an ext3 filesystem online


resize an ext3 filesystem online

keywords: openfiler, iscsi, rhel, rhel4, linux, oracle, ext3, lvm2, ext2online, oracle

Rather than adding mutliple devices to a volume group when using openfiler to present
iSCSI Luns for filesystem use to a Linux system, I prefer to resize the LUN and extend the
volume and filesystem that holds it on the OS. You can do this without shutting anything
down or umounting the filesystem, but obviously use at your own risk.

Openfiler:
1. Choose your LUN in openfiler volume management. Increase its size in Openfiler.
In this case I increase a LUN from 15Gb to 25GB.

OS:

[root@ora02 app]# iscsi-rescan
Rescanning host2
Rescanning host3

# Multiple "hosts" are listed since I present multiple targets to the host containing different
LUN groups. One set is shared LUNs for an Oracle cluster and the other contains LUNs
exclusive to this host.

# identify the device that you want to extend. In this case its /dev/sdb
# and the VG is ora01sanfs

[root@ora01 ~]# pvscan
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
PV /dev/sdb VG ora01sanfs lvm2 [15.00 GB / 0 free]
PV /dev/sda2 VG rootdg lvm2 [232.75 GB / 195.44 GB free]
Total: 2 [247.75 GB] / in use: 2 [247.75 GB] / in no VG: 0 [0 ]

# Now execute a pvresize to reflect the LUNs new larger size

[root@ora01 ~]# pvresize /dev/sdb
Physical volume "/dev/sdb" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

[root@ora02 app]# pvscan
PV /dev/sdb VG ora02sanfs lvm2 [25.00 GB / 0 free]
PV /dev/sda2 VG rootdg lvm2 [232.75 GB / 195.44 GB free]
Total: 2 [257.75 GB] / in use: 2 [257.75 GB] / in no VG: 0 [0 ]

# Now work out how many extra extents you have to given your VG for use when
increasing the LV size.

[root@ora01 ~]# vgdisplay ora01sanfs
--- Volume group ---
VG Name ora01sanfs
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 25.00 GB
PE Size 4.00 MB
Total PE 6399
Alloc PE / Size 3839 / 15.00 GB
Free PE / Size 2560 / 10.00 GB
VG UUID ub4wUC-3Try-z7Rq-NgEH-1RAp-eG3B-K17JfQ

# Now extend the LV.
# Note the + symbol is important, as it states "add" 2560 extents.

[root@ora02 app]# lvextend -l +2560 /dev/mapper/ora02sanfs-lv_ora02_orahome
Extending logical volume lv_ora02_orahome to 25.00 GB
Logical volume lv_ora02_orahome successfully resized

# Note the filesystem is currently 15GB
[root@ora02 app]# df -k /u01
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ora02sanfs-lv_ora02_orahome
15477744 12717992 1973796 87% /u01


# Now extend the filesystem (ext3)

[root@ora02 app]# ext2online /u01
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b

[root@ora02 app]# df -k /u01
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ora02sanfs-lv_ora02_orahome
25798972 12725240 11763820 52% /u01

All done without shutting anything down.

No comments:

Post a Comment