1a5eb4ea3SMarcel Moolenaar.\" Copyright (c) 2013, 2014 Juniper Networks, Inc. 2a5eb4ea3SMarcel Moolenaar.\" All rights reserved. 3a5eb4ea3SMarcel Moolenaar.\" 4a5eb4ea3SMarcel Moolenaar.\" Redistribution and use in source and binary forms, with or without 5a5eb4ea3SMarcel Moolenaar.\" modification, are permitted provided that the following conditions 6a5eb4ea3SMarcel Moolenaar.\" are met: 7a5eb4ea3SMarcel Moolenaar.\" 8a5eb4ea3SMarcel Moolenaar.\" 1. Redistributions of source code must retain the above copyright 9a5eb4ea3SMarcel Moolenaar.\" notice, this list of conditions and the following disclaimer. 10a5eb4ea3SMarcel Moolenaar.\" 2. Redistributions in binary form must reproduce the above copyright 11a5eb4ea3SMarcel Moolenaar.\" notice, this list of conditions and the following disclaimer in the 12a5eb4ea3SMarcel Moolenaar.\" documentation and/or other materials provided with the distribution. 13a5eb4ea3SMarcel Moolenaar.\" 14a5eb4ea3SMarcel Moolenaar.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15a5eb4ea3SMarcel Moolenaar.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16a5eb4ea3SMarcel Moolenaar.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17a5eb4ea3SMarcel Moolenaar.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18a5eb4ea3SMarcel Moolenaar.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19a5eb4ea3SMarcel Moolenaar.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20a5eb4ea3SMarcel Moolenaar.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21a5eb4ea3SMarcel Moolenaar.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22a5eb4ea3SMarcel Moolenaar.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23a5eb4ea3SMarcel Moolenaar.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24a5eb4ea3SMarcel Moolenaar.\" 2595ac5b0eSMark Johnston.Dd June 25, 2025 26a5eb4ea3SMarcel Moolenaar.Dt MKIMG 1 27a5eb4ea3SMarcel Moolenaar.Os 28a5eb4ea3SMarcel Moolenaar.Sh NAME 29a5eb4ea3SMarcel Moolenaar.Nm mkimg 30264f86e1SMarcel Moolenaar.Nd "utility to make disk images" 31a5eb4ea3SMarcel Moolenaar.Sh SYNOPSIS 32a5eb4ea3SMarcel Moolenaar.Nm 33a5eb4ea3SMarcel Moolenaar.Op Fl H Ar heads 34a5eb4ea3SMarcel Moolenaar.Op Fl P Ar blksz 35a5eb4ea3SMarcel Moolenaar.Op Fl S Ar secsz 36a5eb4ea3SMarcel Moolenaar.Op Fl T Ar tracksz 37a5eb4ea3SMarcel Moolenaar.Op Fl b Ar bootcode 382dcfca63SEmmanuel Vadot.Op Fl c Ar min_capacity 392dcfca63SEmmanuel Vadot.Op Fl C Ar max_capacity 402dcfca63SEmmanuel Vadot.Op Fl -capacity Ar capacity 41f0e9dcedSMarcel Moolenaar.Op Fl f Ar format 42a5eb4ea3SMarcel Moolenaar.Op Fl o Ar outfile 43c30dcf40SWarner Losh.Op Fl a Ar active 44*393fefa3SMark Johnston.Op Fl t Ar timestamp 45a5eb4ea3SMarcel Moolenaar.Op Fl v 46264f86e1SMarcel Moolenaar.Op Fl y 47e6679c1aSMarcel Moolenaar.Op Fl s Ar scheme Op Fl p Ar partition ... 48fb2f6c6cSMarcel Moolenaar.Nm 4919870105SMateusz Piotrowski.Fl -formats | Fl -schemes | Fl -version 50a5eb4ea3SMarcel Moolenaar.Sh DESCRIPTION 51a5eb4ea3SMarcel MoolenaarThe 52a5eb4ea3SMarcel Moolenaar.Nm 53a5eb4ea3SMarcel Moolenaarutility creates a disk image from the raw partition contents specified with 54a5eb4ea3SMarcel Moolenaarthe 55a5eb4ea3SMarcel Moolenaar.Ar partition 56a5eb4ea3SMarcel Moolenaarargument(s) and using the partitioning scheme specified with the 57a5eb4ea3SMarcel Moolenaar.Ar scheme 58a5eb4ea3SMarcel Moolenaarargument. 59a5eb4ea3SMarcel MoolenaarThe disk image is written to 60a5eb4ea3SMarcel Moolenaar.Ar stdout 61a5eb4ea3SMarcel Moolenaarby default or the file specified with the 62a5eb4ea3SMarcel Moolenaar.Ar outfile 63a5eb4ea3SMarcel Moolenaarargument. 64f0e9dcedSMarcel MoolenaarThe image file is a raw disk image by default, but the format of the 65f0e9dcedSMarcel Moolenaarimage file can be specified with the 66f0e9dcedSMarcel Moolenaar.Ar format 67f0e9dcedSMarcel Moolenaarargument. 687f0dc6e2SEugene GrosbeinMost formats require seekable output, except of raw disk image. 69a5eb4ea3SMarcel Moolenaar.Pp 70a5eb4ea3SMarcel MoolenaarThe disk image can be made bootable by specifying the scheme-specific boot 71a5eb4ea3SMarcel Moolenaarblock contents with the 72a5eb4ea3SMarcel Moolenaar.Ar bootcode 73a5eb4ea3SMarcel Moolenaarargument and, 74a5eb4ea3SMarcel Moolenaardepending on the scheme, 75a5eb4ea3SMarcel Moolenaarwith a boot partition. 76a5eb4ea3SMarcel MoolenaarThe contents of such a boot partition is provided like any other partition 77a5eb4ea3SMarcel Moolenaarand the 78a5eb4ea3SMarcel Moolenaar.Nm 79a5eb4ea3SMarcel Moolenaarutility does not treat it any differently from other partitions. 80a5eb4ea3SMarcel Moolenaar.Pp 81a5eb4ea3SMarcel MoolenaarSome partitioning schemes need a disk geometry and for those the 82a5eb4ea3SMarcel Moolenaar.Nm 83a5eb4ea3SMarcel Moolenaarutility accepts the 84a5eb4ea3SMarcel Moolenaar.Ar tracksz 85a5eb4ea3SMarcel Moolenaarand 86a5eb4ea3SMarcel Moolenaar.Ar heads 87a5eb4ea3SMarcel Moolenaararguments, specifying the number of sectors per track and the number of 88a5eb4ea3SMarcel Moolenaarheads per cylinder (resp.) 89a5eb4ea3SMarcel Moolenaar.Pp 90a5eb4ea3SMarcel MoolenaarBoth the logical and physical sector size can be specified and for that the 91a5eb4ea3SMarcel Moolenaar.Nm 92a5eb4ea3SMarcel Moolenaarutility 93a5eb4ea3SMarcel Moolenaaraccepts the 94a5eb4ea3SMarcel Moolenaar.Ar secsz 95a5eb4ea3SMarcel Moolenaarand 96a5eb4ea3SMarcel Moolenaar.Ar blksz 97a5eb4ea3SMarcel Moolenaararguments. 98a5eb4ea3SMarcel MoolenaarThe 99a5eb4ea3SMarcel Moolenaar.Ar secsz 100a5eb4ea3SMarcel Moolenaarargument is used to specify the logical sector size. 101a5eb4ea3SMarcel MoolenaarThis is the sector size reported by a disk when queried for its capacity. 102a5eb4ea3SMarcel MoolenaarModern disks use a larger sector size internally, 103a5eb4ea3SMarcel Moolenaarreferred to as block size by the 104a5eb4ea3SMarcel Moolenaar.Nm 105a5eb4ea3SMarcel Moolenaarutility and this can be specified by the 106a5eb4ea3SMarcel Moolenaar.Ar blksz 107a5eb4ea3SMarcel Moolenaarargument. 108a5eb4ea3SMarcel MoolenaarThe 109a5eb4ea3SMarcel Moolenaar.Nm 110a5eb4ea3SMarcel Moolenaarutility will use the (physical) block size to determine the start of 111a5eb4ea3SMarcel Moolenaarpartitions and to round the size of the disk image. 112a5eb4ea3SMarcel Moolenaar.Pp 113a5eb4ea3SMarcel MoolenaarThe 114e6679c1aSMarcel Moolenaar.Fl c 115e6679c1aSMarcel Moolenaaroption can be used to specify a minimal capacity for the disk image. 116e6679c1aSMarcel MoolenaarUse this option without the 117e6679c1aSMarcel Moolenaar.Fl s 118e6679c1aSMarcel Moolenaarand 119e6679c1aSMarcel Moolenaar.Fl p 120e6679c1aSMarcel Moolenaaroptions to create an empty disk image with the given (virtual) size. 121e6679c1aSMarcel MoolenaarAn empty partition table can be written to the disk when specifying a 122e6679c1aSMarcel Moolenaarpartitioning scheme with the 123e6679c1aSMarcel Moolenaar.Fl s 124e6679c1aSMarcel Moolenaaroption, but without specifying any partitions. 125c30dcf40SWarner LoshWhen the size required for all the partitions is larger than the 126e6679c1aSMarcel Moolenaargiven capacity, then the disk image will be larger than the capacity 127e6679c1aSMarcel Moolenaargiven. 128e6679c1aSMarcel Moolenaar.Pp 129e6679c1aSMarcel MoolenaarThe 1302dcfca63SEmmanuel Vadot.Fl C 1312dcfca63SEmmanuel Vadotoption specifies a maximum capacity for the disk image. 1322dcfca63SEmmanuel VadotIf the combined sizes of the given partitions exceed the size given with 1332dcfca63SEmmanuel Vadot.Fl C , 1342dcfca63SEmmanuel Vadotimage creation fails. 1352dcfca63SEmmanuel Vadot.Pp 1362dcfca63SEmmanuel VadotThe 1372dcfca63SEmmanuel Vadot.Fl -capacity 1382dcfca63SEmmanuel Vadotoption is a shorthand to specify the minimum and maximum capacity at the 1392dcfca63SEmmanuel Vadotsame time. 1402dcfca63SEmmanuel Vadot.Pp 1412dcfca63SEmmanuel VadotThe 142*393fefa3SMark Johnston.Fl t 143*393fefa3SMark Johnstonoption causes any timestamps embedded in the output file to be set to the 144*393fefa3SMark Johnstongiven time, specified in seconds since the epoch. 14595ac5b0eSMark Johnston.Pp 14695ac5b0eSMark JohnstonThe 147e6679c1aSMarcel Moolenaar.Fl v 148a5eb4ea3SMarcel Moolenaaroption increases the level of output that the 149a5eb4ea3SMarcel Moolenaar.Nm 150a5eb4ea3SMarcel Moolenaarutility prints. 151a5eb4ea3SMarcel Moolenaar.Pp 152264f86e1SMarcel MoolenaarThe 153e6679c1aSMarcel Moolenaar.Fl y 154264f86e1SMarcel Moolenaaroption is used for testing purposes only and is not to be used in production. 155264f86e1SMarcel MoolenaarWhen present, the 156264f86e1SMarcel Moolenaar.Nm 157264f86e1SMarcel Moolenaarutility will generate predictable values for Universally Unique Identifiers 158264f86e1SMarcel Moolenaar(UUIDs) and time stamps so that consecutive runs of the 159264f86e1SMarcel Moolenaar.Nm 160264f86e1SMarcel Moolenaarutility will create images that are identical. 161264f86e1SMarcel Moolenaar.Pp 162c30dcf40SWarner LoshThe 163c30dcf40SWarner Losh.Ar active 164c30dcf40SWarner Loshoption marks a partition as active, if the partitioning 165c30dcf40SWarner Loshscheme supports it. 166c30dcf40SWarner LoshCurrently, only the 167c30dcf40SWarner Losh.Ar mbr 168c30dcf40SWarner Loshscheme supports this concept. 169c30dcf40SWarner LoshBy default, 170c30dcf40SWarner Losh.Nm 171c30dcf40SWarner Loshwill only mark the first partition as active when boot code is 172c30dcf40SWarner Loshspecified. 173c30dcf40SWarner LoshUse the 174c30dcf40SWarner Losh.Ar active 175c30dcf40SWarner Loshoption to override the active partition. 176c30dcf40SWarner LoshThe number specified corresponds to the number after the 's' in the 177c30dcf40SWarner Loshpartition's 178c30dcf40SWarner Losh.Xr geom 8 179c30dcf40SWarner Loshname. 180c30dcf40SWarner LoshNo partitions are marked active when the value is 0. 181c30dcf40SWarner Losh.Pp 182fb2f6c6cSMarcel MoolenaarA set of long options exist to query about the 183fb2f6c6cSMarcel Moolenaar.Nm 184de932526SMarcel Moolenaarutility itself. 185fb2f6c6cSMarcel MoolenaarOptions in this set should be given by themselves because the 186fb2f6c6cSMarcel Moolenaar.Nm 187fb2f6c6cSMarcel Moolenaarutility exits immediately after providing the requested information. 188fb2f6c6cSMarcel MoolenaarThe version of the 189fb2f6c6cSMarcel Moolenaar.Nm 190fb2f6c6cSMarcel Moolenaarutility is printed when the 19119870105SMateusz Piotrowski.Fl -version 192fb2f6c6cSMarcel Moolenaaroption is given. 193fb2f6c6cSMarcel MoolenaarThe list of supported output formats is printed when the 19419870105SMateusz Piotrowski.Fl -formats 195fb2f6c6cSMarcel Moolenaaroption is given and the list of supported partitioning schemes is printed 196fb2f6c6cSMarcel Moolenaarwhen the 19719870105SMateusz Piotrowski.Fl -schemes 198fb2f6c6cSMarcel Moolenaaroption is given. 199fb2f6c6cSMarcel MoolenaarBoth the format and scheme lists a space-separated lists for easy handling 200fb2f6c6cSMarcel Moolenaarin scripts. 201fb2f6c6cSMarcel Moolenaar.Pp 202fb2f6c6cSMarcel MoolenaarFor a more descriptive list of supported partitioning schemes or supported 203fb2f6c6cSMarcel Moolenaaroutput format, or for a detailed description of how to specify partitions, 204fb2f6c6cSMarcel Moolenaarrun the 205a5eb4ea3SMarcel Moolenaar.Nm 206a5eb4ea3SMarcel Moolenaarutility without any arguments. 207fb2f6c6cSMarcel MoolenaarThis will print a usage message with all the necessary details. 208de932526SMarcel Moolenaar.Sh DISK FORMATS 209de932526SMarcel MoolenaarThe 210de932526SMarcel Moolenaar.Nm 211de932526SMarcel Moolenaarutility supports a number of output file formats. 212de932526SMarcel MoolenaarA short description of these is given below. 213de932526SMarcel Moolenaar.Ss QCOW and QCOW2 214de932526SMarcel MoolenaarQCOW stands for "QEMU Copy On Write". 215de932526SMarcel MoolenaarIt's a sparse file format akin to VHD and VMDK and QCOW represents the 216de932526SMarcel Moolenaarfirst version. 217de932526SMarcel MoolenaarQCOW2 represents version 2 of the file format. 218de932526SMarcel MoolenaarVersion 2 is not backward compatible with version 1 and adds support for 219de932526SMarcel Moolenaarsnapshots among other things. 220de932526SMarcel MoolenaarThe QCOW file formats are natively supported by QEMU and Xen. 221de932526SMarcel MoolenaarTo write QCOW, specify 222de932526SMarcel Moolenaar.Fl f Ar qcow 223de932526SMarcel Moolenaaron the command line. 224de932526SMarcel MoolenaarTo write version 2 QCOW, specify 225de932526SMarcel Moolenaar.Fl f Ar qcow2 226de932526SMarcel Moolenaaron the command line. 2278f1d6b69SMarcel MoolenaarThe preferred file extension is ".qcow" and ".qcow2" for QCOW and QCOW2 228de932526SMarcel Moolenaar(resp.), but ".qcow" is sometimes used for version 2 files as well. 229de932526SMarcel Moolenaar.Ss RAW file format 230de932526SMarcel MoolenaarThis file format is a sector by sector representation of an actual disk. 2313d265fceSGordon BerglingThere is no extra information that describes or relates to the format itself. 2323d265fceSGordon BerglingThe size of the file is the size of the (virtual) disk. 2331a35ead6SYu-Hsun ChenThis file format is suitable for being copied onto a disk with utilities 234de932526SMarcel Moolenaarlike 235de932526SMarcel Moolenaar.Nm dd . 236de932526SMarcel MoolenaarTo write a raw disk file, either omit the 237de932526SMarcel Moolenaar.Fl f 238de932526SMarcel Moolenaaroption, or specify 239de932526SMarcel Moolenaar.Fl f Ar raw 240de932526SMarcel Moolenaaron the command line. 241de932526SMarcel MoolenaarThe preferred file extension is one of ".img" or ".raw", but there's no 242de932526SMarcel Moolenaarreal convention for it. 243de932526SMarcel Moolenaar.Ss Dynamic VHD and Fixed VHD 244de932526SMarcel MoolenaarMicrosoft's "Virtual Hard Disk" file formats. 245de932526SMarcel MoolenaarThe dynamic format is a sparse format akin to QCOW and VMDK. 246de932526SMarcel MoolenaarThe fixed format is effectively a raw format with a footer appended to the 247de932526SMarcel Moolenaarfile and as such it's often indistinguishable from the raw format. 248de932526SMarcel MoolenaarThe fixed file format has been added to support Microsoft's Azure platform 249de932526SMarcel Moolenaarand due to inconsistencies in interpretation of the footer is not compatible 250de932526SMarcel Moolenaarwith utilities like 251de932526SMarcel Moolenaar.Nm qemu 252de932526SMarcel Moolenaarwhen it is specifically instructed to interpreted the file as a VHD file. 253de932526SMarcel MoolenaarBy default 254de932526SMarcel Moolenaar.Nm qemu 255de932526SMarcel Moolenaarwill treat the file as a raw disk file, which mostly works fine. 256de932526SMarcel MoolenaarTo have 257de932526SMarcel Moolenaar.Nm 258de932526SMarcel Moolenaarcreate a dynamic VHD file, specify 259de932526SMarcel Moolenaar.Fl f Ar vhd 260de932526SMarcel Moolenaaron the command line. 261de932526SMarcel MoolenaarTo create a fixed VHD file for use by Azure, specify 262de932526SMarcel Moolenaar.Fl f Ar vhdf 263de932526SMarcel Moolenaaron the command line. 264de932526SMarcel MoolenaarThe preferred file extension is ".vhd". 265c78cd98bSOleksandr Tymoshenko.Ss Dynamic VHDX 266c78cd98bSOleksandr TymoshenkoMicrosoft's "Virtual Hard Disk v2" file formats, the 267c78cd98bSOleksandr Tymoshenkosuccessor to VHD. 268c78cd98bSOleksandr TymoshenkoVHDX is the required format for the 2nd generation Hyper-V VMs. 269c78cd98bSOleksandr TymoshenkoTo have 270c78cd98bSOleksandr Tymoshenko.Nm 271c78cd98bSOleksandr Tymoshenkocreate a dynamic VHDX file, specify 272c78cd98bSOleksandr Tymoshenko.Fl f Ar vhdx 273c78cd98bSOleksandr Tymoshenkoon the command line. 274c78cd98bSOleksandr TymoshenkoThe preferred file extension is ".vhdx". 275de932526SMarcel Moolenaar.Ss VMDK 276de932526SMarcel MoolenaarVMware's "Virtual Machine Disk" file format. 277de932526SMarcel MoolenaarIt's a sparse file format akin to QCOW and VHD and supported by many 278de932526SMarcel Moolenaarvirtualization solutions. 279de932526SMarcel MoolenaarTo create a VMDK file, specify 280de932526SMarcel Moolenaar.Fl f Ar vmdk 281de932526SMarcel Moolenaaron the command line. 282de932526SMarcel MoolenaarThe preferred file extension is ".vmdk". 283de932526SMarcel Moolenaar.Pp 284de932526SMarcel MoolenaarNot all virtualization solutions support all file formats, but often those 285de932526SMarcel Moolenaarvirtualization environments have utilities to convert from one format to 286de932526SMarcel Moolenaaranother. 287de932526SMarcel MoolenaarNote however that conversion may require that the virtual disk size is 288de932526SMarcel Moolenaarchanged to match the constraints of the output format and this may invalidate 289de932526SMarcel Moolenaarthe contents of the disk image. 290de932526SMarcel MoolenaarFor example, the GUID Partition Table (GPT) scheme has a header in the last 291de932526SMarcel Moolenaarsector on the disk. 292de932526SMarcel MoolenaarWhen changing the disk size, the GPT must be changed so that the last header 293de932526SMarcel Moolenaaris moved accordingly. 294de932526SMarcel MoolenaarThis is typically not part of the conversion process. 295de932526SMarcel MoolenaarIf possible, use an output format specifically for the environment in which 296de932526SMarcel Moolenaarthe file is intended to be used. 297d1797fb5SEugene Grosbein.Sh PARTITION SPECIFICATION 298d1797fb5SEugene GrosbeinAn option 299d1797fb5SEugene Grosbein.Fl p 300d1797fb5SEugene Grosbeinmay be used multiple times to specify a list of created partition entries. 301d1797fb5SEugene GrosbeinA specification that is a single dash indicates an unused partition entry. 302d1797fb5SEugene GrosbeinOtherwise, a partition specification has the following format: 303d1797fb5SEugene Grosbein.Bd -literal -offset indent 304d1797fb5SEugene Grosbein<type> ':' <kind> <contents> 305d1797fb5SEugene Grosbein.Ed 306d1797fb5SEugene Grosbein.Bl -tag -width indent 307d1797fb5SEugene Grosbein.It Cm type 308d1797fb5SEugene Grosbeinthe partition type alias (f.e.: freebsd-swap) 309d1797fb5SEugene Grosbeinthat may be optionally followed by a '/' separator 310d1797fb5SEugene Grosbeinand a label for partitioning schemes that feature partition labels 311d1797fb5SEugene Grosbein(see the 312d1797fb5SEugene Grosbein.Sx EXAMPLES 313d1797fb5SEugene GrosbeinSection below) 314d1797fb5SEugene Grosbein.It Cm kind 315d1797fb5SEugene Grosbeinthe interpretation of the contents specification: 316d1797fb5SEugene Grosbein.Bl -tag -width indent 317d1797fb5SEugene Grosbein.It Cm ':' 318d1797fb5SEugene Grosbeincontents holds the size of an empty partition, 319d1797fb5SEugene Grosbeina number that may be suffixed with one of K, M, G, T, P or E 320d1797fb5SEugene Grosbein(either upper or lower case) following the SI power of two convention 321d1797fb5SEugene Grosbein(see also 322d1797fb5SEugene Grosbein.Xr expand_number 3 ) 323d1797fb5SEugene Grosbein.It Cm '=' 324d1797fb5SEugene Grosbeincontents holds the name of a file to read 325d1797fb5SEugene Grosbein.It Cm '-' 326d1797fb5SEugene Grosbeincontents holds a command to run; the output of which is the contents 327d1797fb5SEugene Grosbeinof the partition. 328d1797fb5SEugene GrosbeinMulti-word strings should be quoted according to the shell rules. 329d1797fb5SEugene Grosbein.El 330d1797fb5SEugene Grosbein.It Cm contents 331d1797fb5SEugene Grosbeinthe specification of a partition's contents 332d1797fb5SEugene Grosbein.El 333b6829dc8SJoel Dahl.Sh ENVIRONMENT 334b6829dc8SJoel Dahl.Bl -tag -width "TMPDIR" -compact 335b6829dc8SJoel Dahl.It Ev TMPDIR 336b6829dc8SJoel DahlDirectory to put temporary files in; default is 337b6829dc8SJoel Dahl.Pa /tmp . 338b6829dc8SJoel Dahl.El 339a5eb4ea3SMarcel Moolenaar.Sh EXAMPLES 340a5eb4ea3SMarcel MoolenaarTo create a bootable disk image that is partitioned using the GPT scheme and 341a5eb4ea3SMarcel Moolenaarcontaining a root file system that was previously created using 3420e630e32SBaptiste Daroussin.Xr makefs 8 343a5eb4ea3SMarcel Moolenaarand also containing a swap partition, run the 344a5eb4ea3SMarcel Moolenaar.Nm 345a5eb4ea3SMarcel Moolenaarutility as follows: 346a5eb4ea3SMarcel Moolenaar.Dl % mkimg -s gpt -b /boot/pmbr -p freebsd-boot:=/boot/gptboot \ 347a5eb4ea3SMarcel Moolenaar-p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G \ 348a5eb4ea3SMarcel Moolenaar-o gpt.img 349a5eb4ea3SMarcel Moolenaar.Pp 350f0e9dcedSMarcel MoolenaarThe command line given above results in a raw image file. 351f0e9dcedSMarcel MoolenaarThis is because no output format was given. 352f0e9dcedSMarcel MoolenaarTo create a VMDK image for example, add the 353f0e9dcedSMarcel Moolenaar.Fl f Ar vmdk 354f0e9dcedSMarcel Moolenaarargument to the 355f0e9dcedSMarcel Moolenaar.Nm 356f0e9dcedSMarcel Moolenaarutility and name the output file accordingly. 357f0e9dcedSMarcel Moolenaar.Pp 358a5eb4ea3SMarcel MoolenaarA nested partitioning scheme is created by running the 359a5eb4ea3SMarcel Moolenaar.Nm 360a5eb4ea3SMarcel Moolenaarutility twice. 361a5eb4ea3SMarcel MoolenaarThe output of the first will be fed as the contents of a partition to the 362a5eb4ea3SMarcel Moolenaarsecond. 363a5eb4ea3SMarcel MoolenaarThis can be done using a temporary file, like so: 364a5eb4ea3SMarcel Moolenaar.Dl % mkimg -s bsd -b /boot/boot -p freebsd-ufs:=root-file-system.ufs \ 365a5eb4ea3SMarcel Moolenaar-p freebsd-swap::1G -o /tmp/bsd.img 366a5eb4ea3SMarcel Moolenaar.Dl % mkimg -s mbr -b /boot/mbr -p freebsd:=/tmp/bsd.img -o mbr-bsd.img 367a5eb4ea3SMarcel Moolenaar.Pp 368a5eb4ea3SMarcel MoolenaarAlternatively, the 369a5eb4ea3SMarcel Moolenaar.Nm 370a5eb4ea3SMarcel Moolenaarutility can be run in a cascaded fashion, whereby the output of the 371a5eb4ea3SMarcel Moolenaarfirst is fed directly into the second. 372a5eb4ea3SMarcel MoolenaarTo do this, run the 373a5eb4ea3SMarcel Moolenaar.Nm 374a5eb4ea3SMarcel Moolenaarutility as follows: 375a5eb4ea3SMarcel Moolenaar.Dl % mkimg -s mbr -b /boot/mbr -p freebsd:-'mkimg -s bsd -b /boot/boot \ 376a5eb4ea3SMarcel Moolenaar-p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G' -o mbr-bsd.img 377a5eb4ea3SMarcel Moolenaar.Pp 378463a577bSEitan AdlerTo accommodate the need to have partitions named or numbered in a certain 379752bf469SMarcel Moolenaarway, the 380752bf469SMarcel Moolenaar.Nm 381752bf469SMarcel Moolenaarutility allows for the specification of empty partitions. 382752bf469SMarcel MoolenaarFor example, to create an image that is compatible with partition layouts 383752bf469SMarcel Moolenaarfound in 384752bf469SMarcel Moolenaar.Pa /etc/disktab , 385752bf469SMarcel Moolenaarthe 'd' partition often needs to be skipped. 386752bf469SMarcel MoolenaarThis is accomplished by inserting an unused partition after the first 2 387752bf469SMarcel Moolenaarpartition specifications. 388752bf469SMarcel MoolenaarIt is worth noting at this time that the BSD scheme will automatically 389752bf469SMarcel Moolenaarskip the 'c' partition by virtue of it referring to the entire disk. 390752bf469SMarcel MoolenaarTo create an image that is compatible with the qp120at disk, use the 391752bf469SMarcel Moolenaar.Nm 392752bf469SMarcel Moolenaarutility as follows: 393752bf469SMarcel Moolenaar.Dl % mkimg -s bsd -b /boot/boot -p freebsd-ufs:=root-file-system.ufs \ 394752bf469SMarcel Moolenaar-p freebsd-swap::20M -p- -p- -p- -p- -p freebsd-ufs:=usr-file-system.ufs \ 395752bf469SMarcel Moolenaar-o bsd.img 396752bf469SMarcel Moolenaar.Pp 397a5eb4ea3SMarcel MoolenaarFor partitioning schemes that feature partition labels, the 398a5eb4ea3SMarcel Moolenaar.Nm 399a5eb4ea3SMarcel Moolenaarutility supports assigning labels to the partitions specified. 400a5eb4ea3SMarcel MoolenaarIn the following example the file system partition is labeled as 'backup': 401a5eb4ea3SMarcel Moolenaar.Dl % mkimg -s gpt -p freebsd-ufs/backup:=file-system.ufs -o gpt.img 402a5eb4ea3SMarcel Moolenaar.Sh SEE ALSO 403de932526SMarcel Moolenaar.Xr dd 1 , 404d1797fb5SEugene Grosbein.Xr expand_number 3 , 40565dd075bSEdward Tomasz Napierala.Xr gpart 8 , 40665dd075bSEdward Tomasz Napierala.Xr makefs 8 , 40765dd075bSEdward Tomasz Napierala.Xr mdconfig 8 , 408a5eb4ea3SMarcel Moolenaar.Xr newfs 8 409a5eb4ea3SMarcel Moolenaar.Sh HISTORY 410a5eb4ea3SMarcel MoolenaarThe 411a5eb4ea3SMarcel Moolenaar.Nm 41273f28b23SMarcel Moolenaarutility first appeared in 41391e9fb22SMarcel Moolenaar.Fx 10.1 . 414a5eb4ea3SMarcel Moolenaar.Sh AUTHORS 415a5eb4ea3SMarcel MoolenaarThe 416a5eb4ea3SMarcel Moolenaar.Nm 41799d43aeeSChristian Bruefferutility and manpage were written by 418005156d7SAlan Somers.An Marcel Moolenaar Aq Mt marcel@FreeBSD.org . 419