5.6. bootc-image-builder を使用したイメージモードのディスクイメージへの高度なパーティション設定の追加
bootc-image-builder のブループリントをカスタマイズして、osbuild-composer
の高度なパーティション分割を実装できます。考えられるカスタムマウントポイントは次のとおりです。
-
LVM ベースのイメージは、
/boot
および/boot/efi
を除くすべてのパーティションの下に作成できます。 - LV ベースのスワップを作成できます。
- VG および LV のカスタム名を指定できます。
bootc-image-builder
が読み取るベースイメージにパーティショニング設定を追加してパーティショニングレイアウトを作成し、コンテナー自体がパーティションテーブルの 信頼できるソース となります。パーティションおよび論理ボリュームのマウントポイントは、ディスクの構築に使用する基本コンテナーイメージに作成する必要があります。これは、/app
マウントポイントなどのトップレベルのマウントポイントで特に重要です。bootc-image-builder
は、起動不可能なイメージを作成しないように、ビルド前に bootc コンテナーに対して設定を検証します。
前提条件
- ホストマシンに Podman がインストールされている。
-
bootc-image-builder
ツールを実行し、コンテナーを--privileged
モードで実行して、イメージをビルドするための root アクセスがある。 - QEMU がインストールされている。
手順
以下の内容で
config.tom
ファイルを作成します。ユーザーをイメージに追加します。
[[customizations.user]] name = "user1" password = "user2" key = "ssh-rsa AAA ... user@email.com" groups = ["wheel"] # Set a size for the root partition: [[customizations.partitioning.plain.filesystems]] mountpoint = "/" type = "ext4" minsize = "3 GiB" # Add an extra data partition [[customizations.partitioning.plain.filesystems]] mountpoint = "/var/data" type = "xfs" minsize = "2 GiB" label = "data" # Add an app partition with a top-level mountpoint. # Requires derived container. [[customizations.partitioning.plain.filesystems]] mountpoint = "/app" type = "xfs" minsize = "1 GiB" label = "app" # Add the LVM configuration: # Define the LVM Volume Group name and size [[customizations.partitioning.lvm.volume_groups]] name = "centosvg" minsize = 10737418240 # 10 GiB # Add a data Logical Volume to the group [[customizations.partitioning.lvm.volume_groups.logical_volumes]] name = "datalv" mountpoint = "/var/data" label = "data" minsize = "1 GiB" type = "xfs" # The root Logical Volume is created automatically if not defined, but setting # it lets us set the name, label, and size explicitly [[customizations.partitioning.lvm.volume_groups.logical_volumes]] name = "rootlv" mountpoint = "/" label = "system" minsize = "2 GiB" type = "ext4" # Add an app Logical Volume with a top-level mountpoint. # Requires derived container. [[customizations.partitioning.lvm.volume_groups.logical_volumes]] mountpoint = "/app" type = "xfs" minsize = "1 GiB" label = "app" name = "applv"
[[customizations.user]] name = "user1" password = "user2" key = "ssh-rsa AAA ... user@email.com" groups = ["wheel"] # Set a size for the root partition: [[customizations.partitioning.plain.filesystems]] mountpoint = "/" type = "ext4" minsize = "3 GiB" # Add an extra data partition [[customizations.partitioning.plain.filesystems]] mountpoint = "/var/data" type = "xfs" minsize = "2 GiB" label = "data" # Add an app partition with a top-level mountpoint. # Requires derived container. [[customizations.partitioning.plain.filesystems]] mountpoint = "/app" type = "xfs" minsize = "1 GiB" label = "app" # Add the LVM configuration: # Define the LVM Volume Group name and size [[customizations.partitioning.lvm.volume_groups]] name = "centosvg" minsize = 10737418240 # 10 GiB # Add a data Logical Volume to the group [[customizations.partitioning.lvm.volume_groups.logical_volumes]] name = "datalv" mountpoint = "/var/data" label = "data" minsize = "1 GiB" type = "xfs" # The root Logical Volume is created automatically if not defined, but setting # it lets us set the name, label, and size explicitly [[customizations.partitioning.lvm.volume_groups.logical_volumes]] name = "rootlv" mountpoint = "/" label = "system" minsize = "2 GiB" type = "ext4" # Add an app Logical Volume with a top-level mountpoint. # Requires derived container. [[customizations.partitioning.lvm.volume_groups.logical_volumes]] mountpoint = "/app" type = "xfs" minsize = "1 GiB" label = "app" name = "applv"
Copy to Clipboard Copied!
bootc-image-builder
を実行します。必要に応じて、ユーザーアクセス設定を使用する場合は、config.toml
を引数として渡します。以下は、パブリック QCOW2 イメージを作成する例です。sudo podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v ./config.toml:/config.toml:ro \ -v ./output:/output \ registry.redhat.io/rhel9/bootc-image-builder:latest \ --type qcow2 \ --config /config.toml \ quay.io/<namespace>/<image>:<tag>
sudo podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v ./config.toml:/config.toml:ro \ -v ./output:/output \ registry.redhat.io/rhel9/bootc-image-builder:latest \ --type qcow2 \ --config /config.toml \ quay.io/<namespace>/<image>:<tag>
Copy to Clipboard Copied!
.qcow2
イメージは出力フォルダーにあります。
検証
作成された QCOW2 ファイルを仮想マシンで実行します。
qemu-system-x86_64 \ -enable-kvm \ -cpu host \ -m 8G \ -bios /usr/share/edk2/ovmf/OVMF_CODE.fd \ -snapshot \ -drive file="${path}/output/qcow2/disk.qcow2"
qemu-system-x86_64 \ -enable-kvm \ -cpu host \ -m 8G \ -bios /usr/share/edk2/ovmf/OVMF_CODE.fd \ -snapshot \ -drive file="${path}/output/qcow2/disk.qcow2"
Copy to Clipboard Copied! SSH で起動した仮想マシンのシステムにアクセスします。
ssh -i /<path_to_private_ssh-key> <user1>@<ip-address>
# ssh -i /<path_to_private_ssh-key> <user1>@<ip-address>
Copy to Clipboard Copied!
次のステップ
- イメージをデプロイできます。QCOW2 ディスクイメージを使用した KVM でのコンテナーイメージのデプロイ を参照してください。
- イメージを更新し、変更をレジストリーにプッシュできます。RHEL bootc イメージの管理 を参照してください。