0

I had an ext3 partition. I ran a dd command like this:

dd if=/dev/urandom of=/dev/part2 bs=1024 count=15000 seek="various values"

Where various values are basically 0, 15000K, 30000K etc.

The point is I ran the dd command on the entire partition.

Now the partition won't mount. I get an error "Can't find ext3 partition on ..."

Questions:

  1. What exactly happened to the partition? I know it got corrupted, but what exactly happened? As a clue fsck /dev/part2 gives "The superblock could not be read or does not describe a correct ext2 filesystem."

  2. How do I format it back to ext3?

3 Answers 3

5

You overwrote and/or corrupted superblock(s), and likely other data, with the data from /dev/urandom. Superblocks are important; they contain filesystem metadata.

You can format it back to ext3 by issuing mkfs.ext3 /dev/part2.

2
  • thanks, that worked. Appreciate it. So what I was trying to do is basically write data to filesystem at various offsets. I think I should not have written directly to the device file. Can you please check a question I have posted here at Stackoverflow. stackoverflow.com/questions/9594073/… Commented Mar 7, 2012 at 1:11
  • @abc - I agree with everything Perry said, don't do it. Commented Mar 7, 2012 at 1:38
1

If you are desperate about getting back the ext3 filesystem, you can run e2fsck with the -b NUM parameter, where NUM is the alternate superblock. Read the man page for e2fsck to get that number. Depending on the blocksize of the partition, you might have not overwritten it.

2
  • I wouldn't recommend even trying this once data has been written directly to the device. More than likely even if it initially appears to work, all hell will break loose. Commented Mar 7, 2012 at 1:44
  • It'll be a data recovery mission at best, since a lot must have been overwritten. It won't become a usable filesystem. Commented Mar 7, 2012 at 8:24
0

Another thing one could try in this situation is the program gpart. It attempts to guess missing partition (and filesystem) information - so, it might be able to recover that partition well enough to pull data off of it.

As the comments to jsbillings answer suggest, do not rely on the partition after this; this is recovery - pull off your data and make a new partition. (Other standard recovery tips/rules apply, too - like, "make an image, and work on that, not the original.")

(And yes, I realize this is too late to help the OP. Might help others, though.)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.