Recovering Deleted Data on Ubuntu Linux Server

Posted on 2014-07-19
Medium Priority
Last Modified: 2014-07-20
Hi folks!

Got an Ubuntu Linux 12.04.3 LTS server that is acting as a network file server using Samba.

While connected from a Windows machine using a mapped network drive, I accidentally deleted a bunch of files that shouldn't have been. Too many for me to know the exact file names.

Assuming there is not an easy solution, like going to a backup, what is the best way to go about trying to recover or "undelete" these files? I'm a bit of a novice when it comes to Linux file systems.

Question by:Ithizar
  • 4
  • 3
LVL 14

Expert Comment

ID: 40206801
Testdisk can undelete files in Linux. See here for step-by-step instructions.

Author Comment

ID: 40206807
Would you install TestDisk on the server where the deleted files are? That's what the instructions seem to apply, but I always understood you should not do any disk writes on a drive you're trying to recover data from.
LVL 14

Expert Comment

ID: 40206811
No, I would not install it on the same system - I'd run it from a LiveCD or LiveUSB.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 40206840
This is a machine sitting in a data center about an hour away from me, so I'd like to avoid physically going there if I could. :-) Do you know of a way to install and run TestDisk from another partition/location other than a LiveCD? Or, alternatively, do you know of any other product or technique that could be accomplished without physically accessing the server?

Thanks again!
LVL 14

Expert Comment

ID: 40206854
Can you mount the remote drive across the network? Testdisk can work on mounted drives, so you could just install it locally to fix the remote drive.

Author Comment

ID: 40206870
Yes, I can. In fact, the machine I'm trying TestDisk from already has this particular share mounted. However, when I run TestDisk, I see nothing in the list of available disks that matches that mount point.

For example, if I run the "mount" command with no parameters, one of the entries I see is this:

//datastore02/mainwwwroot on /network/datastore02/mainwwwroot type cifs (rw,mand)

That is the network share in question. However, when I run TestDisk, I see this:

Select a media (use Arrow keys, then press Enter):
>Disk /dev/sda - 644 GB / 600 GiB - VMware Virtual disk
 Disk /dev/mapper/easynas01-root - 642 GB / 598 GiB - VMware Virtual disk
 Disk /dev/mapper/easynas01-swap_1 - 1073 MB / 1024 MiB - VMware Virtual disk
 Disk /dev/sr0 - 64 MB / 61 MiB (RO) - VMware Virtual IDE CDROM Drive
 Disk /dev/dm-0 - 642 GB / 598 GiB - VMware Virtual disk
 Disk /dev/dm-1 - 1073 MB / 1024 MiB - VMware Virtual disk

(The machine I'm running from is a virtual machine, hence all the VMware Virtual disks.)

From there, how do I get it to look at a mounted drive and do recovery on it?

LVL 14

Accepted Solution

ThomasMcA2 earned 2000 total points
ID: 40206883
Since it sees other mounted disks, I was hoping it would work for your network disk. It even sees my encrypted /home, and a mounted TrueCrypt container.

Another option is a tool called foremost. The linked article says the package manager for Ubuntu can install it. I can't test it, since foremost is not in my package manager (openSUSE.) Good luck.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question