Skip to contentSkip to conversation

tune2fs: allow removal of dirty journal with two "-f" options

PATCH Applied Eric Sandeen 2 participants 2 messages Jan 9, 2014 – Feb 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tune2fs: allow removal of dirty journal with two "-f" options

Jim pointed out that "tune2fs -f -O ^has_journal" won't remove the journal if the needs_recovery flag is set; the manpage seems to indicate that it should. And if you've lost an external journal and can no longer replay it, how should one proceed?

Change tune2fs so that two "-f" options will allow removal of a dirty journal from a filesystem, even if the filesystem needs recovery.

e2fsck can then do its best to pick up the pieces.

---

misc/tune2fs.8.in +4 -1
index da21080..e07da28 100644
@@ -248,7 +248,10 @@ option is useful when removing the
 filesystem feature from a filesystem which has 
 an external journal (or is corrupted
 such that it appears to have an external journal), but that 
-external journal is not available.   
+external journal is not available.   If the filesystem appears to require
+journal replay, the
+.B \-f
+flag must be specified twice to proceed.
 .sp
 .B WARNING:
 Removing an external journal from a filesystem which was not cleanly unmounted
misc/tune2fs.c +4 -3
index 0eddf6d..2318dbb 100644
@@ -903,8 +903,9 @@ static int update_feature_set(ext2_filsys fs, char *features)
 				"read-only.\n"), stderr);
 			return 1;
 		}
-		if (sb->s_feature_incompat &
-		    EXT3_FEATURE_INCOMPAT_RECOVER) {
+		if ((sb->s_feature_incompat &
+		    EXT3_FEATURE_INCOMPAT_RECOVER) && 
+		    f_flag < 2) {
 			fputs(_("The needs_recovery flag is set.  "
 				"Please run e2fsck before clearing\n"
 				"the has_journal flag.\n"), stderr);
@@ -1428,7 +1429,7 @@ static void parse_tune2fs_options(int argc, char **argv)
 			open_flag |= EXT2_FLAG_RW;
 			break;
 		case 'f': /* Force */
-			f_flag = 1;
+			f_flag++;
 			break;
 		case 'g':
 			resgid = strtoul(optarg, &tmp, 0);
#1 lore raw
Quoted 5 lines · Eric Sandeen

Jim pointed out that "tune2fs -f -O ^has_journal" won't remove the journal if the needs_recovery flag is set; the manpage seems to indicate that it should. And if you've lost an external journal and can no longer replay it, how should one proceed?

Quoted 7 lines

Change tune2fs so that two "-f" options will allow removal of a dirty journal from a filesystem, even if the filesystem needs recovery.

e2fsck can then do its best to pick up the pieces.

Thanks, applied.

- Ted