PXE 中的pxelinux.cfg中的default文件
#cat default
default menu.c32
prompt 0
timeout 60
ONTIMEOUT local
MENU TITLE Main Menu
LABEL local
MENU LABEL Boot local hard drive
LOCALBOOT 0
LABEL CentOS Linux
MENU LABEL CentOS Linux
KERNEL menu.c32
APPPEND pxelinux.cgf/centos_menu
LABEL Debian Linux
MENU LABEL Debian Linux
KERNEL menu.c32
APPEND pxelinux.cfg/debian_menu
LABEL Window Setup
MENU LABEL Window Setup
KERNEL menu.c32
APPEND pxelinux.cfg/window_menu
centos_menu 配置
#cat centos_menu
LABEL CentOS7
MENU LABEL CentOS 7 install
KERNEL centos7/vmlinuz
APPEND initrd=centos7/initrd.img ks=http://192.168.2.254/ks7.cfg ksdevice=bootif console=tty0 console=ttyS0,115200
LABEL CentOS6
MENU LABEL CentOS 6 install
KERNEL centos7/vmlinuz
APPEND initrd=centos6/initrd.img ks=http://192.168.2.254/ks6.cfg ksdevice=bootif console=tty0 console=ttyS0,115200
LABEL rescue
MENU LABEL CentOS rescue mode
KERNEL centos7/vmlinuz
APPEND initrd=centos7/initrd.img ks=http://192.168.2.254/ks.cfg ksdevice=bootif console=tty0 console=ttyS0,115200
ks.cfg 文件
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
#Install OS instead of upgrade
install
#Keyboard layouts
keyboard 'us'
#Root password
rootpw --iscrypted $1$becav3Xl$q1lGfdGZwDyQ2AzTIHYvB/
#Use network installation
url --url="http://192.168.122.6/var/www/html/RHEL"
#System language
lang zh_CN
#System authorization information
auth --useshadow --passalgo=sha512
#Use graphical install
graphical
firstboot --disable
#SELinux configuration
selinux --disabled
#Firewall configuration
firewall --disabled
#Network information
network --bootproto=dhcp --device=eth0
#Reboot after installation
reboot
#System timezone
timezone Asia/Shanghai
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part / --fstype="ext4" --grow --size=1
part /boot --fstype="xfs" --grow --size=1
part /home --fstype="ext4" --grow --size=1
part /tmp --fstype="xfs" --grow --size=1
part swap --fstype="swap" --size=1024
%packages --nobase
@Core --nodefaults
-iwl3160-firmware
-iwl6000g2b-firmware
-iwl2030-firmware
-alsa-tools-firmware
-aic94xx-firmware
-postfixe
-audit
-tuned
chrony
psmisc
net-tools
screen
vim-enhanced
tcpdump
lrzsz
ltrace
strace
traceroute
whois
bind-utils
tree
mlocate
rsync
lsof
lftp
patch
diffutils
cpio
time
nmap
socat
man-pages
rpm-build
createrepo
%end
%pre
%end
%post --interpreter=/bin/bash
useradd lisi
echo 123 | passwd --stdin lisi
rm -f /etc/yum.repos.d/*.repo
cat >/etc/yum.repos.d/local.repo << 'EOF'
[local_repo]
name=centos
baseurl=http://192.168.2.254/RHEL
enabled=1
gpgcheck=1
EOF
rpm -import http://192.168.2.254/RHEL/RPM-GPG-KEY-CentOS-7
yum erase -y NetworkManager NetworkManager-libnm kexec-tools firewalld-filesystem polkit
sed 's/^CRONDARGS=.*/&" -m off "/ -i /etc/sysconfig/crond
sed 's/^\(OPTIONS=\).*/\1"-4"/' -i /etc/sysconfig/chronyd
sed 's/^server .*,&\ncmdallow 127.0.0.1/' -i /etc/chrony.conf
sed 's/^#\(terminfo xterm \x27is.*\)/\1\nterm xterm/' -i /etc/screenrc
cat >>/etc/sysconfig/network <<'EOF'
IPV6INIT="no"
NETWORING="yes"
NOZEROCONF="yes"
EOF
echo -e "# ::1\t\tlocalhost localhost.localdomian localhost6 localhost6.localdomain6" >/etc/hosts
echo -e "127.0.0.1\tlocalhost localhost.localdomain localhost4 localhost4.localdomain4" >>/etc/hosts
echo -e 'export TZ='Asia/Shanghai' PYTHONSTARTUP="/usr/lib64/python2.7/pystartup.py" tmout=7200' >/etc/profile.d/environ.sh
echo -e "blacklist acpi_pad\nblacklist power_meter" >/etc/modprobe.d/blacklist.conf
cat >/usr/lib64/python2.7/pystartup.py <<'EOF'
#!/usr/bin/python
#-*- coding:utf_8 -*-
#from_future_import print_function
from rlcompleter import readline
readline.parse_and_bind("tab:Complete")
EOF
cat >/etc/sysctl.d/70-system.conf <<'EOF'
net.ipv4.ip_forward = 1
net.ipv4.ip_default_ttl = 255
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce =2
kernel.sysrq = 16
vm.swappiness = 0
EOF
#config vimrc
cat >> /etc/vimrc <<'EOF'
set wrapscan
set noautoindent
set showmatch
set binary
set noswapfile
set ignorecase "Do case insensitive matching"
set foldmethod=syntax
set foldevel=100
filetype plugin off
EOF
sed -e 's/^#\(Port\).*/\1 10022/'
-e 's/^#\(ListenAddress 0.0.0.0\)/ \1/' \
-e 's/^#\(PermitRootLogin\).*/\1 yes/' \
-e 's/^#\(MaxAuthTries\).*/\1 3/' \
-e 's/^#\(UseDNS\).*/\1 no/' -i /etc/ssh/sshd_config
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<'EOF'
#Generated by dracut initrd
DEVICE="eth0"
ONBOOT="yes"
IPV6INIT="no"
IPV4_FAILURE_FATAL="no"
TYPE="Ethernet"
BOOTPROTO="dhcp"
EOF
%end