Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello gurus. I've done the ultimate user error and ran rm -rf * as root on /root and I wiped out everything! What I'm not sure of is what directory I was on when I did rm but I lost everything and assume I was on /root. I freaked out and rebooted and booted to a live cd.
Ultimately I want to just recover what was on my desktop. I tried using extundelete and I get errors about magic number. I also tried testdisk and I got further by it showing me my deleted folders but no option to recover them. The disk still has 2 partitions and. Think the 1st partition might be the boot.
I come in here hoping to get some hope I can recover a directory and its content. I'm begging for guidance! Please let me know the additional info I can provide that may clue you in resolving my problem. Thanks for any help! I browse this site for a long time and its helped me plentiful.
Last edited by Jslo040809; 04-15-2013 at 04:24 AM.
Thanks for the reply and suggestion but i already tried photorec and it would not work for my situation. Firstly, it recovers common file extensions such as jpg, png, avi, txt, rtf, etc. Sadly the files i lost are not all common. Secondly, the original file names are not retained and are named in some series of numbers followed by an exrension. It would take me months to sort all those files.
Would you happen to know is their is another program that can help my situation? Linux or windows app? Thanks!
Thanks for the reply and suggestion but i already tried photorec and it would not work for my situation. Firstly, it recovers common file extensions such as jpg, png, avi, txt, rtf, etc. Sadly the files i lost are not all common. Secondly, the original file names are not retained and are named in some series of numbers followed by an exrension. It would take me months to sort all those files.
Would you happen to know is their is another program that can help my situation? Linux or windows app? Thanks!
No, there really isn't in this situation. You need to just rebuild your box, and restore your data from backups.
If the choice is between recovering files and not recovering anything this isn't a valid argument IMHO. And if you do have a backup (even partial) then for example piece-wise hashing (md5deep) may help sort things. To some extent though, because due to file system behavior and due to how header / footer carvers like Photorec, foremost (older) or scalpel (way old) operate you may count yourself lucky if you can manage partial recovery.
No, there really isn't in this situation. You need to just rebuild your box, and restore your data from backups.
i was afraid that was going to be my only option. Another forehead flicker was it was my backup i oof'd up. i was in the middle of rebuilding when i realized i rm * my ext hdd. I know I know i should slap myself ..and i did.
Are you sure you followed the instructions: http://www.cgsecurity.org/wiki/TestD...file_for_ext2? Did you have another drive or stick present to save files to?
i have. I tried that method. Also could these instructions work on an ext4 FS? Im thinking my results were unsuccessful was because I'm not using ext2.
So what type of files are they exactly?
i have several files to recover. iso, dmg, tzg, mkv, etc. Not all of them are recovered with testdisk unless i could be missing something
If the choice is between recovering files and not recovering anything this isn't a valid argument IMHO. And if you do have a backup (even partial) then for example piece-wise hashing (md5deep) may help sort things. To some extent though, because due to file system behavior and due to how header / footer carvers like Photorec, foremost (older) or scalpel (way old) operate you may count yourself lucky if you can manage partial recovery.
Yeah, youre right but the disk was 1tb and im trying to recover +800GB.
I tried extundelete and when I would run extundelete /dev/sda2 --restore-all (sda2 is an lvm) i get an error regarding "bad magic number". Is that something i can fix to get extundelete to work?
a word of advice
next time do NOT !!! run as root !!!!
on a lot of current distros you can not even login to the gui as root ( without using the "pam" hack)
Only become root for very specific tasks then drop back down to your normal user account
for this i DO recommend loging in as root into the gui one time and once only
-- to set the root gui theme to "high contrast" or some other " hideous" theme that you HATE
that way at a very quick glance you KNOW you are using root
also if not set
set the root terminal color to something VERY noticeable
like RED
on opensuse this is default
the normal user is white
the root prompt is RED
Hello gurus. I've done the ultimate user error and ran rm -rf * as root on /root and I wiped out everything! What I'm not sure of is what directory I was on when I did rm but I lost everything and assume I was on /root. I freaked out and rebooted and booted to a live cd.
Ultimately I want to just recover what was on my desktop. I tried using extundelete and I get errors about magic number. I also tried testdisk and I got further by it showing me my deleted folders but no option to recover them. The disk still has 2 partitions and. Think the 1st partition might be the boot.
I come in here hoping to get some hope I can recover a directory and its content. I'm begging for guidance! Please let me know the additional info I can provide that may clue you in resolving my problem. Thanks for any help! I browse this site for a long time and its helped me plentiful.
Here you say that you can see your folders, but not recover them. Could you put a USB or an external HD in and copy and paste these files onto them? I have done this in the past with brilliant success.
I know this is not helpful now but perhaps for others or for you in the future. Commands like 'rm -fr *' are always high risk, even when run as a regular user. I understand that it is sometimes the quickest and simplest way to kill the contents of a directory and all subdirectores but if you really need to do this at least consider adding '-i' or '-I' to give you a chance to make absolutely sure.
I also tried testdisk and I got further by it showing me my deleted folders but no option to recover them.
Go inside the folder and from there you can recover the files. With one keystroke (I think it's 'C') you can recover all files in one directory at a time. They will be copied to the directory you were in when you started testdisk.
Here you say that you can see your folders, but not recover them. Could you put a USB or an external HD in and copy and paste these files onto them? I have done this in the past with brilliant success.
I think you were much fortunate than I was ...and more skilled than i am because possibly i could be doing this wrong. Here are my steps on testdisk:
Code:
TestDisk 6.13, Data Recovery Utility, November 2011
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
TestDisk is free software, and
comes with ABSOLUTELY NO WARRANTY.
Select a media (use Arrow keys, then press Enter):
>Disk /dev/sda - 1000 GB / 931 GiB - ST31000333AS
Disk /dev/sdb - 4127 MB / 3936 MiB - Kingston DataTraveler 2.0
Disk /dev/mapper/live-osimg-min - 4294 MB / 4096 MiB (RO)
Disk /dev/mapper/live-rw - 4294 MB / 4096 MiB
Disk /dev/mapper/vg_testrhel-lv_home - 941 GB / 877 GiB - ST31000333AS
Disk /dev/mapper/vg_testrhel-lv_root - 53 GB / 50 GiB - ST31000333AS
Disk /dev/mapper/vg_testrhel-lv_swap - 4160 MB / 3968 MiB - ST31000333AS
Disk /dev/dm-0 - 53 GB / 50 GiB - ST31000333AS
Disk /dev/dm-1 - 941 GB / 877 GiB - ST31000333AS
Disk /dev/dm-2 - 4160 MB / 3968 MiB - ST31000333AS
>[Previous] [ Next ] [Proceed ] [ Quit ]
The disk I'm choosing is Disk /dev/mapper/vg_testrhel-lv_home - 941 GB / 877 GiB - ST31000333AS
This is the home directory that I want to recover data from. I got to proceed and I'm at the testdisk menu and I choose Advanced and then here is where i get options for "type" "Superblock" "list" "image create" "quit". I choose list and I can navigate to my home directory and the files/directories that were deleted are in red font. When I attempt to copy the files to an ext hdd it jut creates a file of the deleted directory in the ext hdd with a small data amount. I have followed the instructions on the website provided and some options such as "undelete" is not available for me to continue.
i attached pictures of the hdd and the partitions. Maybe doing the rm * caused more damage than I thought.
Here is also the error when I tried extundelete:
[root@localhost extundelete-0.2.4]# extundelete /dev/sda2 --restore-all
extundelete: Bad magic number in super-block when trying to open filesystem /dev/sda2
Please let me know if you need more info. Many thanks!
Go inside the folder and from there you can recover the files. With one keystroke (I think it's 'C') you can recover all files in one directory at a time. They will be copied to the directory you were in when you started testdisk.
I tried to go into the red folder (deleted folder) but it would not allow me to. I did press c to copy and it just copied over a filename of the deleted directory with no data.
I must be missing something if this program has great success
I feel for you but without backups your data is gone. The rm -rf is a dangerous syntax to run if not careful.
Before I use the rm -rf on a directory or files, I double check where I am in the directory because there is no going back to undo.
You have to accept this as a life learn experience and hope it doesn't happen again. Please do backups, yes it boring, but it is a relief when you have backups to restore files when accidents happen.
A thought: The files you're looking for a apparently in a logical volume group. Is it possible that you have snapshots of the LV? If so, you should be able to restore (some of) your files from the snapshot using the LVM tools. (I think that RHEL may automatically snapshot for you, but I don't use RHEl.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.