]> wimlib.net Git - wimlib/blob - doc/man1/wimlib-imagex-apply.1
619c8fc6658d4cb6a55c2b55283f533d87937f2b
[wimlib] / doc / man1 / wimlib-imagex-apply.1
1 .TH WIMLIB-IMAGEX "1" "February 2015" "wimlib 1.8.0" "User Commands"
2 .SH NAME
3 wimlib-imagex-apply \- Extract one image, or all images, from a WIM archive
4 .SH SYNOPSIS
5 \fBwimlib-imagex apply\fR \fIWIMFILE\fR [\fIIMAGE\fR] \fITARGET\fR [\fIOPTION\fR...]
6 .SH DESCRIPTION
7 \fBwimlib-imagex apply\fR extracts an image, or all images, from the Windows
8 Imaging (WIM) file \fIWIMFILE\fR.  This command is also available as simply
9 \fBwimapply\fR if the appropriate hard link or batch file has been installed.
10 .PP
11 This command is designed to extract, or "apply", one or more full WIM images.
12 If you instead want to extract only certain files or directories contained in a
13 WIM image, consider using \fBwimlib-imagex extract\fR or
14 \fBwimlib-imagex mount\fR instead.  (\fBwimlib-imagex mount\fR is not
15 supported on Windows.)
16 .PP
17 \fIIMAGE\fR specifies the WIM image in \fIWIMFILE\fR to extract.  It may be a
18 1-based index of an image in \fIWIMFILE\fR, the name of an image in
19 \fIWIMFILE\fR, or the keyword "all" to indicate that all images in \fIWIMFILE\fR
20 are to be extracted.  Use the \fBwimlib-imagex info\fR (1) command to show
21 what images a WIM file contains.  \fIIMAGE\fR may be omitted if \fIWIMFILE\fR
22 contains only one image.
23 .PP
24 \fITARGET\fR specifies where to extract the WIM image to.  If \fITARGET\fR
25 specifies a directory, the WIM image is extracted to that directory (see
26 \fBDIRECTORY EXTRACTION (UNIX)\fR or \fBDIRECTORY EXTRACTION (WINDOWS)\fR).
27 Similarly, if \fITARGET\fR specifies a non-existent file, a directory is created
28 in that location and the WIM image is extracted to that directory.
29 .PP
30 If \fIIMAGE\fR is specified as "all", then all the images in \fIWIMFILE\fR are
31 actually extracted into subdirectories of \fITARGET\fR, each of which is given
32 the name of the corresponding image, falling back to the image index in the case
33 of an image with no name or a name not valid as a filename.
34 .PP
35 Alternatively, on UNIX-like systems only, if \fITARGET\fR specifies a regular
36 file or block device, it is interpreted as an NTFS volume to which the WIM image
37 is to be extracted (see \fBNTFS VOLUME EXTRACTION (UNIX)\fR).  Only a single
38 image can be extracted in this mode, and only extracting to the root of the NTFS
39 volume (not a subdirectory thereof) is supported.
40 .PP
41 \fIWIMFILE\fR may be "-" to read the WIM from standard input rather than from a
42 file, but see \fBPIPABLE WIMS\fR for more information.
43 .PP
44 \fBwimlib-imagex apply\fR supports applying images from stand-alone WIMs as
45 well as split WIMs.  See \fBSPLIT WIMS\fR.
46 .SH DIRECTORY EXTRACTION (UNIX)
47 This section documents how \fBwimlib-imagex apply\fR (and also
48 \fBwimlib-imagex extract\fR) extract a WIM image (or a possibly a subset
49 thereof, in the case of \fBwimlib-imagex extract\fR) to a directory on
50 UNIX-like systems.  See \fBDIRECTORY EXTRACTION (WINDOWS)\fR for the
51 corresponding documentation for Windows.
52 .PP
53 As mentioned, a WIM image can be applied to a directory on a UNIX-like system by
54 providing a \fITARGET\fR directory.  However, it is important to keep in mind
55 that the WIM format was designed for Windows, and as a result WIM files can
56 contain data or metadata that cannot be represented on UNIX-like systems.  The
57 main information that \fBwimlib-imagex\fR will \fInot\fR be able to extract
58 on UNIX-like systems is the following:
59 .IP \[bu] 4
60 Windows security descriptors (which include the file owner, group, and ACLs).
61 .IP \[bu]
62 Named data streams.
63 .IP \[bu]
64 Reparse points other than symbolic links and junction points.
65 .IP \[bu]
66 Certain file attributes such as compression, encryption, and sparseness.
67 .IP \[bu]
68 Short (DOS) names for files.
69 .IP \[bu]
70 File creation timestamps.
71 .PP
72 Notes: Unsupported data and metadata is simply not extracted, but
73 \fBwimlib-imagex\fR will attempt to warn you when the contents of the WIM
74 image can't be exactly represented when extracted.  Last access and last
75 modification timestamps are specified to 100 nanosecond granularity in the WIM
76 file, but will only be extracted to the highest precision supported by the
77 underlying operating system, C library, and filesystem.  Compressed files will
78 be extracted as uncompressed, while encrypted files will not be extracted at
79 all.
80 .SH NTFS VOLUME EXTRACTION (UNIX)
81 This section documents how \fBwimlib-imagex apply\fR extracts a WIM image
82 directly to an NTFS volume image on UNIX-like systems.
83 .PP
84 As mentioned, \fBwimlib-imagex\fR running on a UNIX-like system can apply a
85 WIM image directly to an NTFS volume by specifying \fITARGET\fR as a regular file
86 or block device containing an NTFS filesystem.  The NTFS filesystem need not be
87 empty, although it's expected that it be empty for the intended use cases.  A
88 new NTFS filesystem can be created using the \fBmkntfs\fR(8) command provided
89 with \fBntfs-3g\fR.
90 .PP
91 In this NTFS volume extraction mode, the WIM image is extracted to the root of
92 the NTFS volume in a way preserves almost all information contained in the WIM
93 image.  It therefore does not suffer from the limitations described in
94 \fBDIRECTORY EXTRACTION (UNIX)\fR.  This support relies on libntfs-3g to write
95 to the NTFS volume and handle NTFS-specific and Windows-specific data.
96 .PP
97 Please note that this NTFS volume extraction mode is \fInot\fR entered if
98 \fITARGET\fR is a directory, even if an NTFS filesystem is mounted on
99 \fITARGET\fR.  You must specify the NTFS volume itself (and it must be
100 unmounted, and you must have permission to write to it).
101 .PP
102 This NTFS volume extraction mode attempts to extract as much information as
103 possible, including:
104 .IP \[bu] 4
105 All data streams of all files except encrypted files, including the unnamed data
106 stream as well as all named data streams.
107 .IP \[bu]
108 Reparse points, including symbolic links, junction points, and other reparse
109 points.
110 .IP \[bu]
111 File and directory creation, access, and modification timestamps, using the
112 native NTFS resolution of 100 nanoseconds.
113 .IP \[bu]
114 Windows security descriptors, including all components (owner, group, DACL, and
115 SACL).
116 .IP \[bu]
117 DOS/Windows file attribute flags.
118 .IP \[bu]
119 All names of all files, including names in the Win32 namespace, DOS namespace,
120 Win32+DOS namespace, and POSIX namespace.  This includes hard links.
121 .PP
122 However, there are also several known limitations of the NTFS volume extraction
123 mode:
124 .IP \[bu] 4
125 Encrypted files will not be extracted.
126 .IP \[bu]
127 wimlib v1.7.0 and later:  Sparse file attributes will not be extracted (same
128 behavior as ImageX/DISM/WIMGAPI).  wimlib v1.6.2 and earlier:  Although sparse
129 file attributes will be applied, the full data will be extracted to each sparse
130 file, so extracted "sparse" files may not actually contain any sparse regions.
131 .PP
132 Regardless, since almost all information from the WIM image is restored in this
133 mode, it is possible (and fully supported) to restore an image of an actual
134 Windows installation using \fBwimlib-imagex\fR on UNIX-like systems as an
135 alternative to using \fBwimlib-imagex\fR on Windows.  In the examples at the end
136 of this manual page, there is an example of applying an image from the
137 "install.wim" file contained in the installation media for Windows (Vista or
138 later) in the "sources" directory.
139 .PP
140 Note that to actually boot Windows (Vista or later) from an applied
141 "install.wim" image, you also need to mark the partition as "bootable" and set
142 up various boot files, such as \\BOOTMGR and \\BOOT\\BCD.  The latter task is
143 most easily accomplished by running the "bcdboot.exe" program from a live
144 Windows system (such as Windows PE), but there are other options as well.
145 .SH DIRECTORY EXTRACTION (WINDOWS)
146 On Windows, \fBwimlib-imagex apply\fR and \fBwimlib-imagex extract\fR
147 natively support Windows-specific and NTFS-specific data.  For best results, the
148 target directory should be located on an NTFS volume and \fBwimlib-imagex\fR
149 should be run with Administrator privileges; however, non-NTFS filesystems and
150 running without Administrator privileges are also supported.
151 .PP
152 On Windows, \fBwimlib-imagex apply\fR and \fBwimlib-imagex extract\fR
153 try to extract as much data and metadata as possible, including:
154 .IP \[bu] 4
155 All data streams of all files.  This includes the default file contents, as well
156 as named data streams if supported by the target volume.
157 .IP \[bu]
158 Reparse points, including symbolic links, junction points, and other reparse
159 points, if supported by the target volume.  (Note: see \fB--rpfix\fR and
160 \fB--norpfix\fR for documentation on exactly how absolute symbolic links and
161 junctions are extracted.)  However, as per the default security settings of
162 Windows, it is impossible to create a symbolic link or junction point without
163 Administrator privileges; therefore, you must run \fBwimlib-imagex\fR as the
164 Administrator if you wish to fully restore an image containing symbolic links
165 and/or junction points.  (Otherwise, merely a warning will be issued when a
166 symbolic link or junction point cannot be extracted due to insufficient
167 privileges.)
168 .IP \[bu]
169 File and directory creation, access, and modification timestamps, to the highest
170 resolution supported by the target volume.
171 .IP \[bu]
172 Security descriptors, if supported by the filesystem and \fB--no-acls\fR is not
173 specified.  Furthermore, unless \fB--strict-acls\fR is specified, the security
174 descriptors for individual files or directories may be omitted or only partially
175 set if the user does not have permission to set them, which can be a problem if
176 \fBwimlib-imagex\fR is run as a non-Administrator.
177 .IP \[bu]
178 File attributes, including hidden, sparse, compressed, encrypted, etc, when
179 supported by the filesystem.
180 .IP \[bu]
181 DOS names (8.3) names of files; however, the failure to set them is not
182 considered an error condition.
183 .IP \[bu]
184 Hard links, if supported by the filesystem.
185 .PP
186 Additional notes about extracting files on Windows:
187 .IP \[bu] 4
188 \fBwimlib-imagex\fR will issue a warning when it is unable to extract the
189 exact metadata and data of the WIM image, for example due to features mentioned
190 above not being supported by the target filesystem.
191 .IP \[bu]
192 Since encrypted files (with FILE_ATTRIBUTE_ENCRYPTED) are not stored in
193 plaintext in the WIM image, \fBwimlib-imagex\fR cannot restore encrypted
194 files to filesystems not supporting encryption.  Therefore, on such filesystems,
195 encrypted files will not be extracted.  Furthermore, even if encrypted
196 files are restored to a filesystem that supports encryption, they will only be
197 decryptable if the decryption key is available.
198 .IP \[bu]
199 Files with names that cannot be represented on Windows will not
200 be extracted by default; see \fB--include-invalid-names\fR.
201 .IP \[bu]
202 Files with full paths over 260 characters (the so-called MAX_PATH) will be
203 extracted, but beware that such files will be inaccessible to most Windows
204 software and may not be able to be deleted easily.
205 .IP \[bu]
206 On Windows, unless the \fB--no-acls\fR option is specified, wimlib will attempt
207 to restore files' security descriptors exactly as they are provided in the WIM
208 image.  Beware that typical Windows installations contain files whose security
209 descriptors do not allow the Administrator to delete them.  Therefore, such
210 files will not be able to be deleted, or in some cases even read, after
211 extracting, unless processed with a specialized program that knows to acquire
212 the SE_RESTORE_NAME and/or SE_BACKUP_NAME privileges which allow overriding
213 access control lists.  This is not a bug in wimlib, which works as designed to
214 correctly restore the data that was archived, but rather a problem with the
215 access rights Windows uses on certain files.  But if you just want the file data
216 and don't care about security descriptors, use \fB--no-acls\fR to skip restoring
217 all security descriptors.
218 .IP \[bu]
219 A similar caveat to the above applies to file attributes such as Readonly,
220 Hidden, and System.  By design, on Windows wimlib will restore such file
221 attributes; therefore, extracted files may have those attributes.  If this is
222 not what you want, use the \fB--no-attributes\fR option.
223 .SH SPLIT WIMS
224 You may use \fBwimlib-imagex apply\fR to apply images from a split WIM.  The
225 \fIWIMFILE\fR argument must specify the first part of the split WIM, while the
226 additional parts of the split WIM must be specified in one or more
227 \fB--ref\fR="\fIGLOB\fR" options.  Since globbing is built into the \fB--ref\fR
228 option, typically only one \fB--ref\fR option is necessary.  For example, the
229 names for the split WIM parts usually go something like:
230 .RS
231 .PP
232 .nf
233 mywim.swm
234 mywim2.swm
235 mywim3.swm
236 mywim4.swm
237 mywim5.swm
238 .RE
239 .fi
240 .PP
241 To apply the first image of this split WIM to the directory "dir", run:
242 .PP
243 .RS
244 wimlib-imagex apply mywim.swm 1 dir --ref="mywim*.swm"
245 .RE
246 .PP
247 As a special case, if you are applying an image from standard input from a split
248 WIM that is also pipable (as described in \fBPIPABLE WIMS\fR), the \fB--ref\fR
249 option is unneeded; instead you must ensure that all the split WIM parts are
250 concatenated together on standard input.  They can be provided in any order,
251 with the exception of the first part, which must be first.
252 .SH PIPABLE WIMS
253 As of wimlib 1.5.0, \fBwimlib-imagex apply\fR supports applying a WIM from a
254 nonseekable file, such as a pipe, provided that the WIM was captured with
255 \fB--pipable\fR (see \fBwimlib-imagex capture\fR(1)).  To use standard input
256 as the WIM, specify "-" as \fIWIMFILE\fR.  A useful use of this ability is to
257 apply an image from a WIM while streaming it from a server.  For example, to
258 apply the first image from a WIM file available on a HTTP server to an NTFS
259 volume on /dev/sda1, run something like:
260 .PP
261 .RS
262 wget -O - http://myserver/mywim.wim | wimapply - 1 /dev/sda1
263 .RE
264 .PP
265 (The above also used the \fBwimapply\fR abbreviation for \fBwimlib-imagex
266 apply\fR.) Note: WIM files are \fInot\fR pipable by default; you have to
267 explicitly capture them with \fB--pipable\fR, and they are \fInot\fR compatible
268 with Microsoft's software.  See \fBwimlib-imagex capture\fR(1) for more
269 information.
270 .PP
271 It is possible to apply an image from a pipable WIM split into multiple parts;
272 see \fBSPLIT WIMS\fR.
273 .SH OPTIONS
274 .TP 6
275 \fB--check\fR
276 When reading \fIWIMFILE\fR, verify its integrity if the integrity table is
277 present.
278 .TP
279 \fB--ref\fR="\fIGLOB\fR"
280 File glob of additional WIMs or split WIM parts to reference resources from.
281 See \fBSPLIT_WIMS\fR.  This option can be specified multiple times.  Note:
282 \fIGLOB\fR is listed in quotes because it is interpreted by
283 \fBwimlib-imagex\fR and may need to be quoted to protect against shell
284 expansion.
285 .TP
286 \fB--rpfix\fR, \fB--norpfix\fR
287 Set whether to fix targets of absolute symbolic links (reparse points in Windows
288 terminology) or not.  When enabled (\fB--rpfix\fR), extracted absolute symbolic
289 links that are marked in the WIM image as being fixed are assumed to have
290 absolute targets relative to the image root, and therefore \fBwimlib-imagex
291 apply\fR prepends the absolute path to the extraction target directory to their
292 targets.  The intention is that you can apply an image containing absolute
293 symbolic links and still have them be valid after it has been applied to any
294 location.
295 .IP ""
296 The default behavior is \fB--rpfix\fR if any images in \fIWIMFILE\fR have been
297 captured with reparse-point fixups done.  Otherwise, it is \fB--norpfix\fR.
298 .IP ""
299 Reparse point fixups are never done in the NTFS volume extraction mode on
300 UNIX-like systems.
301 .TP
302 \fB--unix-data\fR
303 (UNIX-like systems only)  Restore UNIX owners, groups, modes, and device IDs
304 (major and minor numbers) that were captured by \fBwimlib-imagex capture\fR
305 with the \fB--unix-data\fR option.  As of wimlib v1.7.0, you can backup and
306 restore not only the standard UNIX file permission information, but also
307 character device nodes, block device nodes, named pipes (FIFOs), and UNIX domain
308 sockets.
309 .TP
310 \fB--no-acls\fR
311 Do not restore security descriptors on extracted files and directories.
312 .TP
313 \fB--strict-acls\fR
314 Fail immediately if the full security descriptor of any file or directory cannot
315 be set exactly as specified in the WIM file.  If this option is not specified,
316 when \fBwimlib-imagex\fR on Windows does not have permission to set a
317 security descriptor on an extracted file, it falls back to setting it only
318 partially (e.g. with SACL omitted), and in the worst case omits it entirely.
319 However, this should only be a problem when running \fBwimlib-imagex\fR
320 without Administrator rights.  Also, on UNIX-like systems, this flag can also be
321 combined with \fB--unix-data\fR to cause \fBwimlib-imagex\fR to fail
322 immediately if the UNIX owner, group, or mode on an extracted file cannot be set
323 for any reason.
324 .TP
325 \fB--no-attributes\fR
326 Do not restore Windows file attributes such as readonly, hidden, etc.
327 .TP
328 \fB--include-invalid-names\fR
329 Extract files and directories with invalid names by replacing characters and
330 appending a suffix rather than ignoring them.  Exactly what is considered an
331 "invalid" name is platform-dependent.
332 .IP ""
333 On POSIX-compliant systems, filenames are case-sensitive and may contain any
334 byte except '\\0' and \'/', so on a POSIX-compliant system this option will only
335 have an effect in the unlikely case that the WIM image for some reason has a
336 filename containing one of these characters.
337 .IP ""
338 On Windows, filenames are case-insensitive, cannot include the characters '/',
339 \'\\0', '\\', ':', '*', '?', '"', '<', '>', or '|', and cannot end with a space
340 or period.  Ordinarily, files in WIM images should meet these conditions as
341 well. However, it is not guaranteed, and in particular a WIM image captured with
342 \fBwimlib-imagex\fR on a POSIX-compliant system could contain such files.  By
343 default, invalid names will be ignored, and if there are multiple names
344 differing only in case, one will be chosen to extract arbitrarily; however, with
345 \fB--include-invalid-names\fR, all names will be sanitized and extracted in some
346 form.
347 .TP
348 \fB--wimboot\fR
349 Windows only: Instead of extracting the files themselves, extract "pointer
350 files" back to the WIM archive(s).  This can result in significant space savings.
351 However, it comes at several potential costs, such as not being able to delete
352 the WIM archive(s) and possibly having slower access to files.  See Microsoft's
353 documentation for "WIMBoot" for more information.
354 .IP ""
355 If it exists, the [PrepopulateList] section of the file
356 \\Windows\\System32\\WimBootCompress.ini in the WIM image will be read.  Files
357 matching any of these patterns will be extracted normally, not as WIMBoot
358 "pointer files".  This is helpful for certain files that Windows needs to read
359 early in the boot process.
360 .IP ""
361 This option only works when the program is run as an Administrator and the
362 target volume is NTFS or another filesystem that supports reparse points.
363 .IP ""
364 In addition, this option works best when running on Windows 8.1 Update 1 or
365 later, since that is the first version of Windows that contains the Windows
366 Overlay File System Filter Driver ("WOF").  If the WOF driver is detected,
367 wimlib will create the WIMBoot "pointer files" using documented ioctls provided
368 by WOF.
369 .IP ""
370 Otherwise, if the WOF driver is not detected, wimlib will create the reparse
371 points and edit the file "\\System Volume Information\\WimOverlay.dat" on the
372 target volume manually.  This is potentially subject to problems, since although
373 the code works in certain tested cases, neither of these data formats is
374 actually documented by Microsoft.  Before overwriting this file, wimlib will
375 save the previous version in "\\System Volume
376 Information\\WimOverlay.wimlib_backup", which you potentially could restore if
377 you needed to.
378 .IP ""
379 You actually can still do a \fB--wimboot\fR extraction even if the WIM image is
380 not marked as "WIMBoot-compatible".  This option causes the extracted files to
381 be set as "externally backed" by the WIM file.  Microsoft's driver which
382 implements this "external backing" functionality seemingly does not care whether
383 the image(s) in the WIM are really marked as WIMBoot-compatible.  Therefore, the
384 "WIMBoot-compatible" tag (<WIMBOOT> in the XML data) seems to be a marker for
385 intent only.  In addition, the Microsoft driver can externally back files from
386 WIM files that use XPRESS chunks of size 8192, 16384, and 32768, or LZX chunks
387 of size 32768, in addition to the default XPRESS chunks of size 4096 that are
388 created when \fBwimlib-imagex capture\fR is run with the \fB--wimboot\fR
389 option.
390 .SH NOTES
391 \fIData integrity\fR:  WIM files include SHA1 message digests for file data.
392 \fBwimlib-imagex apply\fR calculates the SHA1 message digest of every file
393 it extracts and issues an error if it is not equal to the SHA1 message digest
394 provided in the WIM.  (This default behavior seems equivalent to the
395 \fB/verify\fR option of ImageX.)  Note that this is separate from the integrity
396 table of the WIM, which provides SHA1 message digests over raw chunks of the
397 entire WIM file and is checked separately if the \fB--check\fR option is
398 specified.
399 .PP
400 \fIESD files\fR: wimlib v1.6.0 and later can extract files from version 3584
401 WIMs, which usually contain LZMS-compressed solid resources and may carry the
402 \fI.esd\fR file extension rather than \fI.wim\fR.  However, \fI.esd\fR files
403 downloaded directly by the Windows 8 web downloader have encrypted segments, and
404 wimlib cannot extract such files until they are first decrypted.
405 .PP
406 \fIDirectory traversal attacks\fR:  wimlib validates filenames before extracting
407 them and is not vulnerable to directory traversal attacks.  This is in contrast
408 to Microsoft WIMGAPI/ImageX/DISM which can overwrite arbitrary files on the
409 target drive when extracting a malicious WIM file containing files named
410 \fI..\fR or containing path separators.
411 .SH EXAMPLES
412 Extract the first image from the Windows PE image on the Windows (Vista or
413 later) installation media to the directory "boot":
414 .RS
415 .PP
416 wimlib-imagex apply /mnt/windows/sources/boot.wim 1 boot
417 .RE
418 .PP
419 Same as above, but using the \fBwimapply\fR abbreviation:
420 .RS
421 .PP
422 wimapply /media/windows/sources/boot.wim 1 boot
423 .RE
424 .PP
425 On Windows, apply an image of an entire volume, for example from "install.wim"
426 which can be found on the Windows (Vista or later) installation media:
427 .RS
428 .PP
429 wimlib-imagex apply install.wim 1 E:\\
430 .RE
431 .PP
432 Same as above, but running on a UNIX-like system where the corresponding
433 partition is /dev/sda2:
434 .RS
435 .PP
436 wimlib-imagex apply install.wim 1 /dev/sda2
437 .RE
438 .PP
439 Note that before running either of the above commands, an NTFS filesystem may
440 need to be created on the partition, for example with format.exe on Windows or
441 \fBmkntfs\fR(8) (part of NTFS-3g) on UNIX-like systems.  For example, you might
442 run:
443 .RS
444 .PP
445 mkntfs /dev/sda2 && wimapply install.wim 1 /dev/sda2
446 .RE
447 .PP
448 (Of course don't do that if you don't want to destroy all existing data on the
449 partition!)
450 .PP
451 An example of applying a pipable WIM from a pipe can be found in \fBPIPABLE
452 WIMS\fR, and an example of applying a split WIM can be found in \fBSPLIT
453 WIMS\fR.
454 .SH SEE ALSO
455 .BR wimlib-imagex (1)
456 .BR wimlib-imagex-capture (1)
457 .BR wimlib-imagex-extract (1)
458 .BR wimlib-imagex-info (1)