2

An ext2 filesystem can be resized - as long as the underlying block device can be resized - but not ONLINE.

However, as another posting of mine has showed, if the ext2 filesystem is mounted as ext4 then resize2fs will not give an errormessage.

System information:

  • Red Hat Enterprise Linux Server release 6.4 (Santiago)
  • e2fsprogs-1.41.12-14.el6_4.2.x86_64

Recreate (example with an LVM block device ("disk"):

Create a block device and an ext2 filesystem (default for mke2fs in RedHat 6)

[root@myServer ~]# lvcreate -L 8M -n test3 vg_myServer
  Logical volume "test3" created
[root@myServer ~]# mke2fs /dev/mapper/vg_myServer-test3
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=4 blocks, Stripe width=0 blocks
2048 inodes, 8192 blocks
409 blocks (4.99%) reserved for the super user
First data block=1
Maximum filesystem blocks=8388608
1 block group
8192 blocks per group, 8192 fragments per group
2048 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

    # verify by checking the block ID
[root@myServer ~]# blkid /dev/mapper/vg_myServer-test3 | grep ext
/dev/mapper/vg_myServer-test3: UUID="97a46d2c-e157-46ec-a942-2df0d07eb39f" TYPE="ext2"

Mount the filesystem

    # Create a mount point and mount the file system
[root@myServer ~]# mkdir -p /mnt/test3
[root@myServer ~]# mount -t ext4 /dev/mapper/vg_myServer-test3 /mnt/test3/

    # See that mount percieves the filesystem as "ext4"
[root@myServer ~]# mount | grep test3
/dev/mapper/vg_myServer-test3 on /mnt/test3 type ext4 (rw)

Fill the filesystem to capacity

[root@myServer ~]# dd if=/dev/zero of=/mnt/test3/largefile bs=1024 count=8000
dd: writing `/mnt/test3/largefile': No space left on device
7849+0 records in
7848+0 records out
8036352 bytes (8.0 MB) copied, 2.22541 s, 3.6 MB/s

    # Verify
[root@myServer ~]# df -P /dev/mapper/vg_myServer-test3
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/mapper/vg_myServer-test3     7931     7926      0      100% /mnt/test3

Extend the block device / LVM, and resize

[root@myServer ~]# lvextend -L +8M /dev/mapper/vg_myServer-test3
  Extending logical volume test3 to 16.00 MiB
  Logical volume test3 successfully resized

    # Perform a resize, _without_ umount
[root@myServer ~]# resize2fs /dev/mapper/vg_myServer-test3
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_myServer-test3 is mounted on /mnt/test3; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/vg_myServer-test3 to 16384 (1k) blocks.
The filesystem on /dev/mapper/vg_myServer-test3 is now 16384 blocks long.

Verify - the filesystem thinks the filesystem is extended

[root@myServer ~]# df /dev/mapper/vg_myServer-test3
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_myServer-test3   15863      7957      7089  53% /mnt/test3

Create a second "large" file

[root@myServer ~]# dd if=/dev/zero of=/mnt/test3/largefile2 bs=1024 count=8000
dd: writing `/mnt/test3/largefile2': No space left on device
5230+0 records in
5229+0 records out
5354496 bytes (5.4 MB) copied, 0.280078 s, 19.1 MB/s

    # Verify that the OS sees the FS as 88% full - but unable to write any more
[root@myServer ~]# df -P /dev/mapper/vg_myServer-test3
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/mapper/vg_myServer-test3     15863     13227      1819      88% /mnt/test3

umount/mount and do an fsck on the filesystem

[root@myServer ~]# umount /dev/mapper/vg_myServer-test3
[root@myServer ~]# mount -t ext4 /dev/mapper/vg_myServer-test3 /mnt/test3/

    # FS suddenly has less usage...
[root@myServer ~]# df -P /dev/mapper/vg_myServer-test3
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/mapper/vg_myServer-test3     15863      7963      7083      53% /mnt/test3

    # Perfor an fsck after an umount, then mount again
[root@myServer ~]# umount /dev/mapper/vg_myServer-test3
[root@myServer ~]# e2fsck -f /dev/mapper/vg_myServer-test3
e2fsck 1.41.12 (17-May-2010)
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/mapper/vg_myServer-test3: 13/4096 files (15.4% non-contiguous), 8484/16384 blocks
[root@myServer ~]# mount -t ext4 /dev/mapper/vg_myServer-test3 /mnt/test3/

What size do we have now?

    # Same as before the fsck
[root@myServer ~]# df -P /dev/mapper/vg_myServer-test3
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/mapper/vg_myServer-test3     15863      7963      7083      53% /mnt/test3

    # A bit strange, the 8MB file and an 5MB file...?
[root@myServer ~]# ls -ld /mnt/test3/large*
-rw-r--r--. 1 root root 8036352 Jun 18 09:54 /mnt/test3/largefile
-rw-r--r--. 1 root root 5354496 Jun 18 09:55 /mnt/test3/largefile2

Try to create a second large file

    # Fill up again
[root@myServer ~]# dd if=/dev/zero of=/mnt/test3/largefile2 bs=1024 count=8000
dd: writing `/mnt/test3/largefile2': No space left on device
7870+0 records in
7869+0 records out
8057856 bytes (8.1 MB) copied, 2.43879 s, 3.3 MB/s

    # "largefile2" has increased in size - OK
[root@myServer ~]# ls -ld /mnt/test3/large*
-rw-r--r--. 1 root root 8036352 Jun 18 09:54 /mnt/test3/largefile
-rw-r--r--. 1 root root 8057856 Jun 18 10:12 /mnt/test3/largefile2

    # We are again at capacity
[root@myServer ~]# df -P /dev/mapper/vg_myServer-test3
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/mapper/vg_myServer-test3     15863     15858         0     100% /mnt/test3

And the FS is (of course) still an ext2 filesystem

    # Still an "ext2" filesystem
[root@myServer ~]# blkid /dev/mapper/vg_myServer-test3
/dev/mapper/vg_myServer-test3: UUID="97a46d2c-e157-46ec-a942-2df0d07eb39f" TYPE="ext2"

    # But mounted as "ext4"
[root@myServer ~]# mount | grep /dev/mapper/vg_myServer-test3
/dev/mapper/vg_myServer-test3 on /mnt/test3 type ext4 (rw)

If the filesystem is mounted as ext2 you get an error message (correctly) when trying to resize

[root@myServer ~]# umount /dev/mapper/vg_myServer-test3
[root@myServer ~]# mount -t ext2 /dev/mapper/vg_myServer-test3 /mnt/test3/
[root@myServer ~]# lvextend -L +8M /dev/mapper/vg_myServer-test3
  Extending logical volume test3 to 24.00 MiB
  Logical volume test3 successfully resized
[root@myServer ~]# resize2fs /dev/mapper/vg_myServer-test3
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_myServer-test3 is mounted on /mnt/test3; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
resize2fs: Kernel does not support online resizing

I know that the ext4 filesystem driver can mount ext2 - which is fine if you are on a system without the ext2 driver.

Question: Is this a bug or a feature - meaning that resize2fs does not give an error message? If so, is it in resize2fs?

1 Answer 1

2

You're using ancient version of e2fsprogs.

Please upgrade, there've been bazzilion of fixes since 1.41.12 (17-May-2010)

1
  • We follow the upstream from RedHat, which is now at e2fsprogs-1.41.12-14.el6_4.2.x86_64
    – sastorsl
    Aug 19, 2013 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .