On Fri, May 08, 2009 at 08:39:53PM -0400, Andres Salomon wrote: > Package: e2fsprogs > Version: 1.41.3-1 > > If I attempt to shrink an ext3 filesystem while mounted (even if > read-only) via "resize2fs /dev/hda1 8G", it refuses with: > > "Filesystem at /dev/hda1 is mounted on /; on-line resizing required > On-line shrinking from $foo to $bar not supported." > > I don't know if this is a necessary restriction or not, but it's pretty > annoying. If it is safe to do when the fs is mounted read-only, it > would be nice if '-f' allowed one to bypass the check.
Well, it could cause the system to panic and reboot while resize2fs is in the middle of resizing the filesystem --- is that unsafe enough? :-) That's pretty extreme, and it's a pretty low-probability event, but it's definitely within the realm of possibility. If you have the filesystem set up to reboot if a filesystem corruption is detected, it's even more likely. Also note that if you are short on memory, and the system is paging, any program currently running on the system which you are shrinking (possibly including resize2fs itself) could end up reading in trash blocks, which could cause that program to crash. And while resize2fs tries very hard not to leave the filesystem corrupted if it or the system crashes while it is running, there are certain operations which could lead to data loss. > Furthermore, if one boots into an initramfs (booting with 'break=mount') > in order to resize the filesystem, mounts /dev/hda1, copies resize2fs > and associated libs into the initramfs root, unmounts /dev/hda1, and > then attempts to shrink the filesystem, one gets: > > "ext2fs_check_mount_point: No such file or directory while determining > whether /dev/hda1 is mounted." > > Even using '-f' doesn't allow it to continue. This is amazingly > unhelpful. The code in lib/ext2fs/ismounted.c checks /proc/mounts for > the filesystem, doesn't find anything interesting, attempts to > check /etc/mtab (which doesn't exist because we're in an initramfs), > and returns ENOENT. > > Please consider the following patch to allow the administrator to > override the failed mount point check using the -f option. It would be > even better if that check could be made to not happen at all w/ -f (or > some other argument). So I'm extremely uncomfortable with this. I would much rather have initramfs create a zero-length /etc/mtab file in the inital ramdisk image, or better yet, have a fully supported and supportable system which allows users to shrink the root filesystem. For example, we could have a script fragment that checks for the existence of a file which matches the pattern /on-initrd-*.tar.gz, and if one or more such files exists, they are copied to the initrd, and then the root filesystem is unmountd, and one by one, the on-initrd-*.tar.gz files are unpacked and the /on-initrd script contained in the tar.gz file is executed. This could be used to perform an off-line shrink of the root partition, by having the user request such a thing, and then rebooting, and having it happen automatically. It could also be used to add or remove a journal safely, as well as repack and optimize directories (e2fsck -fD). Another approach would be to resize the filesystem using a rescue CD. The reason why I suggest these is they are in the long-term much more supportable. If a user doesn't know enough to work around the "ext2fs_check_mount_point: No such file or directory while determining whether /dev/hda1 is mounted" error by using "touch /etc/mtab", do we really want to trust him or her with using resize2fs -f? What if they use it when they shouldn't, and end up trashing their own filesystem? I've already had a bug filed by an Ubuntu user who saw this error message: /dev/ssd/root is mounted. WARNING!!! Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage. Do you really want to continue (y/n)? ... and they were clueless enough to answer yes, and then when his filesystem was severly damanged (as promised) he filed a bug complaining about the fact. "Resize2fs -f" is even easier for said user to screw up. If I did anything at all, I'd be severly tempted to make the user type something like: Warning! An attempt to resize /dev/XXX while it is mounted may cause your system to crash and your filesystem to be destroyed. To continue please type: 'I ACCEPT ALL LIABILITY FOR TRASHING MY FILESYSTEM AND PROMISE NOT TO FILE A BUG'. Or, if your /etc/mtab file is in error or missing, type ^C, fix it by hand, and rerun re2size2fs: " ... and only continue if the user types the required string. :-) - Ted -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org