]> wimlib.net Git - wimlib/blob - doc/man1/wimapply.1
5a7c4a856b3853ad6cfdd5a542216190aed7981c
[wimlib] / doc / man1 / wimapply.1
1 .TH WIMAPPLY "1" "August 2016" "wimlib 1.10.0" "User Commands"
2 .SH NAME
3 wimapply \- Apply a WIM image
4 .SH SYNOPSIS
5 \fBwimapply\fR \fIWIMFILE\fR [\fIIMAGE\fR] \fITARGET\fR [\fIOPTION\fR...]
6 .SH DESCRIPTION
7 \fBwimapply\fR, or equivalently \fBwimlib-imagex apply\fR, extracts ("applies")
8 an image, or all images, from the Windows Imaging (WIM) archive \fIWIMFILE\fR.
9 .PP
10 \fIIMAGE\fR specifies the image in \fIWIMFILE\fR to extract.  It may be the
11 1-based index of an image, the name of an image, or the keyword "all" to specify
12 all images.  It may be omitted if \fIWIMFILE\fR contains only one image.  You
13 can use \fBwiminfo\fR(1) to list the images contained in \fIWIMFILE\fR.
14 .PP
15 \fITARGET\fR specifies where to extract the image(s) to.  If \fITARGET\fR is a
16 directory, then the image(s) will be extracted to that directory as per
17 \fBDIRECTORY EXTRACTION (UNIX)\fR or \fBDIRECTORY EXTRACTION (WINDOWS)\fR.  If
18 \fITARGET\fR does not exist, then a directory will be created there first.
19 Alternatively, if \fITARGET\fR specifies a UNIX block device, then the image
20 will be extracted to it as described in \fBNTFS VOLUME EXTRACTION (UNIX)\fR.
21 .PP
22 Note that \fBwimapply\fR is designed to extract, or "apply", full WIM images.
23 If you instead want to extract only certain files or directories from a WIM
24 image, use \fBwimextract\fR(1) instead.
25 .PP
26 If \fIIMAGE\fR is "all", then all images in \fIWIMFILE\fR will be extracted into
27 subdirectories of \fITARGET\fR named after the images, falling back to the image
28 index when an image has no name or an unusual name.  This is not yet supported
29 in \fBNTFS VOLUME EXTRACTION (UNIX)\fR mode.
30 .PP
31 If \fIWIMFILE\fR is "-", then the WIM is read from standard input rather than
32 from disk.  See \fBPIPABLE WIMS\fR for more information.
33 .SH DIRECTORY EXTRACTION (UNIX)
34 On UNIX-like systems, a WIM image may be extracted to a directory.  This mode
35 has the limitation that NTFS or Windows-specific metadata will not be extracted.
36 Although some concepts such as hard links, symbolic links, last access
37 timestamps, and last modification timestamps will be translated to their UNIX
38 equivalents, other metadata will be lost (with warnings given).  Notably, the
39 following types of metadata will \fInot\fR be extracted in this mode:
40 .IP \[bu] 4
41 Windows file attribute flags
42 .IP \[bu]
43 Windows security descriptors (e.g. file owners and DACLs)
44 .IP \[bu]
45 File creation timestamps
46 .IP \[bu]
47 Reparse points other than symbolic links and junction points
48 .IP \[bu]
49 Named data streams
50 .IP \[bu]
51 Short filenames (also known as 8.3 names or DOS names).
52 .IP \[bu]
53 Object IDs
54 .PP
55 These same limitations apply to \fBwimextract\fR.  As such, this mode is most
56 useful in situations where NTFS or Windows-specific metadata is unimportant,
57 e.g. when wanting to extract specific files, or when doing file archiving only
58 on UNIX-like systems, possibly in combination with \fB--unix-data\fR.  When
59 Windows-specific metadata is important, then either the \fBNTFS VOLUME
60 EXTRACTION (UNIX)\fR mode should be used, or the Windows version of wimlib
61 should be used (see \fBDIRECTORY EXTRACTION (WINDOWS)\fR).
62 .SH NTFS VOLUME EXTRACTION (UNIX)
63 On UNIX-like systems, \fITARGET\fR may also be specified as a block device (e.g.
64 /dev/sda3) containing an unmounted NTFS volume.  In this mode, \fBwimapply\fR
65 uses libntfs-3g to apply the specified WIM image to the root directory of the
66 NTFS volume.  The target volume should be empty, e.g. newly created by
67 \fBmkntfs\fR(8).  In this mode, NTFS-specific and Windows-specific data and
68 metadata will be extracted, including the following:
69 .IP \[bu] 4
70 All data streams of all files except encrypted files, including the unnamed data
71 stream as well as all named data streams.
72 .IP \[bu]
73 Reparse points, including symbolic links, junction points, and other reparse
74 points.
75 .IP \[bu]
76 File and directory creation, access, and modification timestamps, using the
77 native NTFS resolution of 100 nanoseconds.
78 .IP \[bu]
79 Windows security descriptors, including all components (owner, group, DACL, and
80 SACL).
81 .IP \[bu]
82 Windows file attribute flags
83 .IP \[bu]
84 All names of all files, including names in the Win32 namespace, DOS namespace,
85 Win32+DOS namespace, and POSIX namespace.  This includes hard links.
86 .IP \[bu]
87 Object IDs.
88 .PP
89 However, encrypted files will not be extracted.
90 .PP
91 Regardless, since almost all information from the WIM image is restored in this
92 mode, it is possible (and fully supported) to restore an image of an actual
93 Windows installation using \fBwimapply\fR on a UNIX-like system as an
94 alternative to using \fBwimapply\fR or DISM on Windows.  In the \fBEXAMPLES\fR
95 section below, there is an example of applying an image from an "install.wim"
96 file as may be found in the Windows installation media.
97 .PP
98 Note that to actually boot Windows (Vista or later) from an applied
99 "install.wim" image, you also need to mark the partition as "bootable" and set
100 up various boot files, such as \\BOOTMGR and \\BOOT\\BCD.  The latter task is
101 most easily accomplished by running bcdboot.exe from a live Windows system such
102 as Windows PE, but there are other options as well.
103 .PP
104 Finally, note that this mode uses libntfs-3g directly, without going through the
105 \fBntfs-3g\fR(8) driver.  Hence, there is no special support for applying a WIM
106 image to a directory on which an NTFS filesystem has been mounted using
107 \fBntfs-3g\fR(8); you have to unmount it first.  There is also no support for
108 applying a WIM image to some subdirectory of the NTFS volume; you can only apply
109 to the root directory.
110 .SH DIRECTORY EXTRACTION (WINDOWS)
111 On Windows, \fBwimapply\fR (and \fBwimextract\fR) natively support NTFS and
112 Windows-specific metadata.  For best results, the target directory should be
113 located on an NTFS volume and the program should be run with Administrator
114 privileges; however, non-NTFS filesystems and running without Administrator
115 privileges are also supported, subject to limitations.
116 .PP
117 On Windows, \fBwimapply\fR tries to extract as much data and metadata as
118 possible, including:
119 .IP \[bu] 4
120 All data streams of all files.  This includes the default file contents, as well
121 as named data streams if supported by the target volume.
122 .IP \[bu]
123 Reparse points, including symbolic links, junction points, and other reparse
124 points, if supported by the target volume.  Restoring symlinks requires
125 Administrator privileges.  Also see \fB--rpfix\fR and \fB--norpfix\fR for
126 details on how absolute symbolic links and junctions are extracted.
127 .IP \[bu]
128 File and directory creation, access, and modification timestamps, to the highest
129 resolution supported by the target volume.
130 .IP \[bu]
131 Security descriptors, if supported by the filesystem and \fB--no-acls\fR is not
132 specified.  Note that this, in general, requires Administrator privileges, and
133 may be only partially successful if the program is run without Administrator
134 privileges (see \fB--strict-acls\fR).
135 .IP \[bu]
136 File attribute flags, including hidden, compressed, encrypted, sparse, etc, when
137 supported by the filesystem.
138 .IP \[bu]
139 Short filenames (also known as 8.3 names or DOS names).
140 .IP \[bu]
141 Hard links, if supported by the target filesystem.
142 .IP \[bu]
143 Object IDs, if supported by the target filesystem.
144 .PP
145 Additional notes about extracting files on Windows:
146 .IP \[bu] 4
147 \fBwimapply\fR will issue warnings if unable to extract the exact metadata and
148 data of the WIM image due to limitations of the target filesystem.
149 .IP \[bu]
150 Since encrypted files (with FILE_ATTRIBUTE_ENCRYPTED) are not stored in
151 plaintext in the WIM image, \fBwimapply\fR cannot restore encrypted files to
152 filesystems not supporting encryption.  Therefore, on such filesystems,
153 encrypted files will not be extracted.  Furthermore, even if encrypted files are
154 restored to a filesystem that supports encryption, they will only be decryptable
155 if the decryption key is available.
156 .IP \[bu]
157 Files with names that cannot be represented on Windows will not
158 be extracted by default; see \fB--include-invalid-names\fR.
159 .IP \[bu]
160 Files with full paths over 260 characters (the so-called MAX_PATH) will be
161 extracted, but beware that such files will be inaccessible to most Windows
162 software and may not be able to be deleted easily.
163 .IP \[bu]
164 On Windows, unless the \fB--no-acls\fR option is specified, wimlib will attempt
165 to restore files' security descriptors exactly as they are provided in the WIM
166 image.  Beware that typical Windows installations contain files whose security
167 descriptors do not allow the Administrator to delete them.  Therefore, such
168 files will not be able to be deleted, or in some cases even read, after
169 extracting, unless processed with a specialized program that knows to acquire
170 the SE_RESTORE_NAME and/or SE_BACKUP_NAME privileges which allow overriding
171 access control lists.  This is not a bug in wimlib, which works as designed to
172 correctly restore the data that was archived, but rather a problem with the
173 access rights Windows uses on certain files.  But if you just want the file data
174 and don't care about security descriptors, use \fB--no-acls\fR to skip restoring
175 all security descriptors.
176 .IP \[bu]
177 A similar caveat to the above applies to file attributes such as Readonly,
178 Hidden, and System.  By design, on Windows wimlib will restore such file
179 attributes; therefore, extracted files may have those attributes.  If this is
180 not what you want, use the \fB--no-attributes\fR option.
181 .SH SPLIT WIMS
182 You may use \fBwimapply\fR to apply images from a split WIM, or \fBwimextract\fR
183 to extract files from a split WIM.  The \fIWIMFILE\fR argument must specify the
184 first part of the split WIM, while the additional parts of the split WIM must be
185 specified in one or more \fB--ref\fR="\fIGLOB\fR" options.  Since globbing is
186 built into the \fB--ref\fR option, typically only one \fB--ref\fR option is
187 necessary.  For example, the names for the split WIM parts usually go something
188 like:
189 .RS
190 .PP
191 .nf
192 mywim.swm
193 mywim2.swm
194 mywim3.swm
195 mywim4.swm
196 mywim5.swm
197 .RE
198 .fi
199 .PP
200 To apply the first image of this split WIM to the directory "dir", run:
201 .PP
202 .RS
203 wimapply mywim.swm 1 dir --ref="mywim*.swm"
204 .RE
205 .PP
206 .SH PIPABLE WIMS
207 \fBwimapply\fR also supports applying a WIM from a nonseekable file, such as a
208 pipe, provided that the WIM was captured in the wimlib-specific pipable format
209 using \fB--pipable\fR (see \fBwimcapture\fR(1)).  To use standard input as the
210 WIM, specify "-" as \fIWIMFILE\fR.  A possible use of this feature is to apply a
211 WIM image being streamed from the network.  For example, to apply the first
212 image from a WIM file available on a HTTP server to an NTFS volume on /dev/sda1,
213 run something like:
214 .PP
215 .RS
216 wget -O - http://myserver/mywim.wim | wimapply - 1 /dev/sda1
217 .RE
218 .PP
219 Pipable WIMs may also be split into multiple parts, just like normal WIMs.  To
220 apply a split pipable WIM from a pipe, the parts must be concatenated and all
221 written to the pipe.  The first part must be sent first, but the remaining parts
222 may be sent in any order.
223 .SH OPTIONS
224 .TP 6
225 \fB--check\fR
226 Before applying the image, verify the integrity of \fIWIMFILE\fR if it has extra
227 integrity information.
228 .TP
229 \fB--ref\fR="\fIGLOB\fR"
230 File glob of additional WIMs or split WIM parts to reference resources from.
231 See \fBSPLIT_WIMS\fR.  This option can be specified multiple times.  Note:
232 \fIGLOB\fR is listed in quotes because it is interpreted by \fBwimapply\fR and
233 may need to be quoted to protect against shell expansion.
234 .TP
235 \fB--rpfix\fR, \fB--norpfix\fR
236 Set whether to fix targets of absolute symbolic links (reparse points in Windows
237 terminology) or not.  When enabled (\fB--rpfix\fR), extracted absolute symbolic
238 links that are marked in the WIM image as being fixed are assumed to have
239 absolute targets relative to the image root, and therefore \fBwimapply\fR
240 prepends the absolute path to the extraction target directory to their targets.
241 The intention is that you can apply an image containing absolute symbolic links
242 and still have them be valid after it has been applied to any location.
243 .IP ""
244 The default behavior is \fB--rpfix\fR if any images in \fIWIMFILE\fR have been
245 captured with reparse-point fixups done.  Otherwise, it is \fB--norpfix\fR.
246 .IP ""
247 Reparse point fixups are never done in the NTFS volume extraction mode on
248 UNIX-like systems.
249 .TP
250 \fB--unix-data\fR
251 (UNIX-like systems only)  Restore UNIX-specific metadata and special files that
252 were captured by \fBwimcapture\fR with the \fB--unix-data\fR option.  This
253 includes: standard UNIX file permissions (owner, group, and mode); device nodes,
254 named pipes, and sockets; and extended attributes (Linux-only).
255 .TP
256 \fB--no-acls\fR
257 Do not restore security descriptors on extracted files and directories.
258 .TP
259 \fB--strict-acls\fR
260 Fail immediately if the full security descriptor of any file or directory cannot
261 be set exactly as specified in the WIM file.  If this option is not specified,
262 when \fBwimapply\fR on Windows does not have permission to set a security
263 descriptor on an extracted file, it falls back to setting it only partially
264 (e.g. with SACL omitted), and in the worst case omits it entirely.  However,
265 this should only be a problem when running \fBwimapply\fR without Administrator
266 rights.  Also, on UNIX-like systems, this flag can also be combined with
267 \fB--unix-data\fR to cause \fBwimapply\fR to issue an error if UNIX permissions
268 are unable to be applied to an extracted file.
269 .TP
270 \fB--no-attributes\fR
271 Do not restore Windows file attributes such as readonly, hidden, etc.
272 .TP
273 \fB--include-invalid-names\fR
274 Extract files and directories with invalid names by replacing characters and
275 appending a suffix rather than ignoring them.  Exactly what is considered an
276 "invalid" name is platform-dependent.
277 .IP ""
278 On POSIX-compliant systems, filenames are case-sensitive and may contain any
279 byte except '\\0' and \'/', so on a POSIX-compliant system this option will only
280 have an effect in the unlikely case that the WIM image for some reason has a
281 filename containing one of these characters.
282 .IP ""
283 On Windows, filenames are case-insensitive(*), cannot include control
284 characters, and cannot include the characters '/', \'\\0', '\\', ':', '*', '?',
285 \'"', '<', '>', or '|'.  Ordinarily, files in WIM images should meet these
286 conditions as well. However, it is not guaranteed, and in particular a WIM image
287 captured with \fBwimcapture\fR on a POSIX-compliant system could contain such
288 files.  By default, invalid names will be ignored, and if there are multiple
289 names differing only in case, one will be chosen to extract arbitrarily;
290 however, with \fB--include-invalid-names\fR, all names will be sanitized and
291 extracted in some form.
292 .IP ""
293 (*) Unless the ObCaseInsensitive setting has been set to 0 in the Windows
294 registry, in which case certain software, including the Windows version of
295 \fBwimapply\fR, will honor case-sensitive filenames on NTFS and other compatible
296 filesystems.
297 .TP
298 \fB--wimboot\fR
299 Windows only: Instead of extracting the files themselves, extract "pointer
300 files" back to the WIM archive(s).  This can result in significant space savings.
301 However, it comes at several potential costs, such as not being able to delete
302 the WIM archive(s) and possibly having slower access to files.  See Microsoft's
303 documentation for "WIMBoot" for more information.
304 .IP ""
305 If it exists, the [PrepopulateList] section of the file
306 \\Windows\\System32\\WimBootCompress.ini in the WIM image will be read.  Files
307 matching any of these patterns will be extracted normally, not as WIMBoot
308 "pointer files".  This is helpful for certain files that Windows needs to read
309 early in the boot process.
310 .IP ""
311 This option only works when the program is run as an Administrator and the
312 target volume is NTFS or another filesystem that supports reparse points.
313 .IP ""
314 In addition, this option works best when running on Windows 8.1 Update 1 or
315 later, since that is the first version of Windows that contains the Windows
316 Overlay Filesystem filter driver ("WOF").  If the WOF driver is detected, wimlib
317 will create the WIMBoot "pointer files" using documented ioctls provided by WOF.
318 .IP ""
319 Otherwise, if the WOF driver is not detected, wimlib will create the reparse
320 points and edit the file "\\System Volume Information\\WimOverlay.dat" on the
321 target volume manually.  This is potentially subject to problems, since although
322 the code works in certain tested cases, neither of these data formats is
323 actually documented by Microsoft.  Before overwriting this file, wimlib will
324 save the previous version in "\\System Volume
325 Information\\WimOverlay.wimlib_backup", which you potentially could restore if
326 you needed to.
327 .IP ""
328 You actually can still do a \fB--wimboot\fR extraction even if the WIM image is
329 not marked as "WIMBoot-compatible".  This option causes the extracted files to
330 be set as "externally backed" by the WIM file.  Microsoft's driver which
331 implements this "external backing" functionality seemingly does not care whether
332 the image(s) in the WIM are really marked as WIMBoot-compatible.  Therefore, the
333 "WIMBoot-compatible" tag (<WIMBOOT> in the XML data) seems to be a marker for
334 intent only.  In addition, the Microsoft driver can externally back files from
335 WIM files that use XPRESS chunks of size 8192, 16384, and 32768, or LZX chunks
336 of size 32768, in addition to the default XPRESS chunks of size 4096 that are
337 created when \fBwimcapture\fR is run with the \fB--wimboot\fR option.
338 .TP
339 \fB--compact\fR=\fIFORMAT\fR
340 Windows-only: compress the extracted files using System Compression, when
341 possible.  This only works on either Windows 10 or later, or on an older Windows
342 to which Microsoft's wofadk.sys driver has been added.  Several different
343 compression formats may be used with System Compression, and one must be
344 specified as \fIFORMAT\fR.  The choices are: xpress4k, xpress8k, xpress16k, and
345 lzx.
346 .IP ""
347 Exclusions are handled in the same way as with the \fB--wimboot\fR option.
348 That is: if it exists, the [PrepopulateList] section of the file
349 \\Windows\\System32\\WimBootCompress.ini in the WIM image will be read, and
350 files matching any of the patterns in this section will not be compressed.
351 In addition, wimlib has a hardcoded list of files for which it knows, for
352 compatibility with the Windows bootloader, to override the requested compression
353 format.
354 .SH NOTES
355 \fIData integrity\fR: WIM files include checksums of file data.  To detect
356 accidental (non-malicious) data corruption, wimlib calculates the checksum of
357 every file it extracts and issues an error if it does not have the expected
358 value.  (This default behavior seems equivalent to the \fB/verify\fR option of
359 ImageX.)  In addition, a WIM file can include an integrity table (extra
360 checksums) over the raw data of the entire WIM file.  For performance reasons
361 wimlib does not check the integrity table by default, but the \fB--check\fR
362 option can be passed to make it do so.
363 .PP
364 \fIESD files\fR: wimlib can extract files from solid-compressed WIMs, or "ESD"
365 (.esd) files, just like from normal WIM (.wim) files.  However, Microsoft
366 sometimes distributes ESD files with encrypted segments; wimlib cannot extract
367 such files until they are first decrypted.
368 .PP
369 \fISecurity\fR: wimlib has been carefully written to validate all input and is
370 believed to be secure against some types of attacks which often plague other
371 file archiving programs, e.g. directory traversal attacks (which, as it happens,
372 Microsoft's WIM software is vulnerable to).  Important parts of wimlib, e.g. the
373 decompressors, have also been fuzz tested.  However, wimlib is not currently
374 designed to protect against some types of denial-of-service (DOS) attacks, e.g.
375 memory exhaustion or "zip bombs".
376 .SH EXAMPLES
377 Extract the first image from the Windows PE WIM on the Windows installation
378 media to the directory "boot":
379 .RS
380 .PP
381 wimapply /mnt/windows/sources/boot.wim 1 boot
382 .RE
383 .PP
384 On Windows, apply an image of an entire volume, for example from "install.wim"
385 which can be found on the Windows installation media:
386 .RS
387 .PP
388 wimapply install.wim 1 E:\\
389 .RE
390 .PP
391 Same as above, but running on a UNIX-like system where the corresponding
392 partition is /dev/sda2:
393 .RS
394 .PP
395 wimapply install.wim 1 /dev/sda2
396 .RE
397 .PP
398 Note that before running either of the above commands, an NTFS filesystem may
399 need to be created on the partition, for example with format.exe on Windows or
400 \fBmkntfs\fR(8) on UNIX-like systems.  For example, on UNIX you might run:
401 .RS
402 .PP
403 mkntfs /dev/sda2 && wimapply install.wim 1 /dev/sda2
404 .RE
405 .PP
406 (Of course don't do that if you don't want to destroy all existing data on the
407 partition!)
408 .PP
409 See \fBSPLIT WIMS\fR and \fBPIPABLE WIMS\fR for examples of applying split and
410 pipable WIMs, respectively.
411 .SH SEE ALSO
412 .BR wimlib-imagex (1)
413 .BR wimcapture (1)
414 .BR wimextract (1)
415 .BR wiminfo (1)