tytso / e2fsprogs

Ext2/3/4 file system utilities
http://ext4.wiki.kernel.org
381 stars 223 forks source link

e2fsck isn't working for NVMe drive #196

Closed nerdatwork closed 1 month ago

nerdatwork commented 2 months ago

I am unable to successfully execute fsck for a 4TB NVMe drive.

$sudo e2fsck -f /dev/nvme0n1p1
e2fsck 1.47.1 (20-May-2024)
drive3: recovering journal
Superblock needs_recovery flag is clear, but journal has data.
Run journal anyway<y>? yes to all
e2fsck: unable to set superblock flags on drive3

drive3: ********** WARNING: Filesystem still has errors **********

$sudo e2fsck -b 512000000 /dev/nvme0n1p1
e2fsck 1.47.1 (20-May-2024)
Superblock needs_recovery flag is clear, but journal has data.
Recovery flag not set in backup superblock, so running journal anyway.
drive3: recovering journal
Superblock needs_recovery flag is clear, but journal has data.
Recovery flag not set in backup superblock, so running journal anyway.
Superblock needs_recovery flag is clear, but journal has data.
Recovery flag not set in backup superblock, so running journal anyway.
e2fsck: unable to set superblock flags on drive3

I tried using backup superblocks but they all fail with above output. The drive has around 80GB of data.

nvme0n1     259:0    0   3.6T  0 disk
└─nvme0n1p1 259:1    0   3.6T  0 part /mnt/drive3

Please help me fix this issue.

tytso commented 1 month ago

This error message is coming from the following code path in e2fsck:

                        if (ctx->flags & E2F_FLAG_RESTARTED) {
                                /*                                                     
                                 * Whoops, we attempted to run the                     
                                 * journal twice.  This should never                   
                                 * happen, unless the hardware or                      
                                 * device driver is being bogus.                       
                                 */
                                com_err(ctx->program_name, 0,
                                        _("unable to set superblock flags "
                                          "on %s\n"), ctx->device_name);
                                fatal_error(ctx, 0);
                        }

In other words, it looks like e2fsck attempted to write to the primary superblock, and that write is apparently not being persisted. What I would suggest doing is to obtaining another 4TB drive, and then using a tool like ddrescue to copy the file system image to the new hardware, and then try running e2fsck on that new drive.