* [PATCH] '-b superblock' flag for tune2fs
@ 2003-03-22 18:39 Josh Glover
0 siblings, 0 replies; only message in thread
From: Josh Glover @ 2003-03-22 18:39 UTC (permalink / raw)
To: linux-fsdevel
[-- Attachment #1.1: Type: text/plain, Size: 2070 bytes --]
I searched the archives of this list, as well as a general Google search,
and found nothing to suggest that this has been suggested and dismissed as
a bad idea, so here goes:
The attached patch adds the '-b superblock' flag to tune2fs. The flag works
exactly like the '-b superblock' flag to e2fsck:
-b superblock
Instead of using the normal superblock, use an alternative
superblock specified by superblock. This option is normally
used when the primary superblock has been corrupted. The loca-
tion of the backup superblock is dependent on the filesystem's
blocksize. For filesystems with 1k blocksizes, a backup
superblock can be found at block 8193; for filesystems with 2k
blocksizes, at block 16384; and for 4k blocksizes, at block
32768.
Additional backup superblocks can be determined by using the
mke2fs program using the -n option to print out where the
superblocks were created. The -b option to mke2fs, which spec-
ifies blocksize of the filesystem must be specified in order for
the superblock locations that are printed out to be accurate.
If an alternative superblock is specified and the filesystem is
not opened read-only, e2fsck will make sure that the primary
superblock is updated appropriately upon completion of the
filesystem check.
So, you could run 'tune2fs -b 16384 -l /dev/hda1' on a filesystem with a
blocksize of 2K and a block group size of 16384 to look at the first of
the backup superblocks on the filesystem.
I found this flag to be useful, but YMMV, of course. As noted in the patch
filename, I generated the patch against version 1.32 of e2fsprogs.
Cheers,
Josh
--
Josh Glover <jmglov@incogen.com>
Associate Systems Administrator
INCOGEN, Inc.
http://www.incogen.com/
GPG keyID 0x62386967 (7479 1A7A 46E6 041D 67AE 2546 A867 DBB1 6238 6967)
gpg --keyserver pgp.mit.edu --recv-keys 62386967
[-- Attachment #1.2: e2fsprogs-1.32_tune2fs_alt-superblock.patch --]
[-- Type: text/plain, Size: 4367 bytes --]
diff -uNr e2fsprogs-1.32/misc/tune2fs.8.in 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.8.in
--- e2fsprogs-1.32/misc/tune2fs.8.in 2002-10-25 17:31:08.000000000 -0400
+++ 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.8.in 2003-03-22 13:13:05.000000000 -0500
@@ -8,6 +8,10 @@
.SH SYNOPSIS
.B tune2fs
[
+.B \-b
+.I superblock
+]
+[
.B \-l
]
[
@@ -87,6 +91,32 @@
adjusts tunable filesystem parameters on a Linux second extended filesystem.
.SH OPTIONS
.TP
+.BI \-b " superblock"
+Instead of using the normal superblock, use an alternative superblock
+specified by
+.IR superblock .
+This option is normally used when the primary superblock has been
+corrupted. The location of the backup superblock is dependent on the
+filesystem's blocksize. For filesystems with 1k blocksizes, a backup
+superblock can be found at block 8193; for filesystems with 2k
+blocksizes, at block 16384; and for 4k blocksizes, at block 32768.
+.IP
+Additional backup superblocks can be determined by using the
+.B mke2fs
+program using the
+.B \-n
+option to print out where the superblocks were created. The
+.B \-b
+option to
+.BR mke2fs ,
+which specifies blocksize of the filesystem must be specified in order
+for the superblock locations that are printed out to be accurate.
+.IP
+If an alternative superblock is specified and
+the filesystem is not opened read-only, e2fsck will make sure that the
+primary superblock is updated appropriately upon completion of the
+filesystem check.
+.TP
.BI \-c " max-mount-counts"
Adjust the maximal mounts count between two filesystem checks. If
.I max-mount-counts
diff -uNr e2fsprogs-1.32/misc/tune2fs.c 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.c
--- e2fsprogs-1.32/misc/tune2fs.c 2002-10-15 17:44:46.000000000 -0400
+++ 0_JMGLOV_e2fsprogs-1.32/misc/tune2fs.c 2003-03-22 13:06:56.000000000 -0500
@@ -58,6 +58,7 @@
char * new_label, *new_last_mounted, *new_UUID;
static int c_flag, C_flag, e_flag, f_flag, g_flag, i_flag, l_flag, L_flag;
static int m_flag, M_flag, r_flag, s_flag = -1, u_flag, U_flag, T_flag;
+static int b_flag = 0;
static time_t last_check_time;
static int print_label;
static int max_mount_count, mount_count, mount_flags;
@@ -78,9 +79,8 @@
static void usage(void)
{
fprintf(stderr,
- _("Usage: %s [-c max-mounts-count] [-e errors-behavior] "
- "[-g group]\n"
- "\t[-i interval[d|m|w]] [-j] [-J journal-options]\n"
+ _("Usage: %s [-b superblock] [-c max-mounts-count] [-e errors-behavior]\n "
+ "\t[-g group] [-i interval[d|m|w]] [-j] [-J journal-options]\n"
"\t[-l] [-s sparse-flag] [-m reserved-blocks-percent]\n"
"\t[-o [^]mount-options[,...]] [-r reserved-blocks-count]\n"
"\t[-u user] [-C mount-count] [-L volume-label] "
@@ -462,9 +462,12 @@
struct passwd * pw;
printf("tune2fs %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE);
- while ((c = getopt(argc, argv, "c:e:fg:i:jlm:o:r:s:u:C:J:L:M:O:T:U:")) != EOF)
+ while ((c = getopt(argc, argv, "b:c:e:fg:i:jlm:o:r:s:u:C:J:L:M:O:T:U:")) != EOF)
switch (c)
{
+ case 'b':
+ b_flag = atoi(optarg);
+ break;
case 'c':
max_mount_count = strtol (optarg, &tmp, 0);
if (*tmp || max_mount_count > 16000) {
@@ -712,15 +715,27 @@
else
parse_tune2fs_options(argc, argv);
- retval = ext2fs_open (device_name, open_flag, 0, 0,
- unix_io_manager, &fs);
- if (retval) {
- com_err (program_name, retval, _("while trying to open %s"),
- device_name);
- fprintf(stderr,
- _("Couldn't find valid filesystem superblock.\n"));
- exit(1);
- }
+ if (b_flag) {
+ int blocksize;
+ for (blocksize = EXT2_MIN_BLOCK_SIZE;
+ blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) {
+ retval = ext2fs_open (device_name, open_flag, b_flag, blocksize,
+ unix_io_manager, &fs);
+ if (!retval)
+ break;
+ }
+ } else {
+ retval = ext2fs_open (device_name, open_flag, 0, 0,
+ unix_io_manager, &fs);
+ if (retval) {
+ com_err (program_name, retval, _("while trying to open %s"),
+ device_name);
+ fprintf(stderr,
+ _("Couldn't find valid filesystem superblock.\n"));
+ exit(1);
+ }
+ }
+
sb = fs->super;
if (print_label) {
/* For e2label emulation */
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-03-22 18:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-22 18:39 [PATCH] '-b superblock' flag for tune2fs Josh Glover
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).