Você está na página 1de 10

Recuperar NTFS Se voc apagou um arquivo importante do computador e agora quer reaver este arquivo.

J utilizou diversos aplicativos e no conseguiu ter o resultado desejado, voc pode usar o Ubuntu para fazer essa recuperao. Lembrando que voc no precisa instalar o Ubuntu, basta rodar a verso Live CD. Visitando o site do Baixaki, achei um tutorial ensinando a usar o Live CD e resolvi colocar aqui no Viso Digital. Para explicar o passo a passo, quatro arquivos foram criados e depois deletados da rea de trabalho de um computador rodando Windows 7 Home Premium. Eles consistiam em dois documentos de texto um no formato DOC e o outro em TXT e dois arquivos de imagens, sendo um JPG e o segundo BMP. A verso do Ubuntu utilizada foi a 10.04 Lucid Lynx beta 1, mas voc pode utilizar as anteriores sem problema algum. aconselhado usar da verso 9.04 em diante, uma vez que elas j possuem todos os recursos necessrios instalados no Live CD. 1. Reiniciando o Sistema Para dar incio recuperao de seus arquivos insira o pendrive ou Live CD do Ubuntu no computador e o reinicie. Isso far com que o sistema operacional do pinguim seja iniciado e comece a rodar diretamente do dispositivo mvel escolhido, sem alterar nada em seu HD e com todos os recursos oferecidos pela verso instalada disponveis para uso. 2. Abrir o Terminal O passo seguinte abrir o famoso Terminal de comandos do Ubuntu. Voc o encontra na opo Acessrios do menu Aplicativos.

3. Digitando os comandos necessrios Para conseguir recuperar os arquivos deletados, preciso antes identificar o disco rgido no qual voc deseja procurar os documentos. Na janela do Terminal que foi aberta, digite o seguinte comando: sudo fdisk -l Pressione a tecla Enter e aguarde alguns segundos at que as informaes do HD sejam mostradas na tela. 4. O que procurar? O que voc est procurando no resultado do comando acima uma linha que termina com HPSF/NTFS, pois ela exibe os dados de que precisamos a respeito da partio com Windows. Anote os dados correspondentes coluna Device da tabela (circulado em vermelho na imagem abaixo).

Se h mais de um disco rgido instalado com formato NTFS ser preciso identificar corretamente aquele do qual voc deseja recuperar os arquivos. Uma boa estratgia para diferenciar um HD do outro pelo tamanho deles. Olhando a segunda linha da imagem acima possvel identificar o campo Disk /dev/sdx, o qual mostra o tamanho do disco ali identificado. 5. Lista de arquivos recuperveis Agora que voc j sabe como o disco desejado est identificado no sistema, hora de verificar quais arquivos podem ser recuperados. Para isso, digite o seguinte comando no Terminal: sudo ntfsundelete No caso do HD que foi utilizado para os testes, o comando seria: # ntfsundelete /dev/sda2

Isso porque ao digitar o primeiro comando (fdisk) o nome do disco rgido desejado aparece como /dev/sda2. Caso o seu HD tenha outro nome, fique atento para digitar o comando corretamente. 6. Interpretando e filtrando o resultado O resultado do comando acima uma lista de arquivos que foram deletados do disco. Ela pode ser enorme, ento no se assuste caso parea que o Terminal enlouqueceu depois de voc apertar a tecla Enter. Existem trs colunas muito importantes nesta lista: Inode, %age e Filename. A primeira delas, Inode, mostra o nmero de identificao de cada um dos arquivos. Note que para cada linha da tabela esse nmero muda. Isso acontece porque o Inode funciona como se fosse o RG do arquivo, ou seja, no podem existir dois iguais. A segunda coluna de interesse, %age, talvez a mais importante, uma vez que ela mostra qual porcentagem do arquivo poder ser recuperada. Arquivos com 100% de %age podem ser totalmente recuperados, enquanto documentos com 0% de %age podem ser considerados perdidos. Por fim, a coluna Filename da tabela mostra o nome dos arquivos apagados.

Para saber se o arquivo desejado pode ser recuperado preciso encontr-lo na lista exibida. Se o HD foi pouco usado, tudo bem. O problema quando o disco rgido j est em uso h um tempo. A lista de documentos removidos vai parecer no ter fim. A fim de facilitar a busca o usurio pode criar alguns filtros utilizando o pipe junto com o comando grep. Grep? Pipe? Que tal uma ajuda? O pipe, representado pela barra vertical, permite a combinao de vrios comandos no Linux, enquanto que o grep utilizado na criao de filtros, no intuito de diminuir o nmero de resultados. Por exemplo, para mostrar apenas os arquivos do tipo DOC que foram deletados do computador possvel utilizar a seguinte combinao de comando: # ntfsundelete /dev/sda2 | grep .doc Explicando Aquela lista enorme de documentos apagados enviada para o comando grep por meio do |. O grep, por sua vez, vai mostrar na tela apenas as linhas que contenham .doc em seu contedo. O comando grep bem poderoso e permite criar os mais diversos filtros,

s usar a imaginao! 7. Recuperar Agora que voc j sabe como identificar o disco rgido, listar os arquivos deletados e filtrar os resultados, finalmente hora de recuperar os documentos. Existem duas maneiras de fazer a recuperao: pelo nome do arquivo ou atravs do Inode. Os dois modos restauram o arquivo da mesma maneira. A nica diferena est no comando que ser utilizado. Para recuperar o arquivo atravs do nome digite o seguinte comando no Terminal: # ntfsundelete u m Caso voc prefira utilizar o Inode para restaurar o arquivo s digitar: # ntfsundelete u i

8- Finalizar Os arquivos recuperados foram enviados para a Pasta Pessoal do Ubuntu, mas ainda no podem ser abertos ou utilizados, pois no so reconhecidos pelo sistema operacional. O comando abaixo faz com que os documentos sejam modificados e reconhecidos. # chown ubuntu <Files> <Files> so todos os arquivos que devem ser alterados. Se ocorrer tudo bem na operao, o cone dos documentos vai mudar, conforme mostra a figura abaixo.

Pronto, agora voc pode copiar os arquivos para um pendrive e respirar aliviado! Embora parea complicado em um primeiro momento, o procedimento para recuperao de arquivos e documentos simples, basta seguir as instrues com cuidado.

Name
ntfsundelete - recover a deleted file from an NTFS volume.

Synopsis
ntfsundelete [options] device

Description
ntfsundelete has three modes of operation: scan, undelete and copy.

Scan
The default mode, scan simply reads an NTFS Volume and looks for files that have been deleted. Then it will print a list giving the inode number, name and size.

Undelete
The undelete mode takes the files either matching the regular expression (option -m) or specified by the inode-expressions and recovers as much of the data as possible. It saves the result to another location. Partly for safety, but mostly because NTFS write support isnt finished.

Copy
This is a wizards option. It will save a portion of the MFT to a file. This probably only be useful when debugging ntfsundelete

Notes
ntfsundelete only ever reads from the NTFS Volume. ntfsundelete will never change the volume.

Caveats
Miracles
ntfsundelete cannot perform the impossible. When a file is deleted the MFT Record is marked as not in use and the bitmap representing the disk usage is updated. If the power isnt turned off immediately, the free space, where the file used to live, may become overwritten. Worse, the MFT Record may be reused for another file. If this happens it is impossible to tell where the file was on disk. Even if all the clusters of a file are not in use, there is no guarantee that they havent been overwritten by some short-lived file.

Locale
In NTFS all the filenames are stored as Unicode. They will be converted into the current locale for display by ntfsundelete. The utility has successfully displayed some Chinese pictogram filenames and then correctly recovered them.

Extended MFT Records


In rare circumstances, a single MFT Record will not be large enough to hold the metadata describing a file (a file would have to be in hundreds of fragments for this to happen). In these cases one MFT record may hold the filename, but another will hold the information about the data. ntfsundelete will not try and piece together such records. It will simply show unnamed files with data.

Compressed and Encrypted Files


ntfsundelete cannot recover compressed or encrypted files. When scanning for them, it will display as being 0% recoverable.

The Recovered Files Size and Date


To recover a file ntfsundelete has to read the files metadata. Unfortunately, this isnt always intact. When a file is deleted, the metadata can be left in an inconsistent state. e.g. the file size may be zero; the dates of the file may be set to the time it was deleted, or random. To be safe ntfsundelete will pick the largest file size it finds and write that to disk. It will also try and set the files date to the last modified date. This date may be the correct last modified date, or something unexpected.

Options
Below is a summary of all the options that ntfsundelete accepts. Nearly all options have two equivalent names. The short name is preceded by - and the long name is preceded by --. Any single letter options, that dont take an argument, can be combined into a single command, e.g. -fv is equivalent to -f -v. Long named options can be abbreviated to any unique prefix of their name. -b, --byte NUM If any clusters of the file cannot be recovered, the missing parts will be filled with this byte. The default is zeros. -C, --case When scanning an NTFS volume, any filename matching (using the --match option) is case-insensitive. This option makes the matching case-sensitive. -c, --copy RANGE This wizards option will write a block of MFT FILE records to a file. The default file is mft which will be created in the current directory. This option can be combined with the --output and --destination options. -d, --destination DIR This option controls where to put the output file of the --undelete and --copy options. -f, --force This will override some sensible defaults, such as not overwriting an existing file. Use this option with caution. -h, --help Show a list of options with a brief description of each one. -i, --inodes RANGE Recover the files with these inode numbers. RANGE can be a single inode number, several numbers separated by commas "," or a range separated by a dash "-". -m, --match PATTERN Filter the output by only looking for matching filenames. The pattern can include the wildcards ?, match exactly one character or *, match zero or more characters. By default the matching is case-insensitive. To make the search case sensitive, use the --case option. -O, --optimistic Recover parts of the file even if they are currently marked as in use. -o, --output FILE Use this option to set name of output file that --undelete or --copy will create. -P, --parent Display the parent directory of a deleted file. -p, --percentage NUM Filter the output of the --scan option, by only matching files with a certain amount of recoverable content. Please read the caveats section for more details. -q, --quiet Reduce the amount of output to a minimum. Naturally, it doesnt make sense to combine this option with --scan. -s, --scan Search through an NTFS volume and print a list of files that could be recovered. This is the default action of ntfsundelete. This list can be filtered by filename,

size, percentage recoverable or last modification time, using the --match, --size, --percent and --time options, respectively. The output of scan will be:

Inode 6038

Flags FN..

%age 93%

Date 2002-07-17

Size 26629

Filename thesis.doc

Flag Description F/D File/Directory N/R (Non-)Resident data stream C/E Compressed/Encrypted data stream ! Missing attributes The percentage field shows how much of the file can potentially be recovered. -S, --size RANGE Filter the output of the --scan option, by looking for a particular range of file sizes. The range may be specified as two numbers separated by a -. The sizes may be abbreviated using the suffixes k, m, g, t, for kilobytes, megabytes, gigabytes and terabytes respectively. -t, --time SINCE Filter the output of the --scan option. Only match files that have been altered since this time. The time must be given as number using a suffix of d, w, m, y for days, weeks, months or years ago. -T, --truncate If ntfsundelete is confident about the size of a deleted file, then it will restore the file to exactly that size. The default behaviour is to round up the size to the nearest cluster (which will be a multiple of 512 bytes). -u, --undelete Select undelete mode. You can specify the files to be recovered using by using -match or --inodes options. This option can be combined with --output, -destination, and --byte. When the file is recovered it will be given its original name, unless the --output option is used. -v, --verbose Increase the amount of output that ntfsundelete prints. -V, --version Show the version number, copyright and license for ntfsundelete.

Examples
Look for deleted files on /dev/hda1. ntfsundelete /dev/hda1

Look for deleted documents on /dev/hda1. ntfsundelete /dev/hda1 -s -m *.doc Look for deleted files between 5000 and 6000000 bytes, with at least 90% of the data recoverable, on /dev/hda1. ntfsundelete /dev/hda1 -S 5k-6m -p 90 Look for deleted files altered in the last two days ntfsundelete /dev/hda1 -t 2d Undelete inodes 2, 5 and 100 to 131 of device /dev/sda1 ntfsundelete /dev/sda1 -u -i 2,5,100-131 Undelete inode number 3689, call the file work.doc and put it in the users home directory. ntfsundelete /dev/hda1 -u -i 3689 -o work.doc -d ~ Save MFT Records 3689 to 3690 to a file debug ntfsundelete /dev/hda1 -c 3689-3690 -o debug And Linux saves the day again. My son installed an application but mistakenly he selected the data directory as the installation directory. When he realized it he decided to uninstall, but the full uninstall deleted everything from the folder. This is: the program and all his files. The solution was very easy. I found that I had already installed the ntfsprogrs package. This package contains a pretty slick utility called ntfsundelete. This utility allowed me to first list the files that I could recover and then recover them. It has some very useful filters such as:

File name pattern matching: For example to search/undelete files *.mp3 Files modified since: Maybe you don't care about old deleted files just files modified since 5 months ago Percentage recoverable: In some cases you want to salvage whatever you can, in some cases you only care if you can recover 90% or more, for example. Files within a specific size range

In my case it was a breeze to use it. I first unmounted the partition where the deleted files were
# umount /dev/sda2

I then executed the following to list which deleted mp3 files located in my /dev/sda2 device that were modified in the last 5 months were 100% recoverable:
# ntfsundelete /dev/sda2 -m '*.mp3' -p 100 -t 5m > deletedmp3.txt

That created a file called deletedmp3.txt with a list of files. Once I reviewed the list I went on to undelete them and put the undeleted files on my external HDD on a folder called undeleted
# ntfsundelete /dev/sda2 -u -m '*.mp3' -p 100 -t 5m -d /media/externalExt3/undeleted

If you want to know how to fully use this utility just open a console and type
man ntfsundelete

Important things to consider


If you deleted using the file manager first check if your files are in the trash can, that's always the easiest way As soon as you realize that you mistakenly deleted the files, don't write anything else to that partition. if possible unmount it right away If you want to do it in a computer that does not have linux installed, you can always use a live CD distribution that includes the ntfsundelete utility

Você também pode gostar