Don't understand german? Read or subscribe to my english-only feed.

ext3 online resizing

Yes, online resizing isn’t possible just with xfs but starting with Linux kernel 2.6.10 you can do it with ext3 as well. With e2fsprogs >=1.39-1 new filesystems are created with directory indexing and on-line resizing enabled by default (see /etc/mke2fs.conf).

A short demo how online-resizing running on top of LVM works:

cfdisk /dev/hda                           # create a partition with type 8e (lvm)
pvcreate /dev/hda2                        # create a physical volume 
vgcreate resize_me /dev/hda2              # create volume group
lvcreate -n resize_me -L100 resize_me     # create a logical volume
mkfs.ext3 /dev/resize_me/resize_me        # now create a new filesystem
mount /dev/resize_me/resize_me /mnt/test  # mount the new fs for demonstrating online resizing
df -h                                     # check the size of the partition
lvextend -L+100M /dev/resize_me/resize_me # let's extend the logical volume
resize2fs /dev/resize_me/resize_me        # and finally resize the filesystem
df -h                                    # recheck the size of the partition -> we now have a filesystem with ~200MB

This also works for Software-RAID (thanks to ‘growing ext3 partition on RAID1 without rebooting’ for the hints):

mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
mkfs.ext3 /dev/md0
mount /dev/md0 /mnt/test
mdadm /dev/md0 --fail /dev/hda2 --remove /dev/hda2
cfdisk /dev/hda                                  # adjust partition size for hda2
mdadm /dev/md0 --add /dev/hda2
mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
cfdisk /dev/hdb                                  # adjust partition size for hdb1
mdadm /dev/md0 --add /dev/hdb1
mdadm --grow /dev/md0 --size=max
resize2fs /dev/md0

Notice: online resizing works as soon as the kernel can re-read the partition table. So it works for example with LVM and SW-RAID but not with a plain device (/dev/[sh]d*). Even though using partprobe, the kernel does not re-read the partition table if the device is already mounted. So I could not find a way to online-resize a “plain partition”. (Please let me know if I missed something.)

Anoter note: resizing SW-RAID5 is possible with CONFIG_MD_RAID5_RESHAPE and kernel 2.6.17.

BTW: you should know Zugschlus’ german notes regarding LVM.

Comments are closed.