LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-22-2011, 10:25 AM   #1
linuxpicaxe
LQ Newbie
 
Registered: Feb 2011
Distribution: arch linux
Posts: 17

Rep: Reputation: 0
Undoing a mke2fs command/file recovery


Hi all!

Ok, I have been a complete mug and managed to format a drive that I shouldn't have formatted.

The command I accidentally used on the wrong drive was:

mke2fs -jv /dev/sda3

Which creates an ext3 file system on the partition.

I do have a back up of most of the files but not all unfortunately so would love to know if there is a way of undoing the damage I have caused!

Note: I have not touched that partition of the drive since the deed was done.

Any help is appreciated!!!

Alex
 
Old 02-22-2011, 11:04 AM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Hi,

testdisk and photorec come to mind:
http://www.cgsecurity.org/wiki/TestDisk
http://www.cgsecurity.org/wiki/PhotoRec
 
Old 02-22-2011, 11:17 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Welcome to LQ linuxpicaxe, sorry to see it is on such a sad occasion. Since the first reply was a bit short on nfo:

Basically formatting a filesystem will layer a "mesh" over disk contents (in contrast to zeroing out a partition which destroys filesystem contents). So everything that is not touched by the newly created structure is more or less available. The problem is that entities are linked to their parent. For example a file is linked to it's parent (a directory) and a subdirectory is linked to its parent (a directory) as well. To confuse you even more, files which size exceeds a certain size will be broken up and "recorded" in different parts of the filesystem and those parts may be linked directly or indirectly. Mutilating the existing filesystem hierarchy and structure (the original mesh) by formatting destroys those links. Photorec (or foremost, scalpel, pyFLAG, et cetera) will try to determine the start and end of a file looking for distinct header and footer signatures (called carving). This is kind of a brute-force approach since not all files have distinct header and footer signatures and if there's files mixed in between they may be carved out as part of the result as well.

The best way to procede would be to boot a Live CD like the Helix 2008R1(2.0) ISO (MD5 hash 93a285bfa8ab93d664d508e5b12446d3) and make a bit-by-bit copy of the disk to another separate physical medium (removable USB storage?) before doing anything else with the disk. This way you always have a backup to fall back on might the need arise. When you use any of those tools best boot your Live CD too, bo need to mount partitions, and always recover to a separate drive. If you've got lots of files it may help to hash your backup files so you can easily weed out files you already have. You can use md5deep to piece-wise hash disk parts to find out if any parts of files you already have end up in erroneously carved results.

Searching LQ will yield some posts about accidentally formatted partitions for you to read, else ask away.

GL
 
Old 02-22-2011, 05:07 PM   #4
linuxpicaxe
LQ Newbie
 
Registered: Feb 2011
Distribution: arch linux
Posts: 17

Original Poster
Rep: Reputation: 0
Smile

Hello!

Thanks very very much for the in-depth info

Ill give it a go asap and let you know the results!

Many thanks

Alex
 
Old 08-08-2019, 02:03 PM   #5
somesanity
LQ Newbie
 
Registered: Aug 2019
Posts: 1

Rep: Reputation: Disabled
I was able to undo a "mke2fs -j /dev/sdb2" command, which was forcing my server to reboot in emergency mode, by deleting the partition with fdisk and then editing /etc/fstab and just deleting the line mentioning the new partition. Deleting the partition with fdisk alone wasn't enough, even after reboot, I had to delete that line in /etc/fstab and then reboot to fix the issue.
 
Old 08-09-2019, 02:15 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by somesanity View Post
I was able to undo a "mke2fs -j /dev/sdb2" command, which was forcing my server to reboot in emergency mode, by deleting the partition with fdisk and then editing /etc/fstab and just deleting the line mentioning the new partition. Deleting the partition with fdisk alone wasn't enough, even after reboot, I had to delete that line in /etc/fstab and then reboot to fix the issue.
This is not at all an answer to the original question, which was about data recovery essentially.
 
Old 08-09-2019, 03:06 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Not to mention it had been comatose for 8.5 years ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] NTFS File Sytem Recovery after mke2fs Mandarim Linux - Newbie 10 05-09-2011 06:17 AM
[SOLVED] undoing a mistake on the command line... oznola Linux - Newbie 2 05-15-2010 08:17 AM
mke2fs command not working on mandriva 2010 yogesh605 Linux - Newbie 2 03-03-2010 07:40 AM
Undo a mke2fs command. phoenixfire Linux - General 6 02-02-2010 05:40 AM
mke2fs what is the command to format a FAT23 or SWAP hd? linus72 Linux - Newbie 5 04-15-2009 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration