summaryrefslogtreecommitdiff
path: root/ntfsprogs/ntfsundelete.8 (plain)
blob: 18de27f40d652eb7ce28ce447ec9f150c571f882
1.\" Copyright (c) 2002\-2005 Richard Russon.
2.\" This file may be copied under the terms of the GNU Public License.
3.\"
4.TH NTFSUNDELETE 8 "November 2005" "ntfs-3g 2014.2.15"
5.SH NAME
6ntfsundelete \- recover a deleted file from an NTFS volume.
7.SH SYNOPSIS
8.B ntfsundelete
9[\fIoptions\fR] \fIdevice\fR
10.SH DESCRIPTION
11.B ntfsundelete
12has three modes of operation:
13.IR scan ,
14.I undelete
15and
16.IR copy .
17.SS Scan
18.PP
19The default mode,
20.I scan
21simply reads an NTFS Volume and looks for files that have been deleted. Then it
22will print a list giving the inode number, name and size.
23.SS Undelete
24.PP
25The
26.I undelete
27mode takes the files either matching the regular expression (option \-m)
28or specified by the inode\-expressions and recovers as much of the data
29as possible. It saves the result to another location. Partly for
30safety, but mostly because NTFS write support isn't finished.
31.SS Copy
32.PP
33This is a wizard's option. It will save a portion of the MFT to a file. This
34probably only be useful when debugging
35.I ntfsundelete
36.SS Notes
37.B ntfsundelete
38only ever
39.B reads
40from the NTFS Volume.
41.B ntfsundelete
42will never change the volume.
43.SH CAVEATS
44.SS Miracles
45.B ntfsundelete
46cannot perform the impossible.
47.PP
48When a file is deleted the MFT Record is marked as not in use and the bitmap
49representing the disk usage is updated. If the power isn't turned off
50immediately, the free space, where the file used to live, may become
51overwritten. Worse, the MFT Record may be reused for another file. If this
52happens it is impossible to tell where the file was on disk.
53.PP
54Even if all the clusters of a file are not in use, there is no guarantee that
55they haven't been overwritten by some short\-lived file.
56.SS Locale
57In NTFS all the filenames are stored as Unicode. They will be converted into
58the current locale for display by
59.BR ntfsundelete .
60The utility has successfully displayed some Chinese pictogram filenames and then
61correctly recovered them.
62.SS Extended MFT Records
63In rare circumstances, a single MFT Record will not be large enough to hold the
64metadata describing a file (a file would have to be in hundreds of fragments
65for this to happen). In these cases one MFT record may hold the filename, but
66another will hold the information about the data.
67.B ntfsundelete
68will not try and piece together such records. It will simply show unnamed files
69with data.
70.SS Compressed and Encrypted Files
71.B ntfsundelete
72cannot recover compressed or encrypted files. When scanning for them, it will
73display as being 0% recoverable.
74.SS The Recovered File's Size and Date
75To recover a file
76.B ntfsundelete
77has to read the file's metadata. Unfortunately, this isn't always intact.
78When a file is deleted, the metadata can be left in an inconsistent state. e.g.
79the file size may be zero; the dates of the file may be set to the time it was
80deleted, or random.
81.br
82To be safe
83.B ntfsundelete
84will pick the largest file size it finds and write that to disk. It will also
85try and set the file's date to the last modified date. This date may be the
86correct last modified date, or something unexpected.
87.SH OPTIONS
88Below is a summary of all the options that
89.B ntfsundelete
90accepts. Nearly all options have two equivalent names. The short name is
91preceded by
92.B \-
93and the long name is preceded by
94.BR \-\- .
95Any single letter options, that don't take an argument, can be combined into a
96single command, e.g.
97.B \-fv
98is equivalent to
99.BR "\-f \-v" .
100Long named options can be abbreviated to any unique prefix of their name.
101.TP
102\fB\-b\fR, \fB\-\-byte\fR NUM
103If any clusters of the file cannot be recovered, the missing parts will be
104filled with this byte. The default is zeros.
105.TP
106\fB\-C\fR, \fB\-\-case\fR
107When scanning an NTFS volume, any filename matching (using the
108.B \-\-match
109option) is case\-insensitive. This option makes the matching case\-sensitive.
110.TP
111\fB\-c\fR, \fB\-\-copy\fR RANGE
112This wizard's option will write a block of MFT FILE records to a file. The
113default file is
114.I mft
115which will be created in the current directory. This option can be combined
116with the
117.B \-\-output
118and
119.B \-\-destination
120options.
121.TP
122\fB\-d\fR, \fB\-\-destination\fR DIR
123This option controls where to put the output file of the
124.B \-\-undelete
125and
126.B \-\-copy
127options.
128.TP
129\fB\-f\fR, \fB\-\-force\fR
130This will override some sensible defaults, such as not overwriting an existing
131file. Use this option with caution.
132.TP
133\fB\-h\fR, \fB\-\-help\fR
134Show a list of options with a brief description of each one.
135.TP
136\fB\-i\fR, \fB\-\-inodes\fR RANGE
137Recover the files with these inode numbers.
138.I RANGE
139can be a single inode number, several numbers separated by commas "," or a
140range separated by a dash "\-".
141.TP
142\fB\-m\fR, \fB\-\-match\fR PATTERN
143Filter the output by only looking for matching filenames. The pattern can
144include the wildcards '?', match exactly one character or '*', match zero or
145more characters. By default the matching is case\-insensitive. To make the
146search case sensitive, use the
147.B \-\-case
148option.
149.TP
150\fB\-O\fR, \fB\-\-optimistic\fR
151Recover parts of the file even if they are currently marked as in use.
152.TP
153\fB\-o\fR, \fB\-\-output\fR FILE
154Use this option to set name of output file that
155.B \-\-undelete
156or
157.B \-\-copy
158will create.
159.TP
160\fB\-P\fR, \fB\-\-parent\fR
161Display the parent directory of a deleted file.
162.TP
163\fB\-p\fR, \fB\-\-percentage\fR NUM
164Filter the output of the
165.B \-\-scan
166option, by only matching files with a certain amount of recoverable content.
167.B Please read the caveats section for more details.
168.TP
169\fB\-q\fR, \fB\-\-quiet\fR
170Reduce the amount of output to a minimum. Naturally, it doesn't make sense to
171combine this option with
172.BR \-\-scan .
173.TP
174\fB\-s\fR, \fB\-\-scan\fR
175Search through an NTFS volume and print a list of files that could be recovered.
176This is the default action of
177.BR ntfsundelete .
178This list can be filtered by filename, size, percentage recoverable or last
179modification time, using the
180.BR \-\-match ,
181.BR \-\-size ,
182.B \-\-percent
183and
184.B \-\-time
185options, respectively.
186.sp
187The output of scan will be:
188.sp
189.nf
190Inode Flags %age Date Time Size Filename
191 6038 FN.. 93% 2002\-07\-17 13:42 26629 thesis.doc
192.fi
193.TS
194box;
195lB lB
196l l.
197Flag Description
198F/D File/Directory
199N/R (Non\-)Resident data stream
200C/E Compressed/Encrypted data stream
201! Missing attributes
202.TE
203.sp
204.sp
205The percentage field shows how much of the file can potentially be recovered.
206.TP
207\fB\-S\fR, \fB\-\-size\fR RANGE
208Filter the output of the
209.B \-\-scan
210option, by looking for a particular range of file sizes. The range may be
211specified as two numbers separated by a '\-'. The sizes may be abbreviated
212using the suffixes k, m, g, t, for kilobytes, megabytes, gigabytes and terabytes
213respectively.
214.TP
215\fB\-t\fR, \fB\-\-time\fR SINCE
216Filter the output of the
217.B \-\-scan
218option. Only match files that have been altered since this time. The time must
219be given as number using a suffix of d, w, m, y for days, weeks, months or years
220ago.
221.TP
222\fB\-T\fR, \fB\-\-truncate\fR
223If
224.B ntfsundelete
225is confident about the size of a deleted file, then it will restore the file to
226exactly that size. The default behaviour is to round up the size to the nearest
227cluster (which will be a multiple of 512 bytes).
228.TP
229\fB\-u\fR, \fB\-\-undelete\fR
230Select
231.B undelete
232mode. You can specify the files to be recovered using by using
233.B \-\-match
234or
235.B \-\-inodes
236options. This option can be combined with
237.BR \-\-output ,
238.BR \-\-destination ,
239and
240.BR \-\-byte .
241.sp
242When the file is recovered it will be given its original name, unless the
243.B \-\-output
244option is used.
245.TP
246\fB\-v\fR, \fB\-\-verbose\fR
247Increase the amount of output that
248.B ntfsundelete
249prints.
250.TP
251\fB\-V\fR, \fB\-\-version\fR
252Show the version number, copyright and license for
253.BR ntfsundelete .
254.SH EXAMPLES
255Look for deleted files on /dev/hda1.
256.RS
257.sp
258.B ntfsundelete /dev/hda1
259.sp
260.RE
261Look for deleted documents on /dev/hda1.
262.RS
263.sp
264.B ntfsundelete /dev/hda1 \-s \-m '*.doc'
265.sp
266.RE
267Look for deleted files between 5000 and 6000000 bytes, with at least 90% of the
268data recoverable, on /dev/hda1.
269.RS
270.sp
271.B ntfsundelete /dev/hda1 \-S 5k\-6m \-p 90
272.sp
273.RE
274Look for deleted files altered in the last two days
275.RS
276.sp
277.B ntfsundelete /dev/hda1 \-t 2d
278.sp
279.RE
280Undelete inodes 2, 5 and 100 to 131 of device /dev/sda1
281.RS
282.sp
283.B ntfsundelete /dev/sda1 \-u \-i 2,5,100\-131
284.sp
285.RE
286Undelete inode number 3689, call the file 'work.doc', set it to recovered
287size and put it in the user's home directory.
288.RS
289.sp
290.B ntfsundelete /dev/hda1 \-u \-T \-i 3689 \-o work.doc \-d ~
291.sp
292.RE
293Save MFT Records 3689 to 3690 to a file 'debug'
294.RS
295.sp
296.B ntfsundelete /dev/hda1 \-c 3689\-3690 \-o debug
297.sp
298.RE
299.SH BUGS
300There are some small limitations to
301.BR ntfsundelete ,
302but currently no known bugs. If you find a bug please send an email describing
303the problem to the development team:
304.br
305.nh
306ntfs\-3g\-devel@lists.sf.net
307.hy
308.SH AUTHORS
309.B ntfsundelete
310was written by Richard Russon and Holger Ohmacht, with contributions from Anton
311Altaparmakov.
312It was ported to ntfs-3g by Erik Larsson and Jean-Pierre Andre.
313.SH AVAILABILITY
314.B ntfsundelete
315is part of the
316.B ntfs-3g
317package and is available from:
318.br
319.nh
320http://www.tuxera.com/community/
321.hy
322.SH SEE ALSO
323.BR ntfsinfo (8),
324.BR ntfsprogs (8)
325