lost and found ( for me ? )

KVM : Create CentOS7 VM with zero touch by using virt-install and kickstart

Here are logs when I built a CentOS7 VM with zero touch by using virt-install and kickstart file.

KVM host
$ tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"

$ virt-install --version
1.3.2

Download ISO and prepare kickstart file.

ISO
CentOS-7-x86_64-Minimal-1611.iso

kickstart file
$ cat cent7.ks
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Use text mode install
text
# Firewall configuration
firewall --disabled
firstboot --disable
ignoredisk --only-use=vda
# Keyboard layouts
# old format: keyboard jp106
# new format:
keyboard --vckeymap=jp106 --xlayouts='jp'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=eth0 --hostname=localhost --noipv6
# Reboot after installation
reboot
# Root password
rootpw --plaintext password
# SELinux configuration
selinux --disabled
# System services
services --enabled="chronyd"
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Tokyo --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet crashkernel=auto" --location=mbr --boot-drive=vda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
part / --fstype=ext4 --grow --asprimary --size=1

%packages --nobase --ignoremissing
@core
chrony
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

install
$ sudo virt-install  -n cent7-01 --memory 2048 -f /var/lib/libvirt/images/cent7-01.qcow2,size=20,format=qcow2,bus=virtio,cache=none --vcpus=1 --os-type linux --os-variant centos7.0 --location /home/hattori/ISO_images/CentOS-7-x86_64-Minimal-1611.iso --extra-args='ks=file:/cent7.ks console=tty0 console=ttyS0,115200n8' --keymap ja --initrd-inject ./cent7.ks --network=default,model=virtio --noautoconsole

connect to the VM to see progress.
$ virsh console cent7-01
Starting install...
Retrieving file .treeinfo...                                                                        |  366 B  00:00:00
Retrieving file vmlinuz...                                                                          | 5.1 MB  00:00:00
Retrieving file initrd.img...                                                                       |  41 MB  00:00:00
<snip>
Progress
Setting up the installation environment
.
Creating disklabel on /dev/vda
.
Creating ext4 on /dev/vda1
.
Running pre-installation scripts
.
Starting package installation process
Preparing transaction from installation source
Installing libgcc (1/297)
Installing centos-release (2/297)
Installing setup (3/297)
<snip>
[  OK  ] Stopped LVM2 metadata daemon.
[  OK  ] Started Restore /run/initramfs.
[  OK  ] Reached target Shutdown.
dracut Warning: Killing all remaining processes
Rebooting.
[  194.849928] Restarting system.

get things done.
$ virsh list --all
Id    Name                           State
----------------------------------------------------
-     cent7-01                       shut off

$ virsh start cent7-01

$ virsh console cnet7-01
localhost login: root
Password:
[root@localhost ~]#

No comments:

Post a Comment

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