secoug 发表于 2019-8-22 21:51:10

课程第20次

完整的kickstart文件:
主节:
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
url --url="http://192.168.0.254/pub/rhel7/dvd/"
# Use CDROM installation media
# Use graphical install
text
# Run the Setup Agent on first boot
firstboot --disable
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information
network--bootproto=dhcp

# Root password
rootpw --plaintext redhat123
# System services
services --enabled="chronyd,sshd"
# System timezone
timezone Asia/Shanghai --isUtc
# X Window System configuration information
xconfig--startxonboot
# System bootloader configuration
# Partition clearing information
# Disk partitioning information
%include /tmp/disk.txt
包节:
%packages
@^web-server-environment
%end
后节:
%post
KS_IPADDR=$(ifconfig | head -n 2 | tail -n 1 | cut -c 14- | cut -d ' ' -f 1)
KS_IPADDR_SHORT=$(ifconfig | head -n 2 | tail -n 1 | cut -c 14- | cut -d ' ' -f 1 | cut -d '.' -f 4)
KS_DEVICE=$( ls /etc/sysconfig/network-scripts/ifcf* | grep -v ifcfg-lo | cut -d '/' -f 5)
KS_DEVICE_SHORT=$( ls /etc/sysconfig/network-scripts/ifcf* | grep -v ifcfg-lo | cut -d '/' -f 5 | cut -d '-' -f 2)
cat > /etc/sysconfig/network-scripts/$KS_DEVICE <<EOF
DEVICE=$KS_DEVICE_SHORT
IPADDR=$KS_IPADDR
NETMASK=255.255.255.0
GATEWAY=192.168.0.254
EOF
echo "station$KS_IPADDR_SHORT.example.com" >/etc/hostname
echo "$KS_IPADDRstation$KS_IPADDR_SHORT.example.comstation$KS_IPADDR_SHORT" >> /etc/hosts
%end
前节:
%pre
DISKTYPE=$(cut -c 26-/proc/partitions   |head -n 3 | tail -n 1)
# Partition clearing information
# Disk partitioning information
cat <<EOF >/tmp/disk.txt

ignoredisk --only-use=$DISKTYPE

bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=$DISKTYPE

clearpart --none--initlabel
part swap --fstype="swap"--ondisk=$DISKTYPE --size=1024
part pv.350 --fstype="lvmpv" --ondisk=$DISKTYPE --size=18579
part /boot --fstype="xfs" --ondisk=$DISKTYPE --size=300
volgroup rhel --pesize=4096 pv.350
logvol /--fstype="xfs" --size=17576 --name=root --vgname=rhel
EOF

%end
                     








页: [1]
查看完整版本: 课程第20次