xref: /freebsd/usr.bin/mkuzip/mkuzip.8 (revision 90ce2410817115f2ea804c981de9da37e0577a91)
18f8cb840SMaxim Sobolev.\"-
28f8cb840SMaxim Sobolev.\" Copyright (c) 2004-2016 Maxim Sobolev <sobomax@FreeBSD.org>
38f8cb840SMaxim Sobolev.\" All rights reserved.
48f8cb840SMaxim Sobolev.\"
58f8cb840SMaxim Sobolev.\" Redistribution and use in source and binary forms, with or without
68f8cb840SMaxim Sobolev.\" modification, are permitted provided that the following conditions
78f8cb840SMaxim Sobolev.\" are met:
88f8cb840SMaxim Sobolev.\" 1. Redistributions of source code must retain the above copyright
98f8cb840SMaxim Sobolev.\"    notice, this list of conditions and the following disclaimer.
108f8cb840SMaxim Sobolev.\" 2. Redistributions in binary form must reproduce the above copyright
118f8cb840SMaxim Sobolev.\"    notice, this list of conditions and the following disclaimer in the
128f8cb840SMaxim Sobolev.\"    documentation and/or other materials provided with the distribution.
138f8cb840SMaxim Sobolev.\"
148f8cb840SMaxim Sobolev.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
158f8cb840SMaxim Sobolev.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
168f8cb840SMaxim Sobolev.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
178f8cb840SMaxim Sobolev.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
188f8cb840SMaxim Sobolev.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
198f8cb840SMaxim Sobolev.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
208f8cb840SMaxim Sobolev.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
218f8cb840SMaxim Sobolev.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
228f8cb840SMaxim Sobolev.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
238f8cb840SMaxim Sobolev.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
248f8cb840SMaxim Sobolev.\" SUCH DAMAGE.
257f4caa8cSMaxim Sobolev.\"
267f4caa8cSMaxim Sobolev.\" $FreeBSD$
277f4caa8cSMaxim Sobolev.\"
28*90ce2410SKonstantin Belousov.Dd February 19, 2019
29cf7b3b65SRuslan Ermilov.Dt MKUZIP 8
307f4caa8cSMaxim Sobolev.Os
317f4caa8cSMaxim Sobolev.Sh NAME
327f4caa8cSMaxim Sobolev.Nm mkuzip
3342ecdf05SMaxim Sobolev.Nd compress disk image for use with
347f4caa8cSMaxim Sobolev.Xr geom_uzip 4
3542ecdf05SMaxim Sobolevclass
367f4caa8cSMaxim Sobolev.Sh SYNOPSIS
377f4caa8cSMaxim Sobolev.Nm
38*90ce2410SKonstantin Belousov.Op Fl dLSsvZ
39*90ce2410SKonstantin Belousov.Op Fl j Ar compression_jobs
407f4caa8cSMaxim Sobolev.Op Fl o Ar outfile
417f4caa8cSMaxim Sobolev.Op Fl s Ar cluster_size
427f4caa8cSMaxim Sobolev.Ar infile
437f4caa8cSMaxim Sobolev.Sh DESCRIPTION
447f4caa8cSMaxim SobolevThe
457f4caa8cSMaxim Sobolev.Nm
46d3ff2972SMaxim Sobolevutility compresses a disk image file so that the
477f4caa8cSMaxim Sobolev.Xr geom_uzip 4
48d3ff2972SMaxim Sobolevclass will be able to decompress the resulting image at run-time.
49d3ff2972SMaxim SobolevThis allows for a significant reduction of size of disk image at
5042ecdf05SMaxim Sobolevthe expense of some CPU time required to decompress the data each
51cf7b3b65SRuslan Ermilovtime it is read.
52cb29445aSRuslan ErmilovThe
53d3ff2972SMaxim Sobolev.Nm
54cb29445aSRuslan Ermilovutility
55d3ff2972SMaxim Sobolevworks in two phases:
567f4caa8cSMaxim Sobolev.Bl -enum
577f4caa8cSMaxim Sobolev.It
587f4caa8cSMaxim SobolevAn
597f4caa8cSMaxim Sobolev.Ar infile
60d3ff2972SMaxim Sobolevimage is split into clusters; each cluster is compressed using
618f8cb840SMaxim Sobolev.Xr zlib 3
628f8cb840SMaxim Sobolevor
638f8cb840SMaxim Sobolev.Xr lzma 3 .
647f4caa8cSMaxim Sobolev.It
65d3ff2972SMaxim SobolevThe resulting set of compressed clusters along with headers that allow
66d3ff2972SMaxim Sobolevlocating each individual cluster is written to the output file.
677f4caa8cSMaxim Sobolev.El
687f4caa8cSMaxim Sobolev.Pp
697f4caa8cSMaxim SobolevThe options are:
70cf7b3b65SRuslan Ermilov.Bl -tag -width indent
71*90ce2410SKonstantin Belousov.It Fl j Ar compression_jobs
72*90ce2410SKonstantin BelousovSpecify the number of compression jobs that
73*90ce2410SKonstantin Belousov.Nm
74*90ce2410SKonstantin Belousovruns in parallel to speed up compression.
75*90ce2410SKonstantin BelousovWhen option is not specified the number of jobs set to be equal
76*90ce2410SKonstantin Belousovto the value of
77*90ce2410SKonstantin Belousov.Va hw.ncpu
78*90ce2410SKonstantin Belousov.Xr sysctl 8
79*90ce2410SKonstantin Belousovvariable.
80*90ce2410SKonstantin Belousov.It Fl d
81*90ce2410SKonstantin BelousovEnable de-duplication.
82*90ce2410SKonstantin BelousovWhen the option is enabled the
83*90ce2410SKonstantin Belousov.Nm
84*90ce2410SKonstantin Belousovdetects identical blocks in the input and replaces each subsequent occurence
85*90ce2410SKonstantin Belousovof such block with pointer to the very first one in the output.
86*90ce2410SKonstantin BelousovSetting this option results is moderate decrease of compressed image size,
87*90ce2410SKonstantin Belousovtypically around 3-5% of a final size of the compressed image.
88*90ce2410SKonstantin Belousov.It Fl L
89*90ce2410SKonstantin BelousovUse
90*90ce2410SKonstantin Belousov.Xr lzma 3
91*90ce2410SKonstantin Belousovcompression algorithm instead of the default
92*90ce2410SKonstantin Belousov.Xr zlib 3 .
93*90ce2410SKonstantin BelousovThe
94*90ce2410SKonstantin Belousov.Xr lzma 3
95*90ce2410SKonstantin Belousovprovides noticeable better compression levels on the same data set
96*90ce2410SKonstantin Belousovat the expense of much slower compression speed (10-20x) and somewhat slower
97*90ce2410SKonstantin Belousovdecompression (2-3x).
987f4caa8cSMaxim Sobolev.It Fl o Ar outfile
99d3ff2972SMaxim SobolevName of the output file
1007f4caa8cSMaxim Sobolev.Ar outfile .
1017f4caa8cSMaxim SobolevThe default is to use the input name with the suffix
1028f8cb840SMaxim Sobolev.Pa .uzip
1038f8cb840SMaxim Sobolevfor the
1048f8cb840SMaxim Sobolev.Xr zlib 3
1058f8cb840SMaxim Sobolevcompression or
1068f8cb840SMaxim Sobolev.Pa .ulzma
1078f8cb840SMaxim Sobolevfor the
1088f8cb840SMaxim Sobolev.Xr lzma 3 .
109*90ce2410SKonstantin Belousov.It Fl S
110*90ce2410SKonstantin BelousovPrint summary about the compression ratio as well as output
111*90ce2410SKonstantin Belousovfile size after file has been processed.
1127f4caa8cSMaxim Sobolev.It Fl s Ar cluster_size
113d3ff2972SMaxim SobolevSplit the image into clusters of
1147f4caa8cSMaxim Sobolev.Ar cluster_size
115d3ff2972SMaxim Sobolevbytes, 16384 bytes by default.
116cf7b3b65SRuslan ErmilovThe
1177f4caa8cSMaxim Sobolev.Ar cluster_size
118cf7b3b65SRuslan Ermilovshould be a multiple of 512 bytes.
1197f4caa8cSMaxim Sobolev.It Fl v
1207f4caa8cSMaxim SobolevDisplay verbose messages.
1218f8cb840SMaxim Sobolev.It Fl Z
1228f8cb840SMaxim SobolevDisable zero-blocks detection and elimination.
1238f8cb840SMaxim SobolevWhen this option is set, the
1248f8cb840SMaxim Sobolev.Nm
1258f8cb840SMaxim Sobolevwould compress empty blocks (i.e. clusters that consist of only zero bytes)
1268f8cb840SMaxim Sobolevjust as it would any other block.
1278f8cb840SMaxim SobolevWhen the option is not set, the
1288f8cb840SMaxim Sobolev.Nm
1298f8cb840SMaxim Sobolevdetects such blocks and skips them from the output.
1308f8cb840SMaxim SobolevSetting
1318f8cb840SMaxim Sobolev.Fl Z
1328f8cb840SMaxim Sobolevresults is slight increase of compressed image size, typically less than 0.1%
1338f8cb840SMaxim Sobolevof a final size of the compressed image.
1347f4caa8cSMaxim Sobolev.El
1357f4caa8cSMaxim Sobolev.Sh NOTES
136d3ff2972SMaxim SobolevThe compression ratio largely depends on the cluster size used.
137d3ff2972SMaxim Sobolev.\" The following two sentences are unclear: how can gzip(1) be
138d3ff2972SMaxim Sobolev.\" used in a comparable fashion, and wouldn't a gzip-compressed
139d3ff2972SMaxim Sobolev.\" image suffer from larger cluster sizes as well?
140cf7b3b65SRuslan ErmilovFor large cluster sizes (16K and higher), typical compression ratios
141d3ff2972SMaxim Sobolevare only 1-2% less than those achieved with
142d3ff2972SMaxim Sobolev.Xr gzip 1 .
143cf7b3b65SRuslan ErmilovHowever, it should be kept in mind that larger cluster
1447f4caa8cSMaxim Sobolevsizes lead to higher overhead in the
1457f4caa8cSMaxim Sobolev.Xr geom_uzip 4
1467f4caa8cSMaxim Sobolevclass, as the class has to decompress the whole cluster even if
147d3ff2972SMaxim Sobolevonly a few bytes from that cluster have to be read.
14842ecdf05SMaxim Sobolev.Pp
149cb29445aSRuslan ErmilovThe
15042ecdf05SMaxim Sobolev.Nm
151cb29445aSRuslan Ermilovutility
152d3ff2972SMaxim Sobolevinserts a short shell script at the beginning of the generated image,
15342ecdf05SMaxim Sobolevwhich makes it possible to
154cf7b3b65SRuslan Ermilov.Dq run
155cf7b3b65SRuslan Ermilovthe image just like any other shell script.
156d3ff2972SMaxim SobolevThe script tries to load the
15742ecdf05SMaxim Sobolev.Xr geom_uzip 4
158d3ff2972SMaxim Sobolevclass if it is not loaded, configure the image as an
15942ecdf05SMaxim Sobolev.Xr md 4
16042ecdf05SMaxim Sobolevdisk device using
161d3ff2972SMaxim Sobolev.Xr mdconfig 8 ,
162d3ff2972SMaxim Sobolevand automatically mount it using
16342ecdf05SMaxim Sobolev.Xr mount_cd9660 8
164d3ff2972SMaxim Sobolevon the mount point provided as the first argument to the script.
1658f8cb840SMaxim Sobolev.Pp
1668f8cb840SMaxim SobolevThe de-duplication is a
1678f8cb840SMaxim Sobolev.Fx
1688f8cb840SMaxim Sobolevspecific feature and while it does not require any changes to on-disk
1698f8cb840SMaxim Sobolevcompressed image format, however it did require some matching changes to the
1708f8cb840SMaxim Sobolev.Xr geom_uzip 4
1718f8cb840SMaxim Sobolevto handle resulting images correctly.
1726c7216dfSRuslan Ermilov.Sh EXIT STATUS
1736c7216dfSRuslan Ermilov.Ex -std
1747f4caa8cSMaxim Sobolev.Sh SEE ALSO
1757f4caa8cSMaxim Sobolev.Xr gzip 1 ,
1768f8cb840SMaxim Sobolev.Xr xz 1 ,
1778f8cb840SMaxim Sobolev.Xr lzma 3 ,
178b7dd44ebSBaptiste Daroussin.Xr zlib 3 ,
17942ecdf05SMaxim Sobolev.Xr geom 4 ,
180cf7b3b65SRuslan Ermilov.Xr geom_uzip 4 ,
18142ecdf05SMaxim Sobolev.Xr md 4 ,
18242ecdf05SMaxim Sobolev.Xr mdconfig 8 ,
183cf7b3b65SRuslan Ermilov.Xr mount_cd9660 8
1847f4caa8cSMaxim Sobolev.Sh AUTHORS
1852b7af31cSBaptiste Daroussin.An Maxim Sobolev Aq Mt sobomax@FreeBSD.org
186