virt-install
我最近设法在我的 Archlinux 上使用 kickstart.cfg 文件安装了 Centos7 。
但是,如果我只是想对 Centos 8 使用类似的方法 - 它根本不起作用。我怀疑这是因为 Centos8 没有任何最小版本,您需要使用图形安装程序下载 7GB iso 文件。
sudo virt-install --name k8s-1 \
--description "this is my Centos 8 " \
--ram 2048 \
--vcpus 2 \
--disk path=/vm-disks/k8s-1.qcow2,size=15 \
--os-type linux \
--os-variant "centos8" \
--network bridge=virbr0 \
--graphics vnc,listen=127.0.0.1,port=5901 \
--location /cdimages/CentOS-8.1.1911-x86_64-dvd1.iso \
--noautoconsole \
--initrd-inject ks-1.cfg --extra-args="ks=file:/ks-1.cfg"
Setting input-charset to 'UTF-8' from locale.
Starting install...
Setting input-charset to 'UTF-8' from locale.
Retrieving file vmlinuz... | 7.7 MB 00:00:00
Setting input-charset to 'UTF-8' from locale.
Retrieving file initrd.img... | 59 MB 00:00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
这是 ks-1.cfg
# Install OS instead of upgrade
install
# Use network installation
cdrom
# Root password
rootpw Start123
# System authorization information
auth --useshadow --passalgo=sha512
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --permissive
# Installation logging level
logging --level=info
# Use text mode install
text
# Do not configure the X Window System
skipx
# System timezone, language and keyboard
timezone --utc Europe/Bratislava
lang en_US.UTF-8
# keyboard dk-latin1
# Network information
# network --bootproto=static --ip=192.168.122.110 --device=eth0 --onboot=on
# If you want to configure a static IP:
network --device eth0 --hostname k8s-1 --bootproto=static --ip=192.168.122.111 --netmask=255.255.255.0 --gateway=192.168.122.1 --nameserver 192.168.122.1
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=512
#part swap --fstype="swap" --recommended
part /var --fstype="ext4" --size=5120 --grow
part / --fstype="ext4" --size=1024 --grow
part /usr --fstype="ext4" --size=3072
part /home --fstype="ext4" --size=512
part /tmp --fstype="ext4" --size=1024
# Reboot after installation
reboot
%packages --nobase
@core
# @base
%end
%post --log=/root/ks-post.log
#---- Install packages used by kubernetes
#yum install -y socat libseccomp-devel btrfs-progs-devel util-linux nfs-utils conntrack-tools.x86_64
#---- Set bridge-nf-call
echo "net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1" > /etc/sysctl.conf
#---- Add user RKE -----
groupadd docker
adduser rke
echo "rke:praqma" | chpasswd
usermod -aG docker rke
#---- Install our SSH key ----
mkdir -m0700 /home/rke/.ssh/
cat <<EOF >/home/rke/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9F5hTts3U+E10PHRxViM3PX+DZPgBIcL7Uj/Py+udJWehhobnJmj2EoaUYbykm7VdpjImLpjas2Vhb/gNZ+wVWGho1mzWoCPl2fZ7oLXrGdDHXhlyocvfX3XPB6Y1kbFlfh7+4bUaA7w2Dg4x8LO/iXlF34z6IOa2xgx1R70Xc/97lkRMhsKszRBzwGVin6qUqdVmdXg3d0dRUnq039+q8NWUcKAz2w6F/HO7u3N7NhsSLnlpQ9+AztLvHEPeRP6UNex9a8sSHo5Jzc/mjVKGfInfWjp3nru88mwM4UQRbhhW5IeLXgALCa++H4qZw1ivZtVadXBHjK4JMKC1UWD1 rancher@k8s
EOF
### Disabling swap (now and permently)
swapoff -a
sed -i '/^\/swapfile/ d' /etc/fstab
### set permissions
chmod 0600 /home/rke/.ssh/authorized_keys
chown -R rke:rke /home/rke/.ssh
### fix up selinux context
restorecon -R /home/rke/.ssh/authorized_keys
### Install Docker
#yum install docker -y
#systemctl enable docker
%end