linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, Andreas Dilger <adilger@dilger.ca>
Subject: [PATCH] mke2fs: prompt for user verification for "-S"
Date: Fri, 22 May 2015 16:43:08 -0600	[thread overview]
Message-ID: <1432334588-18387-1-git-send-email-adilger@dilger.ca> (raw)

Prompt for user verification before rewriting the filesystem
superblocks using the "-S" (super-only) option.  This should
not normally be used at all, so adding the extra verification
will probably save a few user filesystems in the future.  Since
this is something that should only be done in rare cases under
user supervision, wait for user input rather than proceeding
automatically after a timeout.

Update the mke2fs man page to more fully explain the many
dangers of this option.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
---
 misc/mke2fs.8.in |   24 ++++++++++++++++--------
 misc/mke2fs.c    |    7 ++++++-
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 1002eae..2a50ad2 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -619,18 +619,26 @@ kernels only support revision 0 filesystems.  The default is to
 create revision 1 filesystems.
 .TP
 .B \-S
-Write superblock and group descriptors only.  This is useful if all of
+Write superblock and group descriptors only.  This is an extreme
+measure to be taken only in the very unlikely case that all of
 the superblock and backup superblocks are corrupted, and a last-ditch
-recovery method is desired.  It causes
+recovery method is desired by experienced users.  It causes
 .B mke2fs
-to reinitialize the
-superblock and group descriptors, while not touching the inode table
-and the block and inode bitmaps.  The
+to reinitialize the superblock and group descriptors, while not
+touching the inode table and the block and inode bitmaps.  The
 .B e2fsck
 program should be run immediately after this option is used, and there
-is no guarantee that any data will be salvageable.  It is critical to
-specify the correct filesystem blocksize when using this option,
-or there is no chance of recovery.
+is no guarantee that any data will be salvageable.  Due to the wide
+variety of possible options to
+.BR mke2fs
+that affect the on-disk layout, is critical to specify exactly the same
+the same format options, such as blocksize, fs-type, feature flags, and
+other tunables when using this option, or the filesystem will be further
+corrupted.  In some cases, such as filesystems that have been resized,
+or have had features enabled after format time, it is impossible to
+overwrite all of the superblocks corretly, and at least some filesystem
+corruption will occur.  It is best to run this on a full copy of the
+filesystem so other options can be tried if this doesn't work.
 .\" .TP
 .\" .BI \-t " test"
 .\" Check the device for bad blocks before creating the file system
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index a14e62e..e49ad04 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -2771,9 +2771,14 @@ int main (int argc, char *argv[])
 	}
 
 	if (super_only) {
+		check_plausibility(device_name, CHECK_FS_EXIST, NULL);
+		printf(_("%s may be further corrupted by superblock rewrite\n"),
+		       device_name);
+		if (!force)
+			proceed_question(proceed_delay);
 		fs->super->s_state |= EXT2_ERROR_FS;
 		fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY);
-		/* 
+		/*
 		 * The command "mke2fs -S" is used to recover
 		 * corrupted file systems, so do not mark any of the
 		 * inodes as unused; we want e2fsck to consider all
-- 
1.7.3.4


             reply	other threads:[~2015-05-22 22:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 22:43 Andreas Dilger [this message]
2015-06-20  1:38 ` [PATCH] mke2fs: prompt for user verification for "-S" Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432334588-18387-1-git-send-email-adilger@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).