0

trying to erase only 1st superblock and two other backup superblocks (on ext4 fs), excluding MBR (seek=1) using dd cmd:

here is info about fs: sector=512bytes; block size=4096; Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912

Superblock is of 1 block size (which is 4k ) Superblock starts right after boot block MBR (512 bytes)

man dd says:

seek=N: skip N obs-sized blocks at start of output (obs is 512bytes default)

I'm not quite sure what number should be 'seek' parameter: 1st superblock

dd if=/dev/zero of=/path/to/partition count=1 seek=1 bs=4096

2nd superblock - seek will equal to 64 (32768 / 512 ) ?

dd if=/dev/zero of=/path/to/partition count=1 seek=64 bs=4096

3rd superblock - seek will equal to 192 (98304 / 512 )?

dd if=/dev/zero of=/path/to/partition count=1 seek=192 bs=4096

dumpe2fs output:

Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          8eca40e7-fc3c-43b0-b480-4e96aab5068c
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              131072
Block count:              524032
Reserved block count:     26201
Free blocks:              506067
Free inodes:              131060
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      255
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Tue Aug 22 08:55:26 2023
Last mount time:          n/a
Last write time:          Tue Aug 22 12:05:35 2023
Mount count:              0
Maximum mount count:      -1
Last checked:             Tue Aug 22 10:26:26 2023
Check interval:           0 (<none>)
Lifetime writes:          2138 kB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:           256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      d76982f6-3c1b-42aa-a227-c0b3f594c687
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0xdf9552a4
dumpe2fs: A block group is missing an inode table while reading journal inode

when trying to mount:

mount: /mnt: mount(2) system call failed: Structure needs cleaning.

so to recover the fs, using for example 2sd (erased) backup superblock, it should not work:

e2fsck -b 98304 /path/to/paritition

output is:

e2fsck 1.45.5 (07-Jan-2020)
/dev/sdb1 was not cleanly unmounted, check forced.
Resize inode not valid.  Recreate<y>? yes
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #0 (24280, counted=24281).
Fix<y>? yes
Free blocks count wrong for group #1 (32511, counted=32510).
Fix<y>? yes
Free inodes count wrong for group #0 (8181, counted=8179).
Fix<y>? yes
Free inodes count wrong (131061, counted=131059).
Fix<y>? yes
Padding at end of inode bitmap is not set. Fix<y>? yes

/dev/sdb1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdb1: 13/131072 files (0.0% non-contiguous), 17965/524032 blocks

But I can mount fs and fsck gives me this:

fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
/dev/sdb1: clean, 13/131072 files, 17965/524032 blocks

Are above calculations right? Thanks for suggestions

0 Answers0