Main index | Section 1 | Options |
The disk image can be made bootable by specifying the scheme-specific boot block contents with the bootcode argument and, depending on the scheme, with a boot partition. The contents of such a boot partition is provided like any other partition and the mkimg utility does not treat it any differently from other partitions.
Some partitioning schemes need a disk geometry and for those the mkimg utility accepts the tracksz and heads arguments, specifying the number of sectors per track and the number of heads per cylinder (resp.)
Both the logical and physical sector size can be specified and for that the mkimg utility accepts the secsz and blksz arguments. The secsz argument is used to specify the logical sector size. This is the sector size reported by a disk when queried for its capacity. Modern disks use a larger sector size internally, referred to as block size by the mkimg utility and this can be specified by the blksz argument. The mkimg utility will use the (physical) block size to determine the start of partitions and to round the size of the disk image.
The
The
The
The
The
The active option marks a partition as active, if the partitioning scheme supports it. Currently, only the mbr scheme supports this concept. By default, mkimg will only mark the first partition as active when boot code is specified. Use the active option to override the active partition. The number specified corresponds to the number after the 's' in the partition's geom(8) name. No partitions are marked active when the value is 0.
A set of long options exist to query about the
mkimg
utility itself.
Options in this set should be given by themselves because the
mkimg
utility exits immediately after providing the requested information.
The version of the
mkimg
utility is printed when the
For a more descriptive list of supported partitioning schemes or supported output format, or for a detailed description of how to specify partitions, run the mkimg utility without any arguments. This will print a usage message with all the necessary details.
Not all virtualization solutions support all file formats, but often those virtualization environments have utilities to convert from one format to another. Note however that conversion may require that the virtual disk size is changed to match the constraints of the output format and this may invalidate the contents of the disk image. For example, the GUID Partition Table (GPT) scheme has a header in the last sector on the disk. When changing the disk size, the GPT must be changed so that the last header is moved accordingly. This is typically not part of the conversion process. If possible, use an output format specifically for the environment in which the file is intended to be used.
TMPDIR | |
Directory to put temporary files in; default is /tmp. | |
% mkimg -s gpt -b /boot/pmbr -p freebsd-boot:=/boot/gptboot
-p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G -o gpt.img
The command line given above results in a raw image file.
This is because no output format was given.
To create a VMDK image for example, add the
A nested partitioning scheme is created by running the mkimg utility twice. The output of the first will be fed as the contents of a partition to the second. This can be done using a temporary file, like so:
% mkimg -s bsd -b /boot/boot -p freebsd-ufs:=root-file-system.ufs
-p freebsd-swap::1G -o /tmp/bsd.img
% mkimg -s mbr -b /boot/mbr -p freebsd:=/tmp/bsd.img -o mbr-bsd.img
Alternatively, the mkimg utility can be run in a cascaded fashion, whereby the output of the first is fed directly into the second. To do this, run the mkimg utility as follows:
% mkimg -s mbr -b /boot/mbr -p freebsd:-'mkimg -s bsd -b /boot/boot
-p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G' -o mbr-bsd.img
To accommodate the need to have partitions named or numbered in a certain way, the mkimg utility allows for the specification of empty partitions. For example, to create an image that is compatible with partition layouts found in /etc/disktab, the 'd' partition often needs to be skipped. This is accomplished by inserting an unused partition after the first 2 partition specifications. It is worth noting at this time that the BSD scheme will automatically skip the 'c' partition by virtue of it referring to the entire disk. To create an image that is compatible with the qp120at disk, use the mkimg utility as follows:
% mkimg -s bsd -b /boot/boot -p freebsd-ufs:=root-file-system.ufs
-p freebsd-swap::20M -p- -p- -p- -p- -p freebsd-ufs:=usr-file-system.ufs -o bsd.img
For partitioning schemes that feature partition labels, the mkimg utility supports assigning labels to the partitions specified. In the following example the file system partition is labeled as 'backup':
% mkimg -s gpt -p freebsd-ufs/backup:=file-system.ufs -o gpt.img
MKIMG (1) | June 8, 2020 |
Main index | Section 1 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | How do you pronounce UNIX ? You Nix ! | ” |