仮想化 · 3 min read · Jan 19, 2026
KVMのための仮想RedHat/CentOS/Scientific Linux/Fedoraアプライアンスの作成 (Fedora 17)
KVMのための仮想RedHat/CentOS/Scientific Linux/Fedoraアプライアンスの作成 (Fedora 17)
Version 1.0
Author: Falko Timme
Follow me on Twitter
BoxGrinderは、複数の仮想化技術のためにRedHat、CentOS、Scientific Linux、またはFedoraをOSとして使用する仮想マシンを構築するためのツールです。現在、KVM、VMware、Amazon EC2、VirtualBox、VirtualPCをサポートしています。このチュートリアルでは、BoxGrinderを使用してFedora 17上にCentOS 6 KVMゲストを作成し、それをリモートKVMホストにデプロイする方法を示します。
私はこれがあなたにとって機能するという保証はしません!
1 予備ノート
現在、BoxGrinderはFedora 17用のパッケージとして利用可能ですが、RedHat/CentOS/Scientific Linux 6用は利用できません。したがって、Fedora 17システムを使用して、ローカルで実行できるCentOS KVMゲストを作成します(Fedora 17をKVMプラットフォームとして使用する場合)またはリモートKVMホストに転送します(イメージファイルとゲストのXML定義ファイルをリモートホストに手動で転送することもできますが、BoxGrinderにはこれを自動的に行うための組み込み機能もあります)。
2 BoxGrinderのインストール
Fedoraシステムにrootユーザーとしてログインし、次のコマンドを実行します:
yum install rubygem-boxgrinder-build3 BoxGrinderの使用
BoxGrinderのプラグインとサポートされているゲストオペレーティングシステムについては、次のコマンドを実行して確認できます:
boxgrinder-build --version[root@localhost ~]# boxgrinder-build --version
BoxGrinder Build 0.10.4
Available os plugins:
- rhel plugin for Red Hat Enterprise Linux
- centos plugin for CentOS
- fedora plugin for Fedora
- sl plugin for Scientific Linux
Available platform plugins:
- vmware plugin for VMware
- ec2 plugin for Amazon Elastic Compute Cloud (Amazon EC2)
- virtualbox plugin for VirtualBox
- virtualpc plugin for VirtualPC
Available delivery plugins:
- s3 plugin for Amazon Simple Storage Service (Amazon S3)
- cloudfront plugin for Amazon Simple Storage Service (Amazon S3)
- ami plugin for Amazon Simple Storage Service (Amazon S3)
- sftp plugin for SSH File Transfer Protocol
- ebs plugin for Elastic Block Storage
- local plugin for Local file system
- elastichosts plugin for ElasticHosts
- openstack plugin for OpenStack
- libvirt plugin for libvirt Virtualisation API
[root@localhost ~]#KVMはデフォルトでサポートされているため、プラグインとしてはリストされていません。
BoxGrinderの使い方を学ぶには、次のコマンドを入力します:
boxgrinder-build -h[root@localhost ~]# boxgrinder-build -h
Usage: boxgrinder-build [appliance definition file] [options]
A tool for building VM images from simple definition files.
Homepage:
http://boxgrinder.org/
Documentation:
http://boxgrinder.org/tutorials/
Examples:
$ boxgrinder-build jeos.appl # Build KVM image for jeos.appl
$ boxgrinder-build jeos.appl -f # Build KVM image for jeos.appl with removing previous build for this image
$ boxgrinder-build jeos.appl --os-config format:qcow2 # Build KVM image for jeos.appl with a qcow2 disk
$ boxgrinder-build jeos.appl -p vmware --platform-config type:personal,thin_disk:true # Build VMware image for VMware Server, Player, Fusion using thin (growing) disk
$ boxgrinder-build jeos.appl -p ec2 -d ami # Build and register AMI for jeos.appl
$ boxgrinder-build jeos.appl -p vmware -d local # Build VMware image for jeos.appl and deliver it to local directory
Options:
-p, --platform [TYPE] The name of platform you want to convert to.
-d, --delivery [METHOD] The delivery method for selected appliance.
-f, --force Force image creation - removes all previous builds for selected appliance. Default: false.
Plugin configuration options:
-l, --plugins [PLUGINS] Comma separated list of additional plugins. Default: empty.
--os-config [CONFIG] Operating system plugin configuration in format: key1:value1,key2:value2.
--platform-config [CONFIG] Platform plugin configuration in format: key1:value1,key2:value2.
--delivery-config [CONFIG] Delivery plugin configuration in format: key1:value1,key2:value2.
Logging options:
--debug Prints debug information while building. Default: false.
--trace Prints trace information while building. Default: false.
-b, --backtrace Prints full backtrace if errors occur whilst building. Default: true if console log is set to debug or trace, otherwise false.
Common options:
--change-to-user Change from root to local user after the OS plugin completes.
--help Show this message.
--version Print the version.
[root@localhost ~]#基本的に、次のように動作します:アプライアンス定義ファイル(例:centos.appl)をディレクトリ(例:/usr/local/appliances)に作成します:
mkdir /usr/local/appliances
cd /usr/local/appliances/
vi centos.applこのアプライアンス定義ファイルは、KVMアプライアンス(名前、オペレーティングシステム(現在はRedHat、CentOS、Scientific Linux、Fedoraがサポートされています)、ルートパスワード、CPUの数、RAM、パーティション(数字はGB単位のサイズを意味します)、およびBoxGrinderが仮想マシンを作成する際に自動的にインストールするパッケージ)を説明します:
| name: centos-6-lamp summary: CentOS 6 LAMP version: 1 release: 0 os: name: centos version: 6 password: secret hardware: cpus: 2 memory: 1024 partitions: "/": size: 4 "/var": size: 10 "swap": size: 0.5 packages: - @core - @web-server - @mysql - acpid default_repos: true # default is true |
@で始まるパッケージは単一のパッケージではなく、パッケージグループです。アプライアンスで使用したいオペレーティングシステムと同じオペレーティングシステムを実行しているシステムで次のコマンドを実行することで、利用可能なパッケージグループを確認できます。
yum grouplist -vパッケージグループの名前は括弧内にあります。
@記号で始まらないパッケージはパッケージグループではなく、正確にその単一のパッケージです。
BoxGrinderは常にオペレーティングシステムの最新の利用可能なバージョンをインストールします。つまり、CentOS 6を指定すると、これは6.3をインストールすることを意味します(6.3はこの記事執筆時点での最新のCentOSバージョンです)。
次のようにBoxGrinderを呼び出すことができます(centos.applがある同じディレクトリにいることを確認してください):
boxgrinder-build centos.applデフォルトでは、BoxGrinderは生のイメージを作成します。ビルド後、イメージとXML定義はディレクトリbuild/appliances/
ls -l build/appliances/i686/centos/6/centos-6-lamp/1.0/centos-plugin/[root@localhost appliances]# ls -l build/appliances/i686/centos/6/centos-6-lamp/1.0/centos-plugin/
total 863308
-rwxr-xr-x. 1 root root 15569256448 Oct 5 11:44 centos-6-lamp-sda.raw
-rw-r--r--. 1 root root 475 Oct 5 11:42 centos-6-lamp.xml
[root@localhost appliances]#qcow2形式のアプライアンスを作成するには、次のようにします:
boxgrinder-build centos.appl --os-config format:qcow2代わりに:
ls -l build/appliances/i686/centos/6/centos-6-lamp/1.0/centos-plugin/[root@localhost appliances]# ls -l build/appliances/i686/centos/6/centos-6-lamp/1.0/centos-plugin/
total 1628824
-rw-r--r--. 1 root root 784007168 Oct 5 11:52 centos-6-lamp-sda.qcow2
-rw-r--r--. 1 root root 481 Oct 5 11:51 centos-6-lamp.xml
[root@localhost appliances]#これで、イメージをKVMホストの/var/lib/libvirt/imagesにコピーし、XMLファイルをKVMホストの/etc/libvirt/qemu/にコピーし、virshを開いてXMLファイルから新しい仮想マシンを定義できますが、これを手動で行う代わりに、BoxGrinderにこれを行わせることができます(-dスイッチを使用):
たとえば、アプライアンスをローカルKVMインストールに追加したい場合は、次のように実行します:
boxgrinder-build centos.appl --os-config format:qcow2 -d libvirtこれにより、イメージが直接/var/lib/libvirt/imagesディレクトリにコピーされます…
ls -l /var/lib/libvirt/images[root@localhost appliances]# ls -l /var/lib/libvirt/images
total 765636
-rw-r--r--. 1 root root 784007168 Oct 5 11:55 centos-6-lamp-sda.qcow2
[root@localhost appliances]#…およびXMLファイルが/etc/libvirt/qemu/ディレクトリにコピーされます:
ls -l /etc/libvirt/qemu/[root@localhost appliances]# ls -l /etc/libvirt/qemu/
total 8
-rw-------. 1 root root 2135 Oct 5 11:55 centos-6-lamp-1-0-centos-6-i686-raw.xml
drwx------. 3 root root 4096 Jun 28 15:52 networks
[root@localhost appliances]#新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。