You are on page 1of 5

sign up

/questions

/tags

/users

/badges

log in

tour

/unanswered

help

search

/ask question

Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems..
It's 100% free, no registration required.

Take the 2-minute tour

recovering ext4 partition after dd'ing over start of HD


3

I accidentally used dd and wrote over the first 208MB of my external disk. What I wrote over is a
partition on its own (Debian nestinstaller) so what I see now is not my old (now damaged) ext4
partition but another smaller partition. This limits the tools and advices I could follow.

My plan was to recreate the partition table with testdisk and then fix everything with the backup
superblocks as described here. I'd lose the first 208MB but that's ok compared to the other 300GB of
data in there. Something like the following:
mke2fs -n /dev/sdb1

# doesn't work because sdb1 is the 208MB new partition

testdisk ...

# used this to create new correct partition table

mke2fs -n /dev/sdb1

# now works fine, get backup superblock positions

e2fsck -b backup_position -y /dev/sdb1 # returns many errors hence the -y

asked 2 years ago


viewed 3391 times
active 2 years ago
aviation.stackexchange.com

How are go-arounds


safe with close
parallel runways?
Aaron Lockey

However, I have been unable to recover anything. I used testdisk to write a new partition table that
matched what I had before. When I then run e2fsck I get many different errors. I get a filesystem after
that but it's completely empty, no files.
2 answers

The lost+found directory is full of files (recovered ones I think) but I need to recover the directory tree,
not just the files. I need the filename and previous directories to know what the files are (microscope
images, mass spec data, etc.. Without the names and the directories where they were, they mean
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

runw ays

go-around

Related

pdfcrowd.com

images, mass spec data, etc.. Without the names and the directories where they were, they mean
nothing).

I got another HD exactly the same and made a copy of the whole HD with dd so I can experiment
recovery without losing anything. Any advice?

22 Recovering ext4 superblocks

/ filesystems

/ partition

/ data-recovery

share improve this question

/ ext4

/ disk
edited Sep 1 '12 at 20:05

asked Sep 1 '12 at 17:10

Recover a reiserfs hard disk

Why my partitions don't show


the right capacity on a 4096
byte physical block hard
drive?

how to restore a logical


partition to it's original ext4
format

Resize non-LVM ext4 root


partition

How can I recover damaged


file from overwritten ext4
partition?

How do I find the offset of an


ext4 filesystem?

ext4 data recovery from


gparted error

harddisk not recognized /


filesystem too large to mount
safely on this system /
hdparm shows garbage

carandraug
356
2
10

Do you have any idea how many partitions you did have before? Cougar Sep 1 '12 at 17:25
@Cougar yes. I had a single ext4 primary partition spanning the whole disk. carandraug Sep 1 '12 at
17:26

First I would suggest to recreate the partition with fdisk or any other low-level partition tool. How to recover
your ext4 after that is shown here: link Cougar Sep 1 '12 at 17:37
@Cougar that's actually the link I followed to try to recover the partition. The difference is that I used
testdisk to recreate the partition. I will try with fdisk . carandraug Sep 1 '12 at 17:41
@Cougar using fdisk I couldn't even use e2fsck as it wouldn't find the superblock backups. I think the
problem was that I couldn't edit the CHS (the new partition set it to 64 but should be 255) carandraug
Sep 1 '12 at 19:08

add a comment

1 Answer

active

oldest

votes

I finally managed to fix this. Just for the record here's how I did it. Part of the solution I found here and it
involves knowing the settings used to create the filesystem (I was pretty sure I didn't change the
defaults).
Basically I first had to fix the partition table to reflect what I actually had there (I used testdisk for
this but parted , cfdisk or fdisk should work fine as well). I just removed the wrong partitions

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

Use testdisk and gpart


information to mount ext4
partition

Hot Network Questions


Why do film studios buy
domains of fictitious
companies?
Word for an animal that has
been ridden too much?
What is the result of equation?

pdfcrowd.com

this but parted , cfdisk or fdisk should work fine as well). I just removed the wrong partitions
and replaced by a single ext4 type partition covering the whole disk with the correct CHS values.
The rest is mostly from the link at start (read it for details) but basically I ran mke2fs -n /dev/xxx to
find the positions for the superblocks backup. Then used the last backup closest to the end of the disk
(only the ones at the start of the disk had been overwritten with dd) to run fsck. This generated a lot of
errors but fsck has a -y option (not the same as -a ).

Why do some AC adapters and


power supplies generate a
whining noise, and what can I
do about it?
What should three men and
three women do if everyone
else is dead?

sudo e2fsck -a -b backup_block_number /dev/xxx

Can I correctly populate end


tags using sed, awk or any
other command?

I thought this had not worked because I couldn't see any files but actually they had all been saved to
the lost+found directory.

What is the meaning of the


sentence ?

So in the end I did salvage most of my files while keeping their filenames and directory structure. Hope
this may help others in the future.
share improve this answer

add a comment

answered Oct 1 '12 at 8:03


carandraug
356
2
10

Placement new and alignment


in C++
Transmission implementation in
a car game
Does this linear current source
driver deliver constant current?
What's coming in ArcGIS 10.3
Desktop and where can I find
this info?

Your Answer

Is my carrier monitoring my
traffic?
Mathematician vs. Computer: A
Game
Is this picture from an Anime or
just art?
Ligatures and hyphenations:
the effect of empty brace
groups {}
How do I remove every number
that's surrounded by <>
Why would a table use its
primary key as a foreign key to
itself

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

What can cause a car to


consume more fuel?

Sign up or log in

Vector (physics)
implementation

Post as a guest

Sign up using Google

sideways for equation (a big


matrix)

Name

Division by zero is slow

Sign up using Facebook

Email

How can I lightly irradiate


30,000 km for just 3
generations?

Sign up using Stack Exchange

"FeedItem-Feed Item Layout"


preventing profile deployment
Is the Glass Half Full?

Post Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged / filesystems / partition
/ data-recovery / ext4 / disk or ask your own question.

question feed

tour

help

badges

blog

chat data

legal

privacy policy work here

TECHNOLOGY

advertising info

SCIENCE

OTHER

English Language &


Usage

Mathematics

Stack Apps

Cross Validated (stats)

Meta Stack Exchange


Area 51

Database Administrators

Photography

Server Fault

Unix & Linux

Drupal Answ ers

Science Fiction &


Fantasy

Web Applications
Ask Ubuntu
Webmasters

WordPress Development
Geographic Information
Systems

SharePoint

Skeptics

Graphic Design

Mi Yodeya (Judaism)

Theoretical Computer
Science

Mathematica

Seasoned Advice
(cooking)

Travel

Physics

Salesforce

Christianity

MathOverflow

Home Improvement

Arqade (gaming)

m ore (7)

User Experience

Electrical Engineering
Are you a developer? Try out the HTML to PDF API

open in browser PRO version

feedback

CULTURE /
RECREATION

Programmers

Ask Different (Apple)

contact us

LIFE / ARTS

Stack Overflow

Super User

mobile

Stack Overflow Careers

pdfcrowd.com

Game Development
TeX - LaTeX

Electrical Engineering

m ore (13)

Arqade (gaming)

Android Enthusiasts

Personal Finance &


Money

Bicycles

Information Security

Academia

Role-playing Games

m ore (10)

m ore (21)

m ore (7)

site design / logo 2014 stack exchange inc; user contributions licensed under cc by-sa 3.0 with attribution required
rev 2014.10.28.1972

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

You might also like