xref: /freebsd/usr.bin/mkimg/mkimg.1 (revision 9ecd54f24fe9fa373e07c9fd7c052deb2188f545)
1.\" Copyright (c) 2013, 2014 Juniper Networks, Inc.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\"
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd March 27, 2014
28.Dt MKIMG 1
29.Os
30.Sh NAME
31.Nm mkimg
32.Nd "utility to make a disk image"
33.Sh SYNOPSIS
34.Nm
35.Op Fl H Ar heads
36.Op Fl P Ar blksz
37.Op Fl S Ar secsz
38.Op Fl T Ar tracksz
39.Op Fl b Ar bootcode
40.Op Fl o Ar outfile
41.Op Fl v
42.Fl s Ar scheme
43.Fl p Ar partition
44.Op Fl p Ar partition ...
45.Sh DESCRIPTION
46The
47.Nm
48utility creates a disk image from the raw partition contents specified with
49the
50.Ar partition
51argument(s) and using the partitioning scheme specified with the
52.Ar scheme
53argument.
54The disk image is written to
55.Ar stdout
56by default or the file specified with the
57.Ar outfile
58argument.
59.Pp
60The disk image can be made bootable by specifying the scheme-specific boot
61block contents with the
62.Ar bootcode
63argument and,
64depending on the scheme,
65with a boot partition.
66The contents of such a boot partition is provided like any other partition
67and the
68.Nm
69utility does not treat it any differently from other partitions.
70.Pp
71Some partitioning schemes need a disk geometry and for those the
72.Nm
73utility accepts the
74.Ar tracksz
75and
76.Ar heads
77arguments, specifying the number of sectors per track and the number of
78heads per cylinder (resp.)
79.Pp
80Both the logical and physical sector size can be specified and for that the
81.Nm
82utility
83accepts the
84.Ar secsz
85and
86.Ar blksz
87arguments.
88The
89.Ar secsz
90argument is used to specify the logical sector size.
91This is the sector size reported by a disk when queried for its capacity.
92Modern disks use a larger sector size internally,
93referred to as block size by the
94.Nm
95utility and this can be specified by the
96.Ar blksz
97argument.
98The
99.Nm
100utility will use the (physical) block size to determine the start of
101partitions and to round the size of the disk image.
102.Pp
103The
104.Op Fl v
105option increases the level of output that the
106.Nm
107utility prints.
108.Pp
109For a complete list of supported partitioning schemes or for a detailed
110description of how to specify partitions, run the
111.Nm
112utility without any arguments.
113.Sh EXAMPLES
114To create a bootable disk image that is partitioned using the GPT scheme and
115containing a root file system that was previously created using
116.Xr makefs
117and also containing a swap partition, run the
118.Nm
119utility as follows:
120.Dl % mkimg -s gpt -b /boot/pmbr -p freebsd-boot:=/boot/gptboot \
121-p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G \
122-o gpt.img
123.Pp
124A nested partitioning scheme is created by running the
125.Nm
126utility twice.
127The output of the first will be fed as the contents of a partition to the
128second.
129This can be done using a temporary file, like so:
130.Dl % mkimg -s bsd -b /boot/boot -p freebsd-ufs:=root-file-system.ufs \
131-p freebsd-swap::1G -o /tmp/bsd.img
132.Dl % mkimg -s mbr -b /boot/mbr -p freebsd:=/tmp/bsd.img -o mbr-bsd.img
133.Pp
134Alternatively, the
135.Nm
136utility can be run in a cascaded fashion, whereby the output of the
137first is fed directly into the second.
138To do this, run the
139.Nm
140utility as follows:
141.Dl % mkimg -s mbr -b /boot/mbr -p freebsd:-'mkimg -s bsd -b /boot/boot \
142-p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G' -o mbr-bsd.img
143.Pp
144For partitioning schemes that feature partition labels, the
145.Nm
146utility supports assigning labels to the partitions specified.
147In the following example the file system partition is labeled as 'backup':
148.Dl % mkimg -s gpt -p freebsd-ufs/backup:=file-system.ufs -o gpt.img
149.Sh SEE ALSO
150.Xr gpart 8
151.Xr makefs 8
152.Xr mdconfig 8
153.Xr newfs 8
154.Sh HISTORY
155The
156.Nm
157utility appeared in
158.Fx 11.0
159.Sh AUTHORS
160The
161.Nm
162utility and manpage were written by Marcel Moolenaar <marcelm@juniper.net>
163