lost and found ( for me ? )

Showing posts with label kickstart. Show all posts
Showing posts with label kickstart. Show all posts

KVM : install CentOS 6.9 VM with zero touch by using kickstart

KVM host
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"

$ kvm --version
QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.11), Copyright (c) 2003-2008 Fabrice Bellard

Here is a sample kickstart file for CentOS 6.9.
$ cat cent6.ks
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
cdrom
lang ja_JP.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw --plaintext password

firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Asia/Tokyo
bootloader --location=mbr --driveorder=vda --append="console=ttyS0,115200n8 crashkernel=auto console=ttyS0,115200n8"
# Clear the Master Boot Record
zerombr
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --initlabel


part / --fstype=ext4 --grow --asprimary --size=1

#repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100

%packages --nobase
@Core
@core

%end

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

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 ~]#

Ubuntu 14.04: automatic installation with kickstart file

Here is how to make an unattended installation ISO of Ubuntu 14.04 Server.

Reference
http://pricklytech.wordpress.com/2013/04/21/ubuntu-server-unattended-installation-custom-cd/

make automatic installation ISO

mount the ISO
# mount -o loop /home/hattori/ISO_files/ubuntu-14.04-server-amd64.iso /home/hattori/iso

copy files to /home/hattori/serveriso directory
# cp -rT /home/hattori/iso /home/hattori/serveriso

# chmod -R 777 /home/hattori/serveriso/

configure language ( in my case, use japanese )
first search supported language from langlist file and configure language you want to use
# cd /home/hattori/serveriso/isolinux/

# grep ^ja langlist
ja

# echo ja > langlist

# cat langlist
ja

install system-config-kickstart to make a kickstart file.
# apt-get install system-config-kickstart

start.
error.
# system-config-kickstart
Traceback (most recent call last):
 File "/usr/share/system-config-kickstart/system-config-kickstart.py", line 92, in <module>
   kickstartGui.kickstartGui(file)
 File "/usr/share/system-config-kickstart/kickstartGui.py", line 131, in __init__
   self.X_class = xconfig.xconfig(xml, self.kickstartData)
 File "/usr/share/system-config-kickstart/xconfig.py", line 80, in __init__
   self.fill_driver_list()
 File "/usr/share/system-config-kickstart/xconfig.py", line 115, in fill_driver_list
   raise RuntimeError, (_("Could not read video driver database"))
RuntimeError: ビデオドライバーのデータベースを読み込むことができませんでした

Googling this, this seems to be a bug.

follow the instructions.
# apt-get remove hwdata -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
 localechooser-data
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
 hwdata system-config-kickstart


# wget ftp://mirror.ovh.net/mirrors/ftp.debian.org/debian/pool/main/h/hwdata/hwdata_0.234-1_all.deb
# dpkg -i hwdata_0.234-1_all.deb
# apt-get install system-config-kickstart -y

start. Okay.

# system-config-kickstart


make a kickstart file with GUI

Here is the ks.cfg I made.
# grep -v ^# /home/hattori/ks.cfg

lang en_US
langsupport en_US
keyboard us
mouse
timezone America/New_York
rootpw --iscrypted $1$XQbTzRQH$bL76vvwsL6USTxmS7C4tz1
user hattori --fullname "hattori" --iscrypted --password $1$E/m3UF5k$iqR.lTy44xcWqHJI23M9s.
reboot
text
install
cdrom
bootloader --location=mbr
zerombr yes
clearpart --all --initlabel
part / --fstype ext4 --size 1 --grow
part swap --recommended
auth  --useshadow  --enablemd5
network --bootproto=dhcp --device=eth0
firewall --disabled --ssh
skipx

add following lines at the end of ks.cfg
%packages
nano
openssh-server

# grep -v ^# /home/hattori/ks.cfg

lang ja_JP
langsupport ja_JP
keyboard jp
mouse
timezone Asia/Tokyo
rootpw --iscrypted $1$WQ7m.az5$EAgrglOCZsH2vtRRO.I8e0
user hattori --fullname "hattori" --iscrypted --password $1$cWaRngQ0$VXnCiRAKUe4SvoihCVTtB.
reboot
text
install
cdrom
bootloader --location=mbr
zerombr yes
clearpart --all --initlabel
part / --fstype ext4 --size 1 --grow
part swap --recommended
auth  --useshadow  --enablemd5
network --bootproto=dhcp --device=eth0
firewall --disabled --ssh
skipx

%packages
nano
openssh-server

copy the ks file to the /home/hattori/serveriso
# cp /home/hattori/ks.cfg /home/hattori/serveriso/

# ls /home/hattori/serveriso/
EFI                 boot   doc      isolinux  md5sum.txt  pool     ubuntu
README.diskdefines  dists  install  ks.cfg    pics        preseed

edit txt.cfg
add “ks=cdrom:ks.cfg”
remove vga=788 and quiet --

before
# less /home/hattori/txt.cfg.org
default install
label install
 menu label ^Install Ubuntu Server
 kernel /install/vmlinuz
 append  file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet --

after editing
# pwd
/home/hattori/serveriso/isolinux

# cat txt.cfg
default install
label install
 menu label ^Install Ubuntu Server
 kernel /install/vmlinuz
 append  file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg

make an ISO
# cd /home/hattori/serveriso/


# mkisofs -D -r -V "auto install" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /home/hattori/ubuntu1404_auto.iso /home/hattori/serveriso

# file /home/hattori/ubuntu1404_auto.iso
/home/hattori/ubuntu1404_auto.iso: # ISO 9660 CD-ROM filesystem data 'auto install' (bootable)

install ubuntu by using this ISO.
I confirmed that the the installation succeeds within KVM.