recover reformatted ext4 linux partition

How to use TestDisk to recover lost partition
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read https://www.cgsecurity.org/testdisk.pdf
Message
Author
eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

recover reformatted ext4 linux partition

#1 Post by eeee4 » 01 Dec 2019, 14:54

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.

Sponsored links

User avatar
cgrenier
Site Admin
Posts: 4989
Joined: 18 Feb 2012, 15:08
Location: Le Perreux Sur Marne, France
Contact:

Re: recover reformatted ext4 linux partition

#2 Post by cgrenier » 02 Dec 2019, 07:21

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.

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#3 Post by eeee4 » 02 Dec 2019, 08:58

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.

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#4 Post by eeee4 » 02 Dec 2019, 09:01

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

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#5 Post by eeee4 » 02 Dec 2019, 09:48

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?

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#6 Post by eeee4 » 02 Dec 2019, 16:09

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>

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#7 Post by eeee4 » 02 Dec 2019, 16:14

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?

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#8 Post by eeee4 » 02 Dec 2019, 16:39

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.

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#9 Post by eeee4 » 02 Dec 2019, 17:15

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?

eeee4
Posts: 11
Joined: 01 Dec 2019, 14:39

Re: recover reformatted ext4 linux partition

#10 Post by eeee4 » 02 Dec 2019, 17:26

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

Post Reply