Corrupted file system, not boot, no mount

Hi,
I’ve made the mistake of the year already. I wanted to clean a disk and issued

if=/dev/zero of=/dev/sda

of course that wasn’t the right disk and i stopped the program quickly. but the damaged was done. the system was working fine until I restart the computer. i’m trying to repair, or at least get the data back. But so far no boot, no mount.

I’m trying to find info on my own but any help would be highly appreciated.

Disk /dev/sdf: 931,51 GiB, 1000204884992 bytes, 1953525166 sectors
Disk model: Storage Device  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start        End    Sectors   Size Id Type
/dev/sdf1  *     2048 1935067135 1935065088 922,7G 83 Linux

fsck from util-linux 2.40.2
e2fsck 1.47.1 (20-May-2024)
Superblock has an invalid journal (inode 8).
Clear<y>? cancelled!
fsck.ext4: The journal superblock is corrupt while checking journal for /dev/sdf1
e2fsck: Cannot proceed with file system check

/dev/sdf1: ********** WARNING: Filesystem still has errors **********

thanks

Hi @catapult,

This has saved my @$$ in the past, I’m sure it can yours, as well:

2 Likes

thanks

I’m reading imformation about testdisk and fsck.

1 Like

You mean you did:
dd if=/dev/zero of=/dev/sda ?

But then you speak of /dev/sdf instead.

Which one did you “zero out”?

If you use dd to the device then I’d expect all the partition information to be gone, even after the command running only a short time.

You can run e2fsck in verbose (-v switch) mode
and also provide a different superblock (-b switch) if the first one is faulty or non existent anymore.

man e2fsck

But none of that will work when part of the file system is literally wiped out by writing zeroes to the device.
Such a file system can’t be restored using e2fsck (as far as I know).

Your only option might be testdisk like @Mirdarthos said.

2 Likes

I was using the system on sda, the system was runing when I issued the command on the same drive (sda)

now I have the drive externally plugged through another system. sorry for the confusion.

I don’t care much about the system per se, it can be rebuild. I care much more about some of the datas.

e2fsck 1.47.1 (20-May-2024)
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/sdf

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>

/dev/sdf contains `DOS/MBR boot sector; partition 1 : ID=0x83, active, start-CHS (0x0,32,33), end-CHS (0x3ff,254,63), startsector 2048, 1935065088 sectors' data

I would first clone the disk if you have a disk available for this. Otherwise you risk that your attempts to save data make it worse and you lose all. testdisk is the right approach. Also, have a look here:

https://wiki.archlinux.org/title/File_recovery

2 Likes

If you only had one partition on it (not a separate one for /home for example).
then testdisk or a similar program might be your only option
and the process will be long and tedious.
(the files will be there, on the not overwritten portion of the drive, but without a name to them …)

If you had /home on a separate partition, then testdisk might be able to find and restore that.

Trying to use e2fsck to repair it is very likely a hopeless endeavour, unfortunately.

thanks for your quick answers !

the output of testdisk after a quick search :woozy_face:

   * Linux                    0  32 33 120452  91 23 1935065088
Directory /

No file found, filesystem may be damaged.

could the harddrive be used again with a full clean install ?

Yes, dd is only writing data but not damaging the disk. You would need a new partition table and a repartitioning.

thanks,

I’ll try to do stuff not to much time consuming but this is above my grade.

Is there a way to prevent that to happen ? making a copy of the partition table and the boot file somewhere on the disk that can be recalled ?

2025 i’ll the year i start to make backups…

Yes - but that copy will not help you when you use dd like you did and then stop it after a random short time - you have no control over how much has been written in the meantime.
It’s certainly more than just the boot sector.

dd - ArchWiki

The only thing that really helps is having backups of the files you care about.

If you feel the value of your data warrants it, the best advice might be to seek the services of recovery professionals – this is not cheap – however, will likely provide a better chance of success.

Regards.

I decided to remake a full system. Lesson learned, I’ll add a second drive for data storage. I’ll aslo be more careful next time I do things with harddrive, either using another PC or removing the main drive and booting from a usblive.
thanks for the help !

1 Like

As long as you learnt it.

1 Like

This would not help against dd (to the wrong drive)

Please be very careful when using commands that use a drive or partition directly, such as

  • /dev/xxxx

These things are usually extremely dangerous. (Especially when you consider that the names for /dev/xxxx can change every time you boot, and thus disks can appear with swapped names.)

What helps are: backups, backups, backups and sometimes snapshots. :footprints:

5 Likes