RHEL7下PXE+Apache+Kickstart無人值守安裝操作系統 1.配置yum源 vim /etc/yum.repos.d/development.repo [development] name=yum server baseurl=file:///mnt enabled=1 gpgche ...
RHEL7下PXE+Apache+Kickstart無人值守安裝操作系統
1.配置yum源
vim /etc/yum.repos.d/development.repo
[development] name=yum server baseurl=file:///mnt enabled=1 gpgcheck=0 2.掛載光碟 mount /dev/sr0 /mnt 3.安裝相關軟體包 yum install dhcp syslinux xinetd tftp-server 4.配置dhcp vim /etc/dhcp/dhcpd.conf 5.添加內容 subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.121 192.168.1.200; //ip地址池 option domain-name-servers 192.168.1.1; //網關地址 option domain-name "internal.example.org"; option routers 192.168.1.1; //網關地址 option broadcast-address 192.168.1.255; next-server 192.168.1.32; //Apache伺服器地址 filename "pxelinux.0"; default-lease-time 600; max-lease-time 7200; } 6.啟動服務和開機自啟動 systemctl start dhcpd.servicesystemctl enable dhcpd.service 7.複製啟動文件 cd /var/lib/tftpboot/ #進入/var/lib/tftpboot/
cp /mnt/isolinux/initrd.img /var/lib/tftpboot #複製initrd.img到/var/lib/tftpboot目錄下
cp /mnt/isolinux/vmlinuz /var/lib/tftpboot/ #複製vmlinuz到/var/lib/tftpboot目錄下
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ #複製pxelinux.0到/var/lib/tftpboot目錄下
cp /mnt/isolinux/vesamenu.c32 /var/lib/tftpboot/ #複製vesamenu.c32到/var/lib/tftpboot目錄下
cp /mnt/isolinux/boot.msg /var/lib/tftpboot/ #複製boot.msg到/var/lib/tftpboot目錄下
cd /var/lib/tftpboot/ #進入/var/lib/tftpboot目錄下
mkdir pxelinux.cfg #在/var/lib/tftpboot目錄下創建pxelinux.cfg目錄
cd pxelinux.cfg/ #進入pxelinux.cfg目錄下
cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default #複製isolinux.cfg到pxelinux.cfg目錄下並命名為default
vim default #在/var/lib/tftpboot/pxelinux.cfg目錄下修改default文件 添加內容: label PXE-linux menu label ^Install System from PXE-RHEL7.0 menu default kernel vmlinuz append initrd=initrd.img ks=http://192.168.1.32/ks.cfg ksdevice=eno16777736 ip=dhcp quiet 8.配置tftp-server syslinux service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 } 9.啟動服務和開機自啟動 systemctl start xinetd.service
systemctl enable xinetd.service 10.安裝配置httpd yum -y install httpd mkdir /var/www/html/iso cp -rf /mnt/* /var/www/html/iso 11.啟動服務 systemctl start httpd
systemctl enable httpd 12.無圖形界面配置kickstart一鍵安裝應答文件 vim /var/www/html/ks.cfg #platform=x86, AMD64, 或 Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us'# Reboot after installation reboot # Root password rootpw --iscrypted $1$FyasdJen$q2zUDfVq.ln1FmIlP8O/m0 //root密碼為7788521 # System timezone timezone Asia/Shanghai # Use network installation url --url="http://192.168.1.32/iso" # System language lang en_US # Firewall configuration firewall --disabled # Network information network --bootproto=dhcp --device=eno16777736 # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical firstboot --disable # SELinux configuration selinux --disabled # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part swap --asprimary --fstype="swap" --size=2048 part /boot --asprimary --fstype="xfs" --size=500 part / --asprimary --fstype="xfs" --grow --size=1 %packages @base @compat-libraries @core %end 有圖形化系統可以安裝Kickstart生產ks.cfg文件 yum -y install system-config-kickstart.noarch system-config-kickstart 13.修改SELinux狀態 vim /etc/sysconfig/selinux
SELINUX=disabled 14.開放防火牆服務和埠 firewall-cmd --permanent --add-service=dhcp firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-port=69/udp firewall-cmd --permanent --add-port=111/tcp firewall-cmd --permanent --add-port=111/udp firewall-cmd --permanent --add-port=20048/tcp firewall-cmd --permanent --add-port=20048/udp firewall-cmd --reload