CentOS 6: Automatisierte Installation mit Kickstart
Die Installation von CentOS 6 kann man mit einer Kickstart-Konfiguration automatisieren. Auf dieser Seite möchte ich eine Kickstart-Konfiguration vorstellen, welche bei der Netzwerkinstallation von CentOS 6 eingesetzt werden kann.
Die Kickstart-Konfigurationsdatei befindet sich in diesem Beispiel auf einem CentOS 6.4 System, welches auch einen CentOS 6.4 Mirror über FTP bereitstellt (siehe Shell Skript: CentOS 6.4 Mirror Script).
[root@centos6 ~]# vi /var/ftp/pub/linux/kickstart/centos6.cfg
Das folgende Listing zeigt eine Kickstart-Konfiguration, so wie ich sie bereits im Einsatz habe. Ich denke die Bedeutung der einzelnen Optionen gehen aus den Kommentaren hervor.
################################################################################
### Basic installation configuration ###
################################################################################
# Install OS.
install
# Upgrade OS instead of install.
#upgrade
# Perform installation in graphical mode.
#graphical
# Perform installation in text mode.
text
# Do not configure the X Window System.
skipx
################################################################################
### Localization ###
################################################################################
# Sets language.
lang de_DE.UTF8
################################################################################
### Keyboard ###
################################################################################
# Sets keyboard layout.
keyboard de
################################################################################
### Clock and time zone setup ###
################################################################################
# Controls whether or not the hardware clock is set to UTC and sets the timezone.
timezone --utc Europe/Berlin
################################################################################
### Network configuration ###
################################################################################
# Static IPv4 network configuration.
#network --onboot=yes --device=eth0 --bootproto=static --ip=192.168.10.100 --netmask=255.255.255.0 --gateway=192.168.10.2 --nameserver=192.168.10.1,192.168.10.2
# Dynamic network configuration.
network --onboot=yes --device=eth0 --bootproto=dhcp
# Dynamic network configuration with specified hostname.
#network --onboot=yes --device=eth0 --bootproto=dhcp --hostname=kickstart
################################################################################
### Mirror settings ###
################################################################################
# HTTP mirror configuration.
#url --url http://mirror.home.lan/pub/linux/centos/6/os/x86_64/
# FTP mirror configuration.
url --url ftp://mirror.home.lan/pub/linux/centos/6/os/x86_64/
# NFS mirror configuration.
#nfs --server=mirror.home.lan --dir=/data/nfs/pub/linux/centos/6/os/x86_64/
################################################################################
### Partitioning ###
################################################################################
# Remove all partitions and initialize the disk label to the default for your architecture.
clearpart --all --initlabel
# Remove all partitions on the specified drives.
#clearpart --all --drives=sda,sdb
# Remove all linux partitions on the specified drives.
#clearpart --linux --drives=sda,sdb
# Ignore all listed disks.
ignoredisk --drives=sdb,sdc,sdd,sde
# Create partitions.
part /boot --label=boot --fstype=ext3 --size=512 --asprimary
part / --label=root --fstype=ext4 --size=10240 --asprimary
part swap --size=1024 --asprimary
part /data --label=data --fstype=ext4 --size=1 --grow
# Create LVM.
#part /boot --label=boot --fstype=ext3 --size=512 --asprimary
#part pv.00 --size=1 --grow
#volgroup VolGroup00 pv.00 --pesize=32M
#logvol / --name=root --vgname=VolGroup00 --fstype=ext4 --size=10240
#logvol /data --name=data --vgname=VolGroup00 --fstype=ext4 --size=1 --grow
# Create RAID.
#part raid.00 --size=10240 --ondisk=sda
#part raid.01 --size=10240 --ondisk=sdb
#part raid.02 --size=10240 --ondisk=sdc
#part swap1 --size=1024 --ondisk=sda
#part swap2 --size=1024 --ondisk=sdb
#part swap3 --size=1024 --ondisk=sdc
#part raid.10 --size=1 --grow --ondisk=sda
#part raid.11 --size=1 --grow --ondisk=sdb
#part raid.12 --size=1 --grow --ondisk=sdc
#raid / --label=root --fstype=ext4 --level=1 --device=md0 raid.00 raid.01 raid.02
#raid /data --label=data --fstype=ext4 --level=5 --device=md1 raid.10 raid.11 raid.12
################################################################################
### Boot loader installation ###
################################################################################
# Clear the master boot record (MBR).
zerombr yes
# This one makes grub-installer install the boot loader to the MBR.
bootloader --location=mbr
# Alternatively, the grub-installer can install the boot loader on the first sector of the partition containing the kernel.
#bootloader --location=partition
# Do not install the boot loader.
#bootloader --location=none
# Installs GRUB to the MBR and sets boot menu timeout.
#bootloader --location=mbr --timeout=5
# Installs GRUB to the MBR and sets GRUB boot loader password to restrict access to the GRUB shell.
# GRUB password either in clear text
#bootloader --location=mbr --password=GrubPassword
# or encrypted using an MD5 hash.
#bootloader --location=mbr --md5pass=[MD5 hash]
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("GrubPassword", "$6$96Zt4Ph2"))'
#bootloader --location=mbr --md5pass=$6$96Zt4Ph2$wLEm/dbkXT5T6VL11hZZF/hhG3zH7/twcQEn5batiWddHtunxxyJKGgGOvJ/NxtWjZIL8mY/hZI2iKOPNqnrm0
################################################################################
### Account setup ###
################################################################################
# Sets system authorization infomations.
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
# Root password, either in clear text
#rootpw --plaintext RootPassword
# or encrypted using an MD5 hash.
#rootpw --iscrypted [MD5 hash]
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("RootPassword", "$6$96Zt4Ph2"))'
rootpw --iscrypted $6$96Zt4Ph2$LK9m6yIdXIZ4O4wci0AuuWChUyCkTLhPuWIqHQspZF4gcFnXWxEOKxkVhNWzxHhrt9BQw.GVy8rdaMgfDgnkd/
# To create a normal user account.
# Normal user's password, either in clear text
#user --name=georg --plaintext UserPassword
# or encrypted using an MD5 hash.
#user --name=georg --iscrypted --password [MD5 hash]
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("UserPassword", "$6$96Zt4Ph2"))'
user --name=georg --iscrypted --password $6$96Zt4Ph2$T5XxqLEvW6FrHi1Rq1LU/DQSOv5aJQK7DwOMPieX9wAWyevxCIDJCtMbteHGQx8cN6oF6mKggnlPh7KtF4YRP.
# To create a user account with no interactive shell.
# Normal user's password, either in clear text
#user --name=georg --plaintext password --shell=/sbin/nologin
# or encrypted using an MD5 hash.
#user --name=georg --iscrypted --password [MD5 hash] --shell=/sbin/nologin
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("UserPassword", "$6$96Zt4Ph2"))'
#user --name=georg --iscrypted --password $6$96Zt4Ph2$T5XxqLEvW6FrHi1Rq1LU/DQSOv5aJQK7DwOMPieX9wAWyevxCIDJCtMbteHGQx8cN6oF6mKggnlPh7KtF4YRP. --shell=/sbin/nologin
# To create a new user group.
# Create new user group with specified group id.
#group --name= --gid=
################################################################################
### Firewall configuration ###
################################################################################
# Disable firewall.
#firewall --disabled
# Enable firewall.
#firewall --enabled
# Enable firewall and allow all traffic coming from the specified device to
# go through the firewall.
#firewall --enabled --trust=eth0
# Enable firewall and allow the specified service.
firewall --enabled --service=ssh
# Enable firewall and allow the specified ports (port:protcol).
#firewall --enabled --port=ssh:tcp,1194:udp
################################################################################
### SELinux configuration ###
################################################################################
# Disable SELinux.
selinux --disabled
# Sets SELinux to enforcing mode.
#selinux --enforcing
# Sets SELinux to permissive mode.
#selinux --permissive
################################################################################
### Service configuration ###
################################################################################
# Disable the services given in the comma separated list.
#services --disable kdump
# Enable the services given in the comma separated list.
#services --enable ssh,ntpd
################################################################################
### Package selection ###
################################################################################
%packages
@base
@core
#@basic-desktop
#@desktop-platform
#@x11
#@fonts
openssh-clients
screen
wget
# Insert additional packages or groups here.
%end
################################################################################
### Post-installation script ###
################################################################################
%post --interpreter=/bin/bash --log=/root/postscript.log
# Insert your post-installation script here.
# Run post-installation script on console 3.
exec < /dev/tty3 > /dev/tty3
# Change to console 3.
chvt 3
# Download and execute the postscript
wget ftp://mirror.home.lan/pub/linux/kickstart/centos6_postscript.sh -O /root/postscript.sh
sh /root/postscript.sh
rm -f /root/postscript.sh
# Sets the default run level to 5 (X11).
#sed -i 's/id:3:initdefault:/id:5:initdefault:/g' /etc/inittab
# Change back to console 1.
chvt 1
%end
################################################################################
### Finalize installation ###
################################################################################
# Reboot the system after the installation is complete.
reboot
# Wait for the user to press a key before rebooting the system after the
# installation is complete.
#halt
# Shutdown the system after the installation is complete.
#shutdown
#Turn off the system after the installation is complete.
#poweroff
### Basic installation configuration ###
################################################################################
# Install OS.
install
# Upgrade OS instead of install.
#upgrade
# Perform installation in graphical mode.
#graphical
# Perform installation in text mode.
text
# Do not configure the X Window System.
skipx
################################################################################
### Localization ###
################################################################################
# Sets language.
lang de_DE.UTF8
################################################################################
### Keyboard ###
################################################################################
# Sets keyboard layout.
keyboard de
################################################################################
### Clock and time zone setup ###
################################################################################
# Controls whether or not the hardware clock is set to UTC and sets the timezone.
timezone --utc Europe/Berlin
################################################################################
### Network configuration ###
################################################################################
# Static IPv4 network configuration.
#network --onboot=yes --device=eth0 --bootproto=static --ip=192.168.10.100 --netmask=255.255.255.0 --gateway=192.168.10.2 --nameserver=192.168.10.1,192.168.10.2
# Dynamic network configuration.
network --onboot=yes --device=eth0 --bootproto=dhcp
# Dynamic network configuration with specified hostname.
#network --onboot=yes --device=eth0 --bootproto=dhcp --hostname=kickstart
################################################################################
### Mirror settings ###
################################################################################
# HTTP mirror configuration.
#url --url http://mirror.home.lan/pub/linux/centos/6/os/x86_64/
# FTP mirror configuration.
url --url ftp://mirror.home.lan/pub/linux/centos/6/os/x86_64/
# NFS mirror configuration.
#nfs --server=mirror.home.lan --dir=/data/nfs/pub/linux/centos/6/os/x86_64/
################################################################################
### Partitioning ###
################################################################################
# Remove all partitions and initialize the disk label to the default for your architecture.
clearpart --all --initlabel
# Remove all partitions on the specified drives.
#clearpart --all --drives=sda,sdb
# Remove all linux partitions on the specified drives.
#clearpart --linux --drives=sda,sdb
# Ignore all listed disks.
ignoredisk --drives=sdb,sdc,sdd,sde
# Create partitions.
part /boot --label=boot --fstype=ext3 --size=512 --asprimary
part / --label=root --fstype=ext4 --size=10240 --asprimary
part swap --size=1024 --asprimary
part /data --label=data --fstype=ext4 --size=1 --grow
# Create LVM.
#part /boot --label=boot --fstype=ext3 --size=512 --asprimary
#part pv.00 --size=1 --grow
#volgroup VolGroup00 pv.00 --pesize=32M
#logvol / --name=root --vgname=VolGroup00 --fstype=ext4 --size=10240
#logvol /data --name=data --vgname=VolGroup00 --fstype=ext4 --size=1 --grow
# Create RAID.
#part raid.00 --size=10240 --ondisk=sda
#part raid.01 --size=10240 --ondisk=sdb
#part raid.02 --size=10240 --ondisk=sdc
#part swap1 --size=1024 --ondisk=sda
#part swap2 --size=1024 --ondisk=sdb
#part swap3 --size=1024 --ondisk=sdc
#part raid.10 --size=1 --grow --ondisk=sda
#part raid.11 --size=1 --grow --ondisk=sdb
#part raid.12 --size=1 --grow --ondisk=sdc
#raid / --label=root --fstype=ext4 --level=1 --device=md0 raid.00 raid.01 raid.02
#raid /data --label=data --fstype=ext4 --level=5 --device=md1 raid.10 raid.11 raid.12
################################################################################
### Boot loader installation ###
################################################################################
# Clear the master boot record (MBR).
zerombr yes
# This one makes grub-installer install the boot loader to the MBR.
bootloader --location=mbr
# Alternatively, the grub-installer can install the boot loader on the first sector of the partition containing the kernel.
#bootloader --location=partition
# Do not install the boot loader.
#bootloader --location=none
# Installs GRUB to the MBR and sets boot menu timeout.
#bootloader --location=mbr --timeout=5
# Installs GRUB to the MBR and sets GRUB boot loader password to restrict access to the GRUB shell.
# GRUB password either in clear text
#bootloader --location=mbr --password=GrubPassword
# or encrypted using an MD5 hash.
#bootloader --location=mbr --md5pass=[MD5 hash]
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("GrubPassword", "$6$96Zt4Ph2"))'
#bootloader --location=mbr --md5pass=$6$96Zt4Ph2$wLEm/dbkXT5T6VL11hZZF/hhG3zH7/twcQEn5batiWddHtunxxyJKGgGOvJ/NxtWjZIL8mY/hZI2iKOPNqnrm0
################################################################################
### Account setup ###
################################################################################
# Sets system authorization infomations.
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
# Root password, either in clear text
#rootpw --plaintext RootPassword
# or encrypted using an MD5 hash.
#rootpw --iscrypted [MD5 hash]
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("RootPassword", "$6$96Zt4Ph2"))'
rootpw --iscrypted $6$96Zt4Ph2$LK9m6yIdXIZ4O4wci0AuuWChUyCkTLhPuWIqHQspZF4gcFnXWxEOKxkVhNWzxHhrt9BQw.GVy8rdaMgfDgnkd/
# To create a normal user account.
# Normal user's password, either in clear text
#user --name=georg --plaintext UserPassword
# or encrypted using an MD5 hash.
#user --name=georg --iscrypted --password [MD5 hash]
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("UserPassword", "$6$96Zt4Ph2"))'
user --name=georg --iscrypted --password $6$96Zt4Ph2$T5XxqLEvW6FrHi1Rq1LU/DQSOv5aJQK7DwOMPieX9wAWyevxCIDJCtMbteHGQx8cN6oF6mKggnlPh7KtF4YRP.
# To create a user account with no interactive shell.
# Normal user's password, either in clear text
#user --name=georg --plaintext password --shell=/sbin/nologin
# or encrypted using an MD5 hash.
#user --name=georg --iscrypted --password [MD5 hash] --shell=/sbin/nologin
# Generate MD5-hash: python -c 'import crypt; print(crypt.crypt("UserPassword", "$6$96Zt4Ph2"))'
#user --name=georg --iscrypted --password $6$96Zt4Ph2$T5XxqLEvW6FrHi1Rq1LU/DQSOv5aJQK7DwOMPieX9wAWyevxCIDJCtMbteHGQx8cN6oF6mKggnlPh7KtF4YRP. --shell=/sbin/nologin
# To create a new user group.
# Create new user group with specified group id.
#group --name= --gid=
################################################################################
### Firewall configuration ###
################################################################################
# Disable firewall.
#firewall --disabled
# Enable firewall.
#firewall --enabled
# Enable firewall and allow all traffic coming from the specified device to
# go through the firewall.
#firewall --enabled --trust=eth0
# Enable firewall and allow the specified service.
firewall --enabled --service=ssh
# Enable firewall and allow the specified ports (port:protcol).
#firewall --enabled --port=ssh:tcp,1194:udp
################################################################################
### SELinux configuration ###
################################################################################
# Disable SELinux.
selinux --disabled
# Sets SELinux to enforcing mode.
#selinux --enforcing
# Sets SELinux to permissive mode.
#selinux --permissive
################################################################################
### Service configuration ###
################################################################################
# Disable the services given in the comma separated list.
#services --disable kdump
# Enable the services given in the comma separated list.
#services --enable ssh,ntpd
################################################################################
### Package selection ###
################################################################################
%packages
@base
@core
#@basic-desktop
#@desktop-platform
#@x11
#@fonts
openssh-clients
screen
wget
# Insert additional packages or groups here.
%end
################################################################################
### Post-installation script ###
################################################################################
%post --interpreter=/bin/bash --log=/root/postscript.log
# Insert your post-installation script here.
# Run post-installation script on console 3.
exec < /dev/tty3 > /dev/tty3
# Change to console 3.
chvt 3
# Download and execute the postscript
wget ftp://mirror.home.lan/pub/linux/kickstart/centos6_postscript.sh -O /root/postscript.sh
sh /root/postscript.sh
rm -f /root/postscript.sh
# Sets the default run level to 5 (X11).
#sed -i 's/id:3:initdefault:/id:5:initdefault:/g' /etc/inittab
# Change back to console 1.
chvt 1
%end
################################################################################
### Finalize installation ###
################################################################################
# Reboot the system after the installation is complete.
reboot
# Wait for the user to press a key before rebooting the system after the
# installation is complete.
#halt
# Shutdown the system after the installation is complete.
#shutdown
#Turn off the system after the installation is complete.
#poweroff
Damit die automatische Installation direkt aus dem PXE-Bootmenü gestartet werden kann, werden in der PXE-Konfigurationsdatei noch entsprechende Einträge erstellt. Beachten Sie hierzu auch CentOS 6: Installation via PXE starten.
Öffnen Sie die Konfigurationsdatei mit dem folgenden Befehl.
[root@centos6 ~]# vi /tftpboot/pxelinux.cfg/default
Das folgende Listing zeigt zwei Booteinträge für die 32- und 64-Bit Version von CentOS 6.4. Durch den Parameter ks wird der Pfad zur Kickstart-Konfiguration angegegben, Die Netzwerkschnittstelle. über welche die Installation ablaufen soll, geben Sie mit dem Parameter ksdevice an.
label centos6_i386_ks
menu label CentOS 6.4 i386 Kickstart
kernel /centos6/i386/vmlinuz
append initrd=/centos6/i386/initrd.img devfs=nomount ramdisk_size=9216 ks=ftp://mirror.home.lan/pub/linux/kickstart/centos6.cfg ksdevice=eth0
label centos6_x86_64_ks
menu label CentOS 6.4 x86_64 Kickstart
kernel /centos6/x86_64/vmlinuz
append initrd=/centos6/x86_64/initrd.img devfs=nomount ramdisk_size=9216 ks=ftp://mirror.home.lan/pub/linux/kickstart/centos6.cfg ksdevice=eth0
menu label CentOS 6.4 i386 Kickstart
kernel /centos6/i386/vmlinuz
append initrd=/centos6/i386/initrd.img devfs=nomount ramdisk_size=9216 ks=ftp://mirror.home.lan/pub/linux/kickstart/centos6.cfg ksdevice=eth0
label centos6_x86_64_ks
menu label CentOS 6.4 x86_64 Kickstart
kernel /centos6/x86_64/vmlinuz
append initrd=/centos6/x86_64/initrd.img devfs=nomount ramdisk_size=9216 ks=ftp://mirror.home.lan/pub/linux/kickstart/centos6.cfg ksdevice=eth0
Dieser Eintrag wurde am 27.07.2013 erstellt und zuletzt am 24.01.2016 bearbeitet.
Direkter Link zu dieser Seite: http://www.gtkdb.de/index_33_2266.html
[ Zur Startseite ] [ Zur Kategorie ]
© 2004-2021 by Georg Kainzbauer