ext2 文件系统可以调整大小 - 只要底层块设备可以调整大小 - 但不能在线调整。
然而,正如我的另一篇帖子所显示的那样,如果ext2
文件系统安装就像ext4
那时resize2fs
一样不是给出错误信息。
系统信息:
Red Hat Enterprise Linux Server release 6.4 (Santiago)
e2fsprogs-1.41.12-14.el6_4.2.x86_64
重新创建(以 LVM 块设备(“磁盘”)为例):
创建块设备和 ext2 文件系统(RedHat 6 中 mke2fs 的默认设置)
[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"
挂载文件系统
# 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)
填充文件系统至容量
[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
扩展块设备/LVM,并调整大小
[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.
验证-文件系统想文件系统已扩展
[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
创建第二个“大”文件
[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
卸载/挂载并对文件系统进行 fsck
[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/
我们现在有多大尺寸?
# 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
尝试创建第二个大文件
# 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
FS(当然)仍然是 ext2 文件系统
# 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)
如果文件系统已挂载,则ext2
在尝试调整大小时收到错误消息(正确)
[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
我知道ext4
文件系统驱动程序可以挂载 ext2 - 如果您使用的系统没有该ext2
驱动程序,那么这没问题。
问题:这是一个错误还是特征- 意思是 resize2fs 没有给出错误信息?如果是的话,是在 吗resize2fs
?
答案1
您正在使用旧版本的 e2fsprogs。
请升级,已经有大量的修复自 1.41.12 起(2010 年 5 月 17 日)