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 がインストールされている。

手順

  1. 以下の内容で config.tom ファイルを作成します。

    1. ユーザーをイメージに追加します。

      [[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
  2. 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>
    Copy to Clipboard

.qcow2 イメージは出力フォルダーにあります。

検証

  1. 作成された 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
  2. SSH で起動した仮想マシンのシステムにアクセスします。

    # ssh -i /<path_to_private_ssh-key> <user1>@<ip-address>
    Copy to Clipboard

次のステップ

トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat