There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus batch bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop lcd malware memory modem monitor motherboard network printer problem ram registry router slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
How to recover files deleted in linux partition by using the command rm -rf

Reply  
Thread Tools
pkdcet's Avatar
Computer Specs
Member with 40 posts.
 
Join Date: Oct 2009
Experience: Intermediate
25-Oct-2009, 03:39 PM #1
How to recover files deleted in linux partition by using the command rm -rf
Hi,
One of my friend unknowingly due to some confusion(in stead of running the command on one shell he ran it on mine where pwd aws my home directory) deleted many files in my home dieory which is in ext3 partition. I had many files which were quite important. Can I recover them using some set of commands or any other trick?
Hoping for some positive responses,
-pkd
TerryNet's Avatar
Computer Specs
Moderator with 48,385 posts.
 
Join Date: Mar 2005
Location: Ottawa, IL
Experience: Intermediate to Advanced
25-Oct-2009, 10:32 PM #2
Use the drive as little as possible, so as to not overwrite the files.

Search for "recover Linux files." Here is one promising article.
lotuseclat79's Avatar
Distinguished Member with 21,345 posts.
 
Join Date: Sep 2003
Location: -71.45091, 42.27841
26-Oct-2009, 10:54 AM #3
Quote:
Originally Posted by pkdcet View Post
Hi,
One of my friend unknowingly due to some confusion(in stead of running the command on one shell he ran it on mine where pwd aws my home directory) deleted many files in my home dieory which is in ext3 partition. I had many files which were quite important. Can I recover them using some set of commands or any other trick?
Hoping for some positive responses,
-pkd
Hi pkdcet,

Ext3 has a journal, and if you are willing to slog through the details (it will take some effort if you have followed TerryNet's advice to essentially "do nothing" that would contaminate the contents of the driver before attempting to recover the files on it.

I would get another hard drive (at least as large) to do a Live CD sector backup using the dd command from your hosed hard drive to the backup hard drive first before doing anything else. This essentially clones your hosed hard drive - then you work with the clone to preserve the state of the original hard drive.

Here is a link to one of my posts: How to undelete removed files and directories on an ext3 file system.

Let us know what you decide to do and keep us informed of your progress.

-- Tom

P.S. Note:

Use the fdisk -l command to find the device names on your computer (from Live CD root account) or use the sudo fdisk -l command from a regular user account (from the Live CD regular default user account) - this will identify your Linux disk device name as opposed to any dual or multiple boot disks, e.g. Windows before you clone your hard drive which is the recommended procedure to follow.

Clone a harddisk

To clone a disk A to B, both disks need to have the same capacity. It is very convenient for USB disks. Say our USB disk source is called /dev/sdb and the target is called /dev/sdc. Do it like this:

dd if=/dev/sdb of=/dev/sdc

Now if sdc has a bigger capacity, this capacity will be lost because the file system is not aware of it.

Creating a hard drive backup directly to another hard drive

# dd if=/dev/hda of=/dev/sda conv=noerror,sync bs=4k

This command is used often to create a backup of a drive (/dev/hda) directly to another hard drive (/dev/sda). (The device name /dev/hda is typical of an IDE hard drive, the device /dev/sda is typical of a USB disk.) This works only if the hard drive has enough storage to accommodate the source drive's filesystem. The advantage of this is that you do not have to mount the hard drive to make a backup and the only reference to hda is in /dev and in the command which is usually in a script in cron.

The option "bs=4k" is used to specify the block size used in the copy. The default for the dd command is 512 bytes: use of this small block size can result in significantly slower copying. However, the tradeoff with larger block sizes is that when an error is encountered, the remainder of the block is filled with zero-bytes. So if you increase your block size when copying a failing device, you'll lose more data but also spend less time trying to read broken sectors. Tools like dd_rescue and dd_rhelp can provide a more flexible solution in such cases, combining the speed of a large block size for the regions without errors with finer-grained block-copies for regions with errors.
__________________
The independence created by philosophical insight is - in my opinion - the mark of distinction
between a mere artisan or specialist and a real seeker after truth. - Einstein 1944
Imagination is more important than knowledge. - Einstein

Last edited by lotuseclat79; 26-Oct-2009 at 11:41 AM..
Reply

Tags
ext3, linux, recover, rm -rf, undo

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:35 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.