Windows.  Viruses.  Notebooks.  Internet.  office.  Utilities.  Drivers

Have you often encountered situations when you needed to recover data? You accidentally deleted the file, but when it was too late you changed your mind, but did not know how to restore it, as an option you installed the operating system and, out of ignorance of the disk layout, formatted the disk with all data, music, movies, home photos and other other data. You are in despair not knowing whether it is possible to restore everything bit by bit, but this is only the smallest part of solving the consequences of the problem that arose, data in Linux can be restored and there are utilities for this, both paid and free, and today we will discuss 7 utilities that will help in recovery data in ubuntu linux.

Partially, of course, this all helped, but most of the data was still lost, but imagine the situation, you are a student, preparing a term paper, there is a week or two left before passing, and you flew HDD on which your term paper was, what to do in this situation.

I know that many users are accustomed to working with a graphical interface from the time they worked on the system, but today we will also discuss console utilities, since many of them help in recovery no worse, and in some situations even better.

How to recover data and what applications to use?

How to recover data using the Scalpel utility

Scalpel is a set of tools for quick recovery files. A unique utility, its uniqueness lies in the fact that it does not depend on the file system in any way. The utility searches the database for files of all known formats and tries to find them on the disk according to its own patterns, looking at the beginning and end of the file. It can help in recovery in such file systems as FATx, NTFS, ext2/3, also from "RAW" partitions.

Install the utility, run the command in the terminal:

sudo apt install scalpel

the utility works according to its internal template /etc/scalpel/scalpel.conf, if you want to restore files of a certain format, you should open the config and uncomment the corresponding lines for of this type files. When editing a config template, you need to be very careful not to break it and not delete anything superfluous.

Scalpel example:

sudo scalpel file.iso -o dir_recovery

recovery directory" dir_recovery"must be empty, file.iso this is an example of the data that we need to restore, we know that we had such an image with exactly the same name, we can specify not only the file directly, but we can also specify the full path to the device from where we need to restore, like /dev/sdb1/directory_name/directory_name2/filename.

How to recover data using R-Linux

R-Linux is free program for restoring Ext2/Ext3/Ext4 FS file systems used in Linux and some Unix operating systems (OS). Used in R Linux The Scanning technology and easy-to-set parameters interface of the program gives the user absolute control over the data recovery process. The program recovers data from existing logical drives even if the file records are lost. However, the program lacks the ability to recover data over the network, as well as the functionality for reconstruction disk arrays and data recovery.

There are two versions of the R-Linux utility: for Linux OS and for Windows OS. They have the same functionality, the difference is only in the host OS.

R-Linux restores the following files:

  • Removed as a result of a virus attack, power failure or system damage;
  • From damaged or deleted partitions, after partition formatting, even to a partition with a different file system;
  • When the structure of a partition on a disk has been changed or corrupted. In this case, R-Linux can scan the hard disk, find a previously deleted or damaged partition, and only then recover data from the found partition.
  • WITH hard drives, which have a large number of bad sectors. R-Linux allows you to copy information and create an image of a whole disk or part of it, and only then work with the image file saved on another medium as with the original disk. This is especially useful and effective when the number of bad sectors on the disk is constantly growing, and the remaining information needs to be saved immediately.

What can R-Linux do:

  • Operating system (OS) of the host:
  • Linux OS option: any Linux OS based on kernel 2.6+
  • Windows OS option: Win2000, XP, 2003, Vista, Windows 7, Windows 8/8.1, Windows Server 2008/2012
  • Supported file systems: Ext2/Ext3/Ext4 FS (Linux) only.
  • Recognition and analysis of schemes of Dynamic (Windows 2000/XP/2003/Vista/Win7), Basic, BSD (UNIX) partitions and APM partition scheme (Apple Partition Map). Support for dynamic partitions on GPT as well as MBR.
  • Create an IMAGE FILE for an entire physical disk, partition, or part of it. Disk image files can be treated by the program like a normal disk. Two types of images are possible: 1) Images that are an exact byte-by-byte copy of an object (Uncompressed images) - such images are compatible with the previous ones. R-Linux versions; 2) Compressed images - can be compressed, split into multiple files and password protected. Such images are fully compatible with images created by the R-Drive Image program, but are incompatible with previous versions r-linux.
  • The recovered files can be saved to any drive, including a network drive, accessible by the local operating system.
  • Monitoring S.M.A.R.T parameters R-Linux can display S.M.A.R.T parameters. (Self-Monitoring, Analysis and Reporting Technology) for hard drives that show the state of their hardware and predict their possible failures. Any additional load on such disks should be avoided if warnings from the S.M.A.R.T system appear.
  • Search for deleted versions of files. R-Linux can search remote versions files using their sizes, names, extensions, and recognized file types as search parameters.

If you do not understand something about the application, you can read reference guide the links / manual is quite extensive, you will find answers to many questions.

How to install R-Linux

You can download the file for your architecture from the link - , then to install, open the terminal and run the commands:

cd ~/Downloads/ cd ~/Downloads/ sudo dpkg -i rli*

after the installation is completed, look for the application in ubuntu menu - System Utilities - R Linux, after the first launch you will see an English-language application, do not be alarmed, support for "Russian" is also present. Go to Help menu - Interface Language, and select Russian, done.

If you need to restore files, connect a flash drive as an example, you saw that the flash drive was detected, on the Ubuntu sidebar, click the refresh button in the application to see your media. Next, select the section of our flash drive with the mouse cursor and click the " Scan".

As you can see, we are offered to configure scanning parameters in more detail, whether to search for known file types, whether to keep a log, where to specifically search, you can specify from which byte segment you should start scanning, from 0 according to the standard, or you can specify your data.

Scanning has been started, we wait until it is completed, we do not cancel in any case, sometimes it can end badly for a flash drive. The scan is completed, then we see the following picture:

below our flash section there is an area called " Found by signatures", click on this section with the mouse cursor and you will see a new window:

click on the line " Files found by information about typical features of their data structure". After clicking on this link, we will see something like this:

select the directories you need and click the button " Restore Marked", I checked for the sake of the test, the utility works well, try it and unsubscribe according to the result as it is in practice in a real situation when data is lost, files are deleted, and so on.

How to recover data using the R-Studio utility

Paid utility, but it's worth it as it will help out even the most difficult situations, you can buy on the official website -. Advanced utility, the best among data recovery utilities, works with NTFS, NTFS5, ReFS, FAT12/16/32, exFAT, HFS/HFS+ (Macintosh), Little and Big Endian variants of UFS1/UFS2 (FreeBSD/OpenBSD/NetBSD) /Solaris) and Ext2/Ext3/Ext4 FS (Linux). R-Studio also uses file recovery by signatures (search when scanning files of known types) for badly damaged or unknown file systems. The program allows you to recover data both locally and on remote computers over the network, even if disk partitions have been formatted, damaged or deleted.

R-Studio includes:

  • RAID reconstruction module
  • Versatile text/hexadecimal editor with a wide range of features
  • Separate module Reserve copy system and data (disk copying), which allows us to consider R-Studio the most optimal and complete solution for creating workstation for data recovery.

R-Studio restores files:

  • Deleted outside the Recycle Bin or when the Recycle Bin has been emptied;
  • Removed by virus attack or computer power failure;
  • After the file partition has been reformatted, even to a partition with a different file system;
  • When the partition structure on the hard drive has been changed or damaged. In this case, using the R-Studio program, you can scan the hard drive, find a deleted or damaged partition, and only then recover data from the found partition.
  • From hard drives that have a large number of bad sectors. The R-Studio recovery program can first copy the information and create an image of the whole disk or part of it, and only then work with the image file saved on other media as with the original disk. This is especially useful and effective when the number of bad sectors on the disk is constantly growing, and the remaining information needs to be saved immediately.
  • By order of the Ministry of Justice of the Russian Federation dated November 26, 2015 No. 269, R-STUDIO was included in the list of requirements for the minimum configuration of the material and technical base for several types of forensic examinations conducted in federal budgetary forensic institutions of the Ministry of Justice of the Russian Federation.

What R-Studio utility can do:

  • Standard user interface"Windows Explorer".
  • Host operating system (OS): Windows 2000, XP, 2003 Server, Vista, 2008 Server, Windows 7, Windows 8/8.1/10, Windows Server 2012.
  • Data recovery over the network. Files can be recovered over the network from remote computers running Win2000/XP/2003/Vista/2008/Windows 7/8/8.1/10/Windows Server 2012, Macintosh, Linux and UNIX.
  • Supported file systems: FAT12, FAT16, FAT32, exFAT, NTFS, NTFS5, ReFS (new local file system introduced by Microsoft in Windows 2012 Server), HFS/HFS+ (Macintosh), Little and Big Endian variants of UFS1/UFS2 (FreeBSD) /OpenBSD/NetBSD/Solaris) and Ext2/Ext3/Ext4 FS (Linux).
  • Search for Files of Known Types when Scanning (file recovery by signatures): if the file system on the disk is badly damaged or unknown, then R-Studio looks for data patterns (file signatures) characteristic of certain file types (documents Microsoft office, jpgs, etc.). If necessary, the user can add new types of files to R-Studio.
  • Recognition and analysis of schemes of Basic (MBR), GPT and BSD (UNIX) partitions, as well as Apple partition schemes. Support for Dynamic Volumes (Windows 2000-2012/8.1/10) on MBR and GPT.
  • Support for Windows Storage Spaces (Windows 8/8.1 and 10/Threshold 2), software Apple RAID and Linux Logical Volume Manager (LVM/LVM2). R-Studio can automatically recognize and assemble the components of these disk managers even if their databases are slightly damaged. Their components with severely corrupted databases can be added manually.
  • Reconstruction of damaged disk arrays (RAID). If the OS does not recognize the disk array (RAID), you can create a virtual RAID from its components. Such a virtual array can be processed by the program as a regular physical array. Support for standard RAID levels: 0, 1, 4, 5, 6. Support for nested and non-standard levels: 10(1+0), 1E, 5E, 5EE, 6E. Parity delay support for all relevant RAID levels. Support for custom RAID schemes.
  • Automatic recognition of RAID parameters.R-Studio is able to recognize all parameters for RAID 5 and 6. This allows the user to solve one of the most difficult tasks in RAID recovery - determining its parameters.
  • Creating an IMAGE FILE for an entire Physical Disk (HD), Partition or part of it. These image files can be compressed and split into multiple files for storage on CD/DVD/Flash or FAT16/FAT32/exFAT. Disk image files can be treated by the program like a normal disk.
  • Data recovery from damaged or deleted partitions, encrypted files (NTFS 5), alternative data streams (NTFS, NTFS 5).
  • Data recovery after:
  • running FDISK or similar utilities;
  • virus attack; FAT corruption; destruction of the MBR.
  • Recognition of localized names.
  • The recovered files can be saved to any drive, including a network drive, accessible by the local operating system. The recovered files can be saved on another drive of the connected remote computer without being downloaded over the network to the local computer.
  • View the contents of files to assess the chances of recovery. The contents of most file types (formats) can be viewed even if the corresponding application for the file is not installed.
  • Files or disk contents can be viewed and edited using the built-in hex editor. The editor supports editing the properties of NTFS files.
  • Monitoring of S.M.A.R.T parameters. R-Studio can display S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) for hard drives that show the state of their hardware and predict their possible failures. Any additional load on such disks should be avoided if warnings from the S.M.A.R.T system appear.
  • Integration with DeepSpar Disk Imager, a professional hard drive imaging device specifically designed to recover data from failed drives. This integration gives low-level thin access to disks with a certain level of hardware failures. Moreover, it allows you to create a disk image and analyze at the same time. That is, any sector accessed by R-Studio on the source disk will be immediately copied to the clone disk, and all subsequent data recovery operations will be performed on the clone disk to prevent further deterioration of the source disk and significantly reduce the time processing.

Of course, not all data recovery utilities are described above, there is also a list with such utilities as Unrm, Giis, Ddrescue, DMDE, PhotoRec, Mondo Rescue and Safecopy, I described only the main ones, about other utilities and their capabilities, I would advise you to read the material - . On this, perhaps, we will end the material, there will be questions, ask, clarify and leave feedback about the utilities used by which you recovered data, maybe what you use is not in the article, describe in the comments what you use.

V. Kostromin (edited by Vanderboot)

The other day, during a small revision of the contents of my site, I came across a translation of the article "10 ways to recover deleted files in linux", the original version of which is dated June 21, 2007. After re-reading the article and trying to follow the links provided in it, I found that some of the links do not work at all (the developers' sites on the network have disappeared), and some of the utilities mentioned in the article have not been updated and are not supported for a long time.

The idea was to see what tools to recover accidentally deleted files exist at the moment. I believe that interest in the means of this kind has not disappeared over the past years. After all, novice Linux users (as well as other operating systems, by the way) often find themselves in a situation where, by mistake caused by inexperience, they delete some files and immediately realize that they did not delete what they wanted. Or maybe they didn’t want to delete something at all.

In addition to cases of erroneous deletion of data, situations are possible when the media turns out to be corrupted, bad sectors appear on the disk, and so on. In such situations, data recovery tools are also needed.

I want to warn you right away that everything stated below has not been personally verified by me and is based only on information published on the developers' websites or in articles with descriptions of the relevant products. And, of course, only freely distributed products are considered in the article. If you are interested in paid (proprietary) products, you can easily find them yourself.

So, here list of utilities for recovering lost data, which I managed to find (the data is current as of November 10, 2010).

  1. unrm- a small console utility that, under certain conditions, can recover almost 99% of deleted data (similar to the undelete utility in DOS). Read the FAQ file carefully before using it, and preferably the Linux Ext2fs Undeletion Mini-HOWTO . Application:
    unrm [-b (no block padding)][-e (every block)][-f fstype][-vW] device
  2. (gET iT i sAY) - file recovery tool for Ext2/Ext3 file systems. Can be restored after installation current files and the newly created files in /root and /home. The utility allows users to recover all deleted files, recover files owned by a specified user, dump data from a file location, and recover files of a certain type, such as text or MP3. There is also an analyzer to help users during recovery.
  3. ddrescue(in Ubuntu this utility is called gddrescue) This utility copies data from a file or hardware device containing the data to another location, while attempting to correct any read errors. The main operations ddrescue performs in automatic mode, filling in parallel the protocol file. If there are two or more copies of corrupted files, ddrescue is able to completely restore the file, eliminating all errors.
    ddrescue sets the I/O buffer size to the sector size, so it can be used for sector-by-sector recovery of data from devices.
  4. Test Disk is a powerful free data recovery software! It was developed primarily as a tool for recovering lost partitions and/or restoring disk bootability if the problem is caused by software, viruses, or human error (such as accidental deletion of the Partition Table). Restoring Partition Tables with TestDisk is very easy. But TestDisk can also repair deleted files on FAT, NTFS and ext2 file systems; copy files from remote FAT, NTFS and ext2/ext3/ext4 partitions. (See the article by V.Simon, "Testdisk - restoring the disk partition table").
  5. - console program, which allows you to search for files on disks or their images by hex data, characteristic headers and endings. The program combs files for matching predefined hex codes (signatures) corresponding to the most common file formats. After that, it extracts them from the disk/image and puts them in a directory, along with a detailed report on what, how much and from where it was restored. The types of files that foremost can recover immediately are: jpg, gif, png, bmp, avi, exe, mpg, wav, riff, wmv, mov, pdf, ole, doc, zip, rar, htm, cpp. It is possible to add your own formats (in configuration file/etc/foremost.conf) that the program does not know about.
    Articles: "Recovering deleted files with foremost", "Recovering deleted files in Linux OS".
  6. R Linux is a free program for recovering Ext2/Ext3/Ext4 FS file systems used in Linux and some Unix systems. The Scanning Technology used in R-Linux and the easy-to-set program interface give the user absolute control over the data recovery process. R-Linux allows you to copy information and create an image of a whole disk or part of it, and only then work with the image file saved on another medium as with the original disk. R-Linux searches for files of known types using the typical characteristics of their structures, which allows the user to search and recover files from devices where the file system is unknown - HD, CD, DVD, floppy disks, USB disks, ZIP disks and flash memory devices ( Compact Flash Card, Memory Sticks). However, the program lacks the ability to recover data over the network, as well as the functionality for reconstructing disk arrays and recovering data from them.
  7. DMDE- DM Disk Editor and Data Recovery Software. Disk editing and data recovery software. IN free version all functions of the disk editor, partition management and file recovery are available, with the exception of the possibility of group recovery of files and directories; full version allows you to restore groups of files and directories while maintaining the directory structure.
  8. PhotoRec is a utility included in the TestDisk package. Designed to recover corrupted files from digital camera memory cards (CompactFlash, Secure Digital, SmartMedia, Memory Stick, Microdrive, MMC), USB flash drives, hard drives and CD/DVD. Recovers files of most common image formats including JPEG, audio files including MP3, document files in Microsoft formats Office, PDF and HTML, as well as archives, including ZIP. Can work with ext2, ext3, FAT, NTFS and HFS+ file systems, and is able to recover graphic files even if the file system is corrupted or formatted.
    Can run Linux, DOS, Windows, FreeBSD, NetBSD, OpenBSD, Mac OS X and SunOS operating systems
  9. Mondo Rescue. The main purpose of this program is to create backup copies of data. She can create backups on magnetic tapes, CDs, on remote media via NFS or as ISO images on local drives. But in case of data damage, the program allows you to restore them completely or partially, even if your hard drive is inaccessible by conventional means.
    Mondo runs on all major Linux distributions, supports LVM, RAID, ext2, ext3, JFS, XFS, ReiserFS, VFAT and other file systems. It can restore disk geometry, migrate data to RAID arrays, check the integrity of the computer's file system. In addition, it allows you to restructure the disk, reduce / increase partitions, reassign devices, add hard drives.
  10. is a data recovery tool that tries to extract data from accessible but problematic media (with bad sectors). The data source can be external devices(such as CD, DVD, and Blu-ray) and hard drive partitions. The program has the advantage of continuing to run even when other tools terminate it due to I/O errors. Conventional copy tools such as cat, cp, or dd do not allow you to create an image of a disk or removable media if a sector read fails.
  11. The Sleuth Kit(TSK) - a set of programs (fls, icat, ffind, ifind, mmls, fsstat, etc.) for forensic analysis of file systems. TSK - set of UNIX tools command line, which can parse file NTFS systems, FAT, FFS, EXT2FS, and EXT3FS. TSK reads and processes file system structures on its own, so there is no need for file system support by the operating system.
    Articles: Recovering Hidden or Lost Data.
  12. scalpel is a quick file recovery tool. The uniqueness of this software lies in the fact that it does not depend on the file system. The program searches the database for the beginning and end of files of known formats and tries to find them on the disk. Therefore, recovery is possible both from FATx, NTFS, ext2/3, and from "bare" (raw) partitions.
    Articles: Recover deleted files with Scalpel

In addition to those listed in some articles, utilities are also mentioned. Magicrescue And ntfsundelete from the ntfstools package.

This list can be very useful if you find yourself in a situation where you need to recover data from a damaged media. And it is desirable to master at least some of these tools before there is an urgent need for their use. To do this, it makes sense to test them on artificial examples deleting files, as done in one of the notes in the list of sources.

In conclusion, a few tips, maybe trivial, but certainly useful, on how to try to avoid getting into an unpleasant situation when the use of the above means is required. First, you can make it harder to accidentally delete a file or directory. To do this, make sure that instead of the command rm the command was called rm-i. You can do this with the alias command like this:

Alias ​​rm="rm -i" Then you will be asked an additional question before performing the removal if you really want it.

Second tip: back up your data as often as possible, every day or even every hour. If you follow this advice, then in the worst case, you will lose only the results of your work that you received during the last hour. And the data recovery procedures in this case will be much easier to perform. You can automate the execution of these procedures using cron and the utility rsync by arranging periodic copying of important files and directories to another disk or partition. Or you can use the Mondo Rescue utility mentioned above. By the way, you will learn how to use it, which can be useful in case you need to recover data in an emergency.

And third: before you start trying to recover deleted files, make a copy of the partition in which these files were located, and work with it, and not with the original partition. If you make a mistake again during the recovery process, you can start all over again. If you work with the original partition, you can damage the data irrevocably. You can make a copy of a partition using the command dd(You can read about the use of this command in A. Dmitriev's article "dd: A command that is not like the others").

It is also worth recalling that there are special Linux distributions that run from CD or other removable media and contain a bunch of administration utilities, including data recovery tools. Examples of such distributions include SystemRescue CD and Trinity Rescue Kit.

I believe that the above list will also become obsolete after some time, as happened with the list given in the article mentioned at the beginning of this note. But there will be new means, maybe more advanced. Check back occasionally at the Linux Software Catalog to keep up to date, or better yet, help keep this catalog up to date. Then in any emergency or regular situation, you or another Linux user will be able to find the necessary means and tools to solve their problems.

ABOUT data recovery from file systems Linux didn't write only
lazy. To accomplish this task, there are many different
tools, including the debugfs utility, which easily retrieves any shabby
files from ext2. But what about other FS? How to recover a lost file from
a flash keychain or a nearby NTFS partition? Even the most silent about it
hardworking bloggers. And meanwhile, everything is very simple and prosaic.

It is not always convenient to reboot into another operating system to perform
actions to check file systems, restore files, resize
partitions and perform other data operations. Imagine that there are several
two years have been installed on your computer OS: Windows and Linux. the first
you upload very rarely and only in emergency cases, the second you use
every day and you are already thinking about the complete transition to Linux and the removal of Windows, here
only an NTFS partition that stores data accumulated over the years should be converted to ext3
not possible with any tools. You have to keep two operating systems, because
even though the NTFS partition is accessible from Linux (using ntfs-3g), to solve problems
the file system will still have to be rebooted into Windows.

And if the FAT file system on the Flash drive is covered? Again
reboot into Windows? Or you accidentally deleted a file in the UFS file system,
belonging to a nearby installed FreeBSD? Maybe you are a system
administrator, and disk for Windows Recovery didn't show up at the right time
at hand? I will answer all questions at once: almost all actions upon returning from
non-existence of FAT, NTFS, UFS file systems, recovery of files stored in them,
diagnostics and much more can be done without leaving Linux. From this article
you will know how to do it.

Set of tools

Before proceeding directly to the description of the recovery process,
diagnostics and return of dead files to life, I consider it my duty to acquaint
you with a list of tools used. First, we will need
tools for working with file systems (creating, checking, receiving
information). All of them are distributed in three packages:

1. dosfstools- Utilities for working with FAT file systems.
The package contains only two programs: mkfs.vfat (mkfs.dos) for creating a file
system and fsck.vfat (fsck.dos) to perform a file system check.

2. ufutils- a set of utilities for working with UFS and derivatives (for example,
FFS used by FreeBSD). Contains eight utilities, including mkfs.ufs,
fsck.ufs, tunefs.ufs (FS tuning), growfs.ufs (resizing) and others.

3. ntfsprogs- various utilities for working with NTFS. Does not contain
programs to create or complete check (basic check is possible) file
system, but includes a mass most useful tools, such as ntfscp for
copying files without mounting a partition, "reincarnation" of files ntfsundelete,
ntfsresize partition resizing tool, cloning tool
ntfsclone partitions and others.

We may also need tools for working with hard disk partitions.
disk. There are three most advanced programs of this type:
parted,
designed to create partitions, resize them, move them,
creating and checking file systems;
gpart-
program-recoverer of the erased partition table and
Test Disk-
similar to gpart with a pseudo-graphical interface and a few useful features.

It should be noted that parted is just a good wrapper on top of the described utilities.
to work with filesystems, so pretty much anything that parted can do can and
They. Moreover, there is another wrapper around parted itself, called
. She
just creates a user-friendly GTK GUI in the style of Partition Magic.

In the TestDisk package you will find the PhotoRec utility for
recovery various types files from the partition, regardless of the used
file system. The principle of its work is to find and restore files
by their metadata without analyzing the structure of the file system. PhotoRec is capable
recover images (bmp, jpg, png, tiff, raf, raw, rdc, x3f, crw, ctg,
orf, mrw), audio files (wav, au, mp3, wma), video files (avi, mov, mpg), archives
(bz2, tar, zip), documents (doc, pdf, html, rtf), source code files (c,
pl, sh). A number of programs of the same type can be found in the package
Sleuth Kit for which
there is an autopsy web interface.

Use cases

In the following sections, we'll look at a few common scenarios.
using the described utilities. First, this detailed description process
file recovery using three different approaches, secondly, fixing
file systems after a crash, thirdly, cloning a partition to multiple machines,
fourthly, a description of the process of transferring data to a smaller partition.

Casting ressurection

To revive dead files on NTFS, the already mentioned
ntfsundelete from the ntfsprogs package. It is very easy to use and extremely
neat. If you accidentally wiped a file and immediately unmounted the partition, be
sure - ntfsundelete will be able to return it to its place safe and sound.

First you need to view a list of all deleted files:

# ntfsundelete /dev/sda1

The third column of the output will indicate the percentage of file safety. If he
equal to 100% - everything is OK, the file can be brought back to life safe and sound;
a lower value indicates that some of its parts have already been overwritten
new data, so after recovery the file will be, as they say,
broken. In some cases, the possibility of restoring even a half-killed
file can make the weather, but for now let's focus on completely whole copies.
To do this, run the following command:

# ntfsundelete -p 100 /dev/sda1

Wow, how many of them! We will force the program to display only files,
deleted in the last 2 days:

# ntfsundelete /dev/sda1 -p 100 -t 2d

That's better. Restore the file whose inode number (first column of the output)
is 11172, to the /undeleted directory:

# ntfsundelete /dev/sda1 -u -i 11172 -d /undeleted

Files can be restored by mask:

# ntfsundelete /dev/sda1 -u -m "*.doc"

Filter by length:

# ntfsundelete /dev/hda1 -S 5k-6m

Or you can recover all deleted files, and only then figure out
what is what:

# ntfsundelete /dev/sda1 -u -m "*" -d /undeleted

The program extracts files with all attributes, including name and creation time.
It is a pleasure to use it.

To recover data from all other file systems, including FAT, UFS,
EXT3, and any other, it is most convenient to use PhotoRec. We launch
program:

In the main menu, select the experimental device (for example, / dev / sda). Click
and select the type of partition table (for PCs, this is Intel). Next, select
partition, and on the next screen the file system type (ext2/ext3 or other).
Set the directory where we want to put the recovered files and press "Y".
The directory must be on a different partition/disk, otherwise you run the risk of aggravating
situation, overwriting deleted files with new data.

Everything, the recovery process has begun, it can last from 10 minutes to
several hours, depending on the "old age" of the file system and the number of
deleted files. You can stop the process at any time by clicking , And
resume it from where it left off by restarting PhotoRec.

In the directory of your choice, you will find a lot of subdirectories with names like
recup_dir.1, recup_dir.2, each containing a large number of files
different type. PhotoRec does not restore names, so you have to tinker with
raking this whole heap.
PhotoRec also has other disadvantages:

  1. Quite often it crashes, and files can be damaged,
    therefore, they should be checked for "brokenness" without fail.
  2. The program searches for files by patterns. If you have deleted a file whose format
    PhotoRec is not supported - write wasted.

Therefore, in addition to photorec, it is necessary to have other means at hand.
analysis and recovery of lost data. The best in this field is
Sleuth Kit utilities,
containing a huge number of a wide variety of tools that love
use in their work various services for investigating incidents of hacking and
advanced system administrators. We are far from it, and we are interested in
only two utilities from the whole set: fls and icat, designed to search and
extracting files (both existing and deleted).

Let's view the list of deleted files using the fls utility:

# fls -rd /dev/sdb1
r/r*117: dsc0005.jpg
r/r*119: dsc0006.jpg
r/r*122: dsc0007.jpg
r/r*125: dsc0008.jpg
r/r*128: dsc0009.jpg

The "-r" flag causes the program to recursively go through all directories, and "-d"
- show only deleted files.

Most likely, the listing will be very long, and it will also contain a list
inodes that have already been given to other files (the realloc line in the third
column), so we filter it and send it to less:

# fls -rd /dev/sda1 | grep -v "(realloc)" | less

In the third column you will see the inode numbers, and in the fourth - their names.
To extract a file from the FS, use the icat command (the "-r" flag is for
to recover a deleted file):

# icat -r /dev/sda1 1023 > /home/vasya/tmp/my_file

To restore all files, you can use the following command:

# for i in `fls -rd /dev/sda1 | grep -v "(realloc)" |\
awk("print $3")|tr -d [:]`; do icat -r -f fat /dev/sdb1 $i >\
/home/vasya/tmp/inode-$i ;done

If you want to find a specific file, then the output of fls can simply be "warmed":

# fls -rd /dev/sda1 | grep -v "(realloc)" | grep my_file.jpg

The great thing about the Sleuth Kit utilities is that they use
a wide variety of methods for searching for deleted files and their parts. This and
analysis of file system control structures, and various heuristic methods,
and pattern matching. In fact, with the Sleuth Kit it is possible to return to
life, even files overwritten on ext3 (despite the fact that the ext3 developers themselves talk about
the impossibility of carrying out such an operation).

Fixing file systems

Fix broken file system very simple. Enough
use the standard fsck.vfat utilities (for FAT12 file systems,
FAT16 and FAT32), fsck.ufs (for UFS, UFS2, FFS), and ntfsfix (for NTFS).

Unfortunately, ntfsfix is ​​unable to completely fix NTFS. She only fixes
some of its problems and sets the forced file check flag.
system, so that the next reboot into Windows will launch
chkdsk for full FS check.

Using virtual machine, we can avoid the need to reload in
Windows. For this:

  1. We start the virtual machine and install Windows on the virtual
    HDD.
  2. Unmount the partition containing the NTFS file system.
  3. We start the virtual machine, as the first hard disk of which
    indicate virtual disk with Windows, and the second one is our real hard
    disk.
  4. By using standard means Windows starts checking the NTFS partition.

Partition copying

Let's say you bought a new hard drive and want to move some partitions
from the old disk to the new one. If you start doing it the standard way,
through creating a new partition and manually copying files, then you risk having
a lot of problems related to filename encodings, special files,
protected files, and you will lose a lot of time. It is better to use the method
partition cloning.

UNIX users clone partitions with standard utility dd, which
can be used in conjunction with any file system. To do this on a new disk
a partition is created that is identical in size to the source, and the command "dd if=partition1
of=partition2 bs=1m". In the same way, you can copy an NTFS partition, but in a package
ntfsprogs is a better utility for this purpose.

The ntfsclone program is identical in functionality to the dd command except for
two features. First, it does not copy unused portions of the file
system, and the movement is faster, and the partition image (if you create
image) takes up less space. Secondly, ntfsclone is able to store the image in
special compressed file which is convenient to transfer to other machines.

To clone a partition, just run the following command:

# ntfsclone --overwrite /dev/hda1 /dev/hdb1

And to create an image:

# ntfsclone --save-image --output backup.img /dev/hda1

The ntfsclone utility is especially handy if you decide to copy the installed
Windows on a whole fleet of other machines (classroom or office). For this
it is enough to install Windows on one machine and create an image, which then
can be laid out in a ball and with using Linux LiveCD pour on other machines. To
they were able to boot, you will also have to copy the disk's MBR record:

# sfdisk -d /dev/sda > /share/sda-sfdisk.dump
# dd if=/dev/sda bs=512 count=1 of=/share/sda-mbr.dump

And then write it to the disk of all machines:

# sfdisk /dev/sda< /share/sda-sfdisk.dump
# dd if=/share/sda-mbr.dump of=/dev/sda

Data transfer

What to do if you decide to completely switch to Linux, but do not want to
use various tricks and ntfs-3g to access your old data,
located on an NTFS partition? After all, this section can occupy most of the
disk, and there is no way to simply copy its contents to a new
partition formatted in ext3/ext4. In this case, they will come to your aid again
utilities from the ntfsprogs package, or rather one of them - ntfsresize, which will allow
copy data in small portions to a new file system, and then
reducing the size of the NTFS partition and increasing the ext3 / ext4 partition. For this you
you will need some kind of LiveCD containing ntfsprogs and e2fsprogs at least version
1.41 (for ext4 support, if you are going to transfer data to
her). It is also very desirable that the LiveCD contains a fresh gparted, because
that manually resizing is difficult and dangerous (other than resizing the file system itself,
have to resize the partition using fdisk, one mistake and the whole operation
will have to start over).

So, we boot from the LiveCD and mount the hard disk partitions. Let's say it
the size is 120 GB. Of these, 80 GB is a fully stuffed NTFS partition, and
the remaining 30 GB (yes, exactly 30, after the transfer of marketing gigabytes to
the real volume of the disk turns out to be approximately 111 GB) - this is a partition with
installed Linux, which is occupied by 5 GB. So our window
equals approximately 25 GB. Move files from NTFS partition to ext3/ext4 partition
until their combined size is equal to the size of the window. As a result
the latter is completely filled, and the first "loses weight" by 25 GB.
Unmount both partitions and run gparted. Select the NTFS partition, click the second one
mouse button, select Resize/Move and reduce the section to the size of the window, select
ext3/ext4 partition and increase it by the same window size (the partition will have to
move to the beginning of the disk, and then increase). So we get another 25 GB
freed space, which will allow us to copy some of the files, and then again
resize. Four such passes, and we completely delete the NTFS partition, and
the ext3/ext4 partition is expandable to the entire disk.

conclusions

As you can see, Linux can not only work with many third-party
file systems, but is also equipped with a mass of utilities for modifying them, carrying out
diagnostics and other operations. You will never find yourself in a hopeless
situations, keeping a LiveCD at hand on Linux-based, which is just that
the most holy grail of any system administrator and user.

www

Foremost, another popular software for
restoring files by templates.

www.sysresccd.org -
The System Rescue CD contains all the programs mentioned in the article.

I will share a small find, a small program for recovering deleted files. Some time ago it was very necessary, but then I did not find the Scalpel program, unfortunately. In my opinion, of all the methods known to me, this is one of the simplest. Scalpel came from the .

And so the fans of rm -rf are dedicated to:

First and foremost, no one guarantees that Scalpel will be able to recover your files, but chances are there.

Installation (since Ubuntu is installed on the test machine, I will talk about it):

sudo apt-get install scalpel

Before using Scalpel, let's edit the settings file:
sudo nano /etc/scalpel/scalpel.conf

In it, you need to specify the files of what type we will restore (by default, more than one type is not selected). I chose doc and pdf files for recovery:

doc y 10000000 \xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1\x00\x00 \xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1\x00\x00 NEXT
doc y 10000000 \xd0\xcf\x11\xe0\xa1\xb1

pdf y 5000000%PDF %EOF\x0d REVERSE
pdf y 5000000%PDF %EOF\x0a REVERSE

Now you can start recovery:

scalpel /dev/sda1 -o output

-o shows the directory where the recovered files will be stored, if the directory with the same name already exists (and is not empty) Scalpel will not start.
/ dev / sda1 - actually the volume that we will wool for lost files.
The list can be viewed using the mount command:
[email protected]:~$ mount
/dev/sda1 on / type ext3 (rw, relatime, errors=remount-ro)
proc on /proc type proc (rw, noexec, nosuid, nodev)
/sys on /sys type sysfs (rw, noexec, nosuid, nodev)
varrun on /var/run type tmpfs (rw, noexec, nosuid, nodev, mode=0755)
udev on /dev type tmpfs (rw, mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw, gid=5, mode=620)
lrm on /lib/modules/2.6.24–21-generic/volatile type tmpfs (rw)
/dev/sda2 on /home type ext3 (rw, relatime)

After working out, go to the output directory and see what is there:

[email protected]:~/output$ ls -l
-rw-r--r-- 1 root root 28189 2009–03–24 14:42 audit.txt
drwxr-xr-x 2 root root 4096 2009-03-24 14:42 doc-3-0
drwxr-xr-x 2 root root 4096 2009-03-24 14:42 doc-3-1
drwxr-xr-x 2 root root 4096 2009-03-24 14:42 doc-3-2
drwxr-xr-x 2 root root 4096 2009-03-24 14:42 doc-4-0

drwxr-xr-x 2 root root 4096 2009-03-24 14:42 pdf-5-0
drwxr-xr-x 2 root root 4096 2009-03-24 14:42 pdf-6-0

The audit.txt file stores information about the recovery:

[email protected]:~/output$ cat audit.txt

Scalpel version 1.60 audit file
Started at Tue Mar 24 14:16:04 2009
command line:
scalpel /dev/sda1 -o output

Output directory: /home/username/output
Configuration file: /etc/scalpel/scalpel.conf

Opening target "/dev/sda1"

The following files were carved:
File Start Chop Length Extracted From
00053045.doc 183664640 YES 10000000 sda1
00053046.doc 183971840 YES 10000000 sda1

00050372.doc 203272192 NO 208896 sda1
00050373.doc 203481088 NO 229376 sda1

Completed at Tue Mar 24 14:42:41 2009

We look into the nested directories and see (if we're lucky) our files:

[email protected]:~/output/doc-3–0$ ls -l
total 25564
-rw-r--r-- 1 root root 307200 2009–03–24 14:42 00050348.doc
-rw-r--r-- 1 root root 40960 2009-03-24 14:42 00050349.doc
-rw-r--r-- 1 root root 4354 2009–03–24 14:42 00050350.doc
-rw-r--r-- 1 root root 466686 2009–03–24 14:42 00050351.doc
-rw-r--r-- 1 root root 176128 2009-03-24 14:42 00050352.doc

Source - HowtoForge (free translation).

I'll add from myself Scalpel restored far from everything, of course. But a lot, I even forgot about some files already. It works very slowly, eats almost the entire processor during operation.

Scalpel can work with FAT, NTFS, ext 2/3 file systems, that is, you can recover data from win-partitions.

And finally, best way restore very important files is:
1. Make backups.
2. It is very good to think before removal.

Happy data recovery!

Recovery of deleted data is real until you overwrite other information in their place. This is true for any media, so in Mint and other builds of Linux or Windows return erased files are produced according to the same scheme, only the tools differ. Below you will find instructions for working with some programs that are great at recovering deleted data on Linux.

Recovery via Photorec

The utility, as the name suggests, was created specifically to search for deleted photos. However, over time, the application has turned into a powerful program that finds and returns files of various formats from oblivion. The only condition for successful recovery of deleted data is that nothing should be written in their place. Therefore, immediately after the loss of files, you must stop working with the disk from which they were deleted. Copying new files, changing the password - nothing worth doing.

Photorec is distributed free of charge as part of the TestDisk package and does not require a registration key. To install it on Linux Mint or another version, open a terminal and run "sudo apt-get install testdisk". To run the program, use the "sudo photorec" command.

  1. After starting the application to recover files deleted from the system, enter the user password set on Linux Mint. By entering the password, you will see all the connected drives that are defined in the system. If there is no password, then you do not need to enter anything, the connected media will be displayed immediately. Using the arrows on your keyboard, select the partition where the erased data was stored and press Enter.
  2. In the next window, you can start the search right away or tweak the criteria a bit by filtering out files that you don't need to recover. If you immediately start searching for data deleted from their system, then you will take a long time to parse the file “garbage”. Photorec can find things that the user has long forgotten about, so it's better to limit the program a bit. Highlight "File Opt" (use the right arrow to move) and press Enter.
  3. By default, all file types are selected. But in order not to overload the system with unnecessary work, uncheck all the boxes by pressing the "S" key. Then use the arrows to highlight the data formats you want to restore and press the space bar to mark.
  4. Then return to the previous window. Select the FAT32 format and start the search with the "Search" button.
  5. Leave the selection on "Other".
  6. Select the data search mode. If "Free" is selected, Photorec will only search for deleted files in empty space. If you select the “Whole” mode, then the program will scan the entire surface, which will make it possible to restore files that have been deleted from the system so long ago that the user forgot about them.
  7. The last step is to select the directory where the data found by the program will be saved. To start scanning, press the "C" key in the English layout.

The main rule of recovery - never save files to the partition from which they were deleted. It is better to use removable media, when the recovery is completed, just transfer the data back to the system. All data that Photorec manages to find and recover will be in the folder you specified in the last step. The file names will change, so some time will have to be spent on parsing the data, but this is not as critical as the loss of important information.

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE: