lost and found ( for me ? )

Fedora 20: build a VM with virt-builder

Here are trial and error logs when building VMs for KVM by using virt-builder

reference
http://libguestfs.org/virt-builder.1.html

[root@f20 ~]# cat /etc/fedora-release
Fedora release 20 (Heisenbug)
[root@f20 ~]# uname -ri
3.13.0-0.rc8.git2.1.vanilla.mainline.knurd.1.fc20.x86_64 x86_64
[root@f20 ~]# qemu-system-x86_64 --version
QEMU emulator version 1.7.0, Copyright (c) 2003-2008 Fabrice Bellard

virt-builder includes libguest-tools.
# yum install libguestfs-tools

# libguestfs-test-tool --version
libguestfs-test-tool 1.24.4fedora=20,release=1.fc20,libvirt

list OSes you can build
# virt-builder --list
virt-builder: warning: cache /root/.cache/virt-builder: Unix.Unix_error(20, "mkdir", "/root/.cache/virt-builder")
virt-builder: disabling the cache
centos-6                 CentOS 6.5
cirros-0.3.1             CirrOS 0.3.1
debian-6                 Debian 6 (Squeeze)
debian-7                 Debian 7 (Wheezy)
fedora-18                Fedora® 18
fedora-19                Fedora® 19
fedora-20                Fedora® 20
scientificlinux-6        Scientific Linux 6.4
ubuntu-10.04             Ubuntu 10.04 (Lucid)
ubuntu-12.04             Ubuntu 12.04 (Precise)
ubuntu-13.10             Ubuntu 13.10 (Saucy)

build a Fedora20 VM
error.
# virt-builder fedora-20 --root-password file:./rootpw.txt -o f20-vm.qcow2 --format qcow2 --size 20G --hostname f20-vm.example.com --install "@core" --firstboot-command 'yum update -y' --firstboot-command 'localectl set-locale LANG=ja_JP.utf8' --firstboot-command 'set-keymap jp'
virt-builder: warning: cache /root/.cache/virt-builder: Unix.Unix_error(20, "mkdir", "/root/.cache/virt-builder")
virt-builder: disabling the cache
[   1.0] Downloading: http://libguestfs.org/download/builder/fedora-20.xz
#######################################################################  100.0%
[ 510.0] Planning how to build this image
[ 510.0] Uncompressing
[ 521.0] Resizing (using virt-resize) to expand the disk to 20.0G
Fatal error: exception Guestfs.Error("could not create appliance through libvirt.

Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct

Original error from libvirt: 内部エラー: モニターに接続中にプロセス

Configure LIBGUESTFS_BACKEND environment.
# export LIBGUESTFS_BACKEND=direct

# echo $LIBGUESTFS_BACKEND
direct

okay.
# virt-builder fedora-20 --root-password file:./rootpw.txt -o f20-vm.qcow2 --format qcow2 --size 20G --hostname f20-vm.example.com --install "@core" --firstboot-command 'yum update -y' --firstboot-command 'localectl set-locale LANG=ja_JP.utf8' --firstboot-command 'set-keymap jp'
virt-builder: warning: cache /root/.cache/virt-builder: Unix.Unix_error(20, "mkdir", "/root/.cache/virt-builder")
virt-builder: disabling the cache
[   1.0] Downloading: http://libguestfs.org/download/builder/fedora-20.xz
#######################################################################  100.0%
[ 518.0] Planning how to build this image
[ 518.0] Uncompressing
[ 529.0] Resizing (using virt-resize) to expand the disk to 20.0G
[ 561.0] Opening the new disk
[ 565.0] Setting a random seed
[ 565.0] Setting the hostname: f20-vm.example.com
[ 565.0] Setting root password
[ 565.0] Installing packages: @core
[ 624.0] Installing firstboot command: [1] yum update -y
[ 624.0] Installing firstboot command: [2] localectl set-locale LANG=ja_JP.utf8
[ 624.0] Installing firstboot command: [3] set-keymap jp
[ 624.0] Finishing off
Output: f20-vm.qcow2
Output size: 20.0G
Output format: qcow2
Total usable space: 19.0G
Free space: 18.1G (95%)

the VM image has been created under the directory where you issued virt-builder command.

# file f20-vm.qcow2
f20-vm.qcow2: QEMU QCOW Image (unknown version)

copy the original VM image to KVM pool ( in my case, /var/lib/libvit/images/disk1 )

# cp f20-vm.qcow2 /var/lib/libvirt/images/disk1/f20.qcow2

deploy the VM.
# yum install virt-install


# virt-install --import --name f20-vm1 --ram 512 --disk path=/var/lib/libvirt/images/disk1/f20-vm1.qcow2,format=qcow2,device=disk,bus=virtio,20G
ERROR    Error with storage parameters: Size must be specified for non existent volume path '/var/lib/libvirt/images/disk1/f20-vm1.qcow2'
[root@f20 Virtbuilder_works]# virt-install
ERROR    
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.11.10-301.fc20.x86_64 (mockbuild@bkernel01.phx2.fedoraproject.org) (gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) (GCC) ) #1 SMP Thu Dec 5 14:01:17 UTC 2013
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.11.10-301.fc2


when booting the VM for the  first time, execute “yum update” automatically.
[  112.857596] firstboot.sh[408]: Transaction test succeeded
[  112.859440] firstboot.sh[408]: Running transaction
[  114.431092] firstboot.sh[408]: Updating   : libselinux-2.2.1-6.fc20.x86_64                             1/129
[  115.127248] firstboot.sh[408]: Updating   : nspr-4.10.2-1.fc20.x86_64                                  2/129
[  115.797586] firstboot.sh[408]: Updating   : nss-util-3.15.3-1.fc20.x86_64                              3/129
[  116.429433] firstboot.sh[408]: Updating   : audit-libs-2.3.3-1.fc20.x86_64                             4/129

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.