FastNetMon

Tuesday, 19 March 2013

How to format mounted filesystem? VERY DANGER!

Are you knew about FULL DATA LOSS in this operation? Sure? Okay, we can proceed.

If you are certainly read mkfs.ext4 manual page (man mkfs.ext4), you can read this:
In order to force mke2fs to create a filesystem even if the filesystem appears to be in use or is mounted (a truly dangerous thing to do), this option must be specified twice.
It's fine, try it:
mkfs.ext4 -F -F /dev/XXX
Oops:
mke2fs 1.41.12 (17-May-2010)
/dev/ploop56106p1 is mounted; will not make a filesystem here! 
There are bug (?) in man page, I'm discovered source code and found it (Debian 6, e2fsprogs, misc/util.c):

       if (mount_flags & EXT2_MF_BUSY) {
                fprintf(stderr, _("%s is apparently in use by the system; "),
                        device);
                if (force > 2) {
                        fputs(_("mke2fs forced anyway.\n"), stderr);
                        return;
                }
                goto abort_mke2fs;
        }
Yeppp! We are need specify -F option triple times! -F -F -F


mke2fs 1.41.12 (17-May-2010)
/dev/ploop56106p1 is mounted; mke2fs forced anyway.  Hope /etc/mtab is incorrect.
fs_types for mke2fs.conf resolution: 'ext4', 'default'
/dev/ploop56106p1: Device or resource busy while setting up superblock

No comments :

Post a Comment

Note: only a member of this blog may post a comment.