5 OCK Builder Utilities

Lists the individual scripts that the OCK Image Builder tool consists of.

The ock-forge utility is a shell script that relies on other shell scripts to do its work. Each of the shell scripts can be useful by itself, but probably requires editing to make it so.

WARNING:

Ensure that you understand how these scripts function before changing them. These utility scripts can be destructive if used incorrectly.

The shell scripts that make up the OCK Image Builder tool are listed in the following table.

Table 5-1 OCK Image Builder Utility Scripts

Script Options Notes

setup-vm-disk.sh

-d network-block-device

-D path-to-new-image

Creates a Qcow2 image and attaches it to a network block device.

sparsify-image.sh

-D path-to-image

Re-sparsifies and compresses a Qcow2 image. It does part of the job of virt-sparsify and the result isn't as good. However, it has the advantage of not requiring a VM and can be used in environments where starting a VM isn't an option. For example, building an image inside an ARM VM. It requires several gigabytes of storage while running. That space is released by the time the script ends.

make-partitions.sh

-d path-to-device

-f filesystem

Partitions a disk using a standard layout. It creates a small EFI partition as partition 1, a small boot partition as partition 2, and a root partition with the rest of the disk as the last partition.

Example 5-1 Creating and attaching Qcow2 images

To create a Qcow2 image and attach it to /dev/nbd0:

sudo ./setup-vm-disk -d /dev/nbd0 -D mydisk.qcow2

Example 5-2 Sparsify a Qcow2 image

To sparsify and compress an existing Qcow2 image:

sudo ./sparsify-image.sh -D mydisk.qcow2

Example 5-3 Partition a disk

To partition a physical block device using XFS:

sudo ./make-partitions.sh -d /dev/sdb -f xfs