Score:0

Fixing bad superblock on SSD drive: Is e2fsck safe to run?

pk flag

The symptoms:

I cannot boot anymore into my Xubuntu 22.04 Linux machine, and here's what happened:

At some point my home directory filesystem went into read-only (most likely as a protective measure, from what I can gather). I then rebooted, thinking it was a one-time glitch, but that is not the case: It failed to boot with journaling errors on my /dev/sdb disk (which is where I have stored my home directory, separate from the OS which is on /dev/sda).

I am able to reboot into my installation USB, and mount both /dev/sda and /dev/sdb. When running fsck, it errors out with:

# fsck /dev/sdb
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/sdb

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Found a gpt partition table in /dev/sdb

I've since backed up my home directory on that drive back to /dev/sda which seems to be working, although with errors transferring some files that I can recreate.

The question:

I'm thinking about trying to repair the /dev/sdb drive using these instructions:

https://askubuntu.com/a/1335193/340383

But it scared me away with this sentence which gave no explanation as to why:

Note: do NOT bad block a SSD

So, in that answer, they mentioned running:

sudo e2fsck -fccky /dev/sdXX # non-destructive read/write test (recommended)

where, in my case, I speculate would need to be:

sudo e2fsck -fccky /dev/sdb1

Is that going to harm my ability to repair this issue with /dev/sdb, or is it is harmless and a true non-destructive test?

Given the answer here:

https://askubuntu.com/a/1233241/340383

and the OP's question where they implied they succeeded in using e2fsck, I'm concluding it is safe to proceed. Is it?

Sub-question:

Also, I do not know what this part of the output of fsck is trying to communicate:

Found a gpt partition table in /dev/sdb

Is that telling me that I'm running fsck incorrectly? I don't want to follow that advice in the output by trying different superblocks until I confirm that this is not just my own user-error.

2023-07-02 09:08:57: Running sudo e2fsck -C0 -p -f -v /dev/sdb1

At comment, I followed the advice of Ubuntu 14.04 is not booting normaly after a manual hard boot via (this was after a unmounting of /dev/sda* and /dev/sdb* drives):

sudo e2fsck -C0 -p -f -v /dev/sdb1

And got:

Inode898044343 extent tree (at level 2) could be narrower.  IGNORED.0.1%
DRIVE8: Inode 103942010 extent tree (at level 2) could be narrower.  IGNORED.
DRIVE8: Inode 103942011 extent tree (at level 2) could be narrower.  IGNORED.
 ... <snip mostly duplicate types of output lines here> ...
DRIVE8: Inode 103942324 extent tree (at level 1) could be narrower.  IGNORED.
Inodes:that=were=part=of=a=corrupted=orphan linked list found.   / 59.7%
DRIVE8: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
    (i.e., without -a or -p options)
oldfred avatar
cn flag
You do not run fsck on a drive like sdb, but on a partition that is ext4 formatted like sdb1, if that is your ext4 partition. I typically suggest two versions, so you do not have to press y on errors which possibly could require many y presses. https://askubuntu.com/questions/642504/ubuntu-14-04-is-not-booting-normaly-after-a-manual-hard-boot/642789#642789
bgoodr avatar
pk flag
@oldfred I certainly will try that out, just as soon as I can get unblocked by a basic problem whereby I am inexplicably unable to even get the BIOS to select the boot order to the USB stick containing my bootable installation CD for Xubuntu, whereas I succeeded in doing so last week. I'm working with my laptop vendor's gurus to get me sorted out on that.
oldfred avatar
cn flag
If your UEFI has fast start up on, it assumes no system changes & immediately boots to last default, no time to press any keys. You should be able to do full power down,remove battery,hold power switch for 10 sec to drain all power & then boot & immediately press key(s) to get into UEFI settings. You may have UEFI Secure boot on or evne additional UEFI settings that prevent USB boot for "secuity" reasons. Now sure if that is on, with even a Windows only system how you boot a Windows recovery drive.
bgoodr avatar
pk flag
@oldfred My issue was not figuring out the keystrokes to get into the UEFI boot screens, but getting the UEFI screens to select the USB partition in the boot order. Not knowing that, I ended up re-burning the Xubuntu 22.04 ISO to the USB stick using "Rufus" app on my Windows 10 laptop, and retrying. ...
bgoodr avatar
pk flag
@oldfred ... I did not follow your sequence for "...remove battery..." etc.  I then doinked around for an hour in the UEFI menus only to finally figure out that I had to FUNDING double-click using the mouse on the boot order #1 in order to select the order: https://i.stack.imgur.com/zovIx.jpg  ...
bgoodr avatar
pk flag
@oldfred ... But I do believe that _also_ the USB stick was somehow damaged, maybe by myself, so reburning it was a good thing after all. Thanks for your advice here!
bgoodr avatar
pk flag
@oldfred And I will finally get into the https://askubuntu.com/questions/642504/ubuntu-14-04-is-not-booting-normaly-after-a-manual-hard-boot/642789#642789 link you mentioned and see how to proceed.
bgoodr avatar
pk flag
@oldfred I just inserted in **2023-07-02 09:08:57: Running sudo e2fsck -C0 -p -f -v /dev/sdb1** into the question at the end. That is pointing me back to running `fsck` which may bring me back full circle to the original problem with `fsck`. I'm running e2fsck with the -y option now and it fixed a ton of errors. I'll try rebooting to see if the /dev/sdb1 drive starts to be come functional again.
bgoodr avatar
pk flag
@oldfred Your advice worked! I am now able to boot back in without any "journal" issues. Whether or not I lost any precious data is orthogonal to this, so thank you. Please write up an answer and I'll mark it as The answer to this question.
Score:3
cn flag

You do not run fsck on a drive like sdb, but on a partition that is ext4 formatted like sdb1

From working live Flash drive, so everything is un mounted,swap off if necessary, change example shown with partition sdb1 to your partition(s) To see all the ext4 partitions

sudo parted -l

e2fsck is used to check the ext2/ext3/ext4 family of file systems. -p trys fixes where response not required Run both commands as different parameters used. New NVMe drives will be like /dev/nvme0n1pY where pY is partition. Both SATA & NVMe shown as an example, mostly for others:

sudo e2fsck -C0 -p -f -v /dev/sdb1
sudo e2fsck -C0 -p -f -v /dev/nvme0n1p2

if errors: -y auto answers yes for fixes needing response, also see man e2fsck

sudo e2fsck -f -y -v /dev/sdb1
sudo e2fsck -f -y -v /dev/nvme0n1p2
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.