Page 1 of 2

recover reformatted ext4 linux partition

Posted: 01 Dec 2019, 14:54
by eeee4
hello, i accidentally reformatted my ext4 storage drive in ubuntu using the disks utility. It was a quick format and only took a second to do. ive tried testdisk and found the partition and recovered it. but now it wont mount. i did get one error saying the sectors are 255 and perhaps should be 16 and that i could change it if i wanted. it read like this:

Error mounting /dev/sdc1 at /media/pc/UB1 2TB: Command-line `mount -t "ext4" -o "uhelper=udisks2,nodev,nosuid" "/dev/sdc1" "/media/pc/UB1 2TB"' exited with non-zero exit status 32: mount: wrong fs type, bad option, bad superblock on /dev/sdc1,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.

after seeing this i went forward and found the partition and clicked write to recover it. i only clicked write once and that was to recover the only partition that showed up. right now it wont mount but testdisk does give me info on the drive.

the error i get when i try to mount the drive is in ubuntu 16 is:

Error mounting /dev/sdc1 at /media/pc/UB1 2TB: Command-line `mount -t "ext4" -o "uhelper=udisks2,nodev,nosuid" "/dev/sdc1" "/media/pc/UB1 2TB"' exited with non-zero exit status 32: mount: wrong fs type, bad option, bad superblock on /dev/sdc1,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.

any help would be appreciated. thank you.

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 07:21
by cgrenier
Try TestDisk, Advanced, SuperBlock. It may give you some parameters to use fsck.ext4 to fix this partition.
If it doesn't work, try PhotoRec on the partition.

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 08:58
by eeee4
ok i ran superblock and got this?

Disk /dev/sdc - 2000 GB / 1863 GiB - CHS 243201 255 63

Partition Start End Size in sectors

Linux 0 1 1 243201 80 62 3907029104 [UB1 2TB]
superblock 0, blocksize=4096 [UB1 2TB]
superblock 32768, blocksize=4096 [UB1 2TB]
superblock 1605632, blocksize=4096 [UB1 2TB]
superblock 2654208, blocksize=4096 [UB1 2TB]
superblock 20480000, blocksize=4096 [UB1 2TB]

To repair the filesystem using alternate superblock, run
fsck.ext4 -p -b superblock -B blocksize device

i'm really in the dark here as far as my understanding of how this works but thanks for any help u can give.

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 09:01
by eeee4
some more info:

the drive is a 2tb toshiba drive that has only one ext4 2tb volume to recover

when i formatted the disk i did a quick format to ntfs (i made a mistake thinking this internal 2tb drive was my unplugged external 1tb drive that i needed to format)

when i used testdisk the first time it diagnosed my drive as intel

the program easily found my ext4 partition as it is the only one on the drive

i only used the write function once to restore the partition

when i try to mount the drive i get the errors stated above

i havent used testdisk to search to see if my files show up on the drive yet....im trying to be extra careful

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 09:48
by eeee4
as there are several blocksizes listed above im not sure what this means or how to use it.

To repair the filesystem using alternate superblock, run
fsck.ext4 -p -b superblock -B blocksize device

im trying to be careful

any suggestions?

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 16:09
by eeee4
i ran this command in terminal:

sudo fsck.ext4 -p -b 32768 -B 4096 /dev/sdc

this is what i got back:

fsck.ext4: Bad magic number in super-block while trying to open /dev/sdc
/dev/sdc:
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>

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 16:14
by eeee4
next i rant his command:

sudo e2fsck -b 1605632 /dev/sdc

and got this reply:

e2fsck 1.42.13 (17-May-2015)
e2fsck: Bad magic number in super-block while trying to open /dev/sdc

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>

should I continue with this?

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 16:39
by eeee4
i next ran the command using the actual drive path (testdisk had it as /dev/sdc)

Ubuntu lists the drive as /dev/sdc1

testdisk lists the drive as /dev/sdc

i ran this command:

sudo fsck.ext4 -p -b 32768 -B 4096 /dev/sdc1

this is what came back: :

UB1_2TB: Superblock has an invalid journal (inode 8).
CLEARED.
*** ext3 journal has been deleted - filesystem is now ext2 only ***

UB1_2TB: Resize inode not valid.

UB1_2TB: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)

does this means it's restored? im afraid to do anything else without further advice. please help if u can understand whats happening here.

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 17:15
by eeee4
next I ran fsck to check the disk:

fsck /dev/sdc1

and got this back saying the file system is now ext2:

fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
fsck.ext2: Permission denied while trying to open /dev/sdc1
You must have r/w access to the filesystem or be root

next i ran with sudo:

sudo fsck /dev/sdc1

and got back this:

fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
UB1_2TB contains a file system with errors, check forced.
Resize inode not valid. Recreate<y>?

should i select yes?

am I on the right track here?

Re: recover reformatted ext4 linux partition

Posted: 02 Dec 2019, 17:26
by eeee4
next I ran testdisk again to check if the superblock info is now different..it has changed some

this is what came back:

Linux 0 1 1 243201 80 62 3907029104 [UB1 2TB]
superblock 0, blocksize=4096 [UB1 2TB]
superblock 32768, blocksize=4096 [UB1 2TB]
superblock 98304, blocksize=4096 [UB1 2TB]
superblock 163840, blocksize=4096 [UB1 2TB]
superblock 229376, blocksize=4096 [UB1 2TB]
superblock 294912, blocksize=4096 [UB1 2TB]
superblock 819200, blocksize=4096 [UB1 2TB]
superblock 884736, blocksize=4096 [UB1 2TB]
superblock 1605632, blocksize=4096 [UB1 2TB]
superblock 2654208, blocksize=4096 [UB1 2TB]

To repair the filesystem using alternate superblock, run
fsck.ext4 -p -b superblock -B blocksize device