PXE自動化安裝centos6與centos7

PXE自動化安裝centos7系統
1、確保防火墻和selinux全部關閉
2、yum -y install dhcp tftp-server httpd syslinux
3、啟動相關服務
systemctl start httpd
systemctl enable httpd
systemctl start tftp.service
systemctl enable tftp.service
4、編輯dhcp配置文件/etc/dhcp/dhcpd.conf
subnet 192.168.67.0 netmask 255.255.255.0 {
range 192.168.67.150 192.168.67.200;
option routers 192.168.67.253;
next-server 192.168.67.130;
filename “pxelinux.0″;
}
5、啟動dhcp服務
Systemctl start dhcpd
Systemctl enable dhcpd
6、自動掛載光盤,供客戶端安裝系統
mkdir -p /var/www/html/centos/7
vim /etc/fstab
/dev/sr0 /var/www/html/centos/7 iso9660 defaults 0 0
mount -a
7、在/var/www/html/目錄下創建ksdir/7目錄,編輯應答文件ks7_desktop.cfg放入其中
mkdir -p /var/www/html/ksdir/7
vim ks7_desktop.cfg
cp /root/anaconda-ks.cfg ks7_desktop.cfg
chmod +r ks7_desktop.cfg
vim ks7_desktop.cfg
#version=DEVEL
# System authorization information
auth –enableshadow –passalgo=sha512
# Use CDROM installation media
url –url=http://192.168.67.130/centos/7
# Use graphical install
text
reboot
# Run the Setup Agent on first boot
firstboot –enable
ignoredisk –only-use=sda
# Keyboard layouts
keyboard –vckeymap=us –xlayouts=’us’
# System language
lang en_US.UTF-8

# Network information
network –bootproto=dhcp –device=ens33 –onboot=on –ipv6=auto –activate
network –hostname=centos7

# Root password
rootpw –iscrypted $6$BKZMtfbq7nheJUSc$maT1N3JM4MKPu5u4cwWmmO6PRtlJfapZ11rTt/Vp4jE2IJN1eqL3YXugStz4Ywwn9JeDftsFFVkvxN8/uu9el.
# System services
services –disabled=”chronyd”
# System timezone
timezone Asia/Shanghai –isUtc –nontp
user –name=wang –password=$6$ajL2KgUguatiI0Ix$he/GsnwS19klg6U5J1QhghVlojJuRt8q6pKGEdT/rynfFYH64h7nlBxHiXa8s/qSyup/HI.HekOnc7011t36d/ –iscrypted –gecos=”wang”
# X Window System configuration information
xconfig –startxonboot
# System bootloader configuration
bootloader –append=” crashkernel=auto” –location=mbr –boot-drive=sda
# Partition clearing information
zerombr
clearpart –none –initlabel
# Disk partitioning information
part swap –fstype=”swap” –ondisk=sda –size=2000
part / –fstype=”xfs” –ondisk=sda –size=50000
part /boot –fstype=”xfs” –ondisk=sda –size=1000
part /data –fstype=”xfs” –ondisk=sda –size=30000

%packages
@^gnome-desktop-environment
@base
@core
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@print-client
@x11
autofs
%end

%addon com_redhat_kdump –enable –reserve-mb=’auto’

%end

%anaconda
pwpolicy root –minlen=6 –minquality=1 –notstrict –nochanges –notempty
pwpolicy user –minlen=6 –minquality=1 –notstrict –nochanges –emptyok
pwpolicy luks –minlen=6 –minquality=1 –notstrict –nochanges –notempty
%end

%post
systemctl enable autofs
systemctl disable initial-setup.service
systemctl set-default multi-user.target
mkdir /root/.ssh
cat > /root/.ssh/authorized_keys < /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
EOF
%end

8、在tftp工作目錄/var/lib/tftpboot/下創建pxelinux.cfg目錄
mkdir -p /var/lib/tftpboot/pxelinux.cfg/
9、拷貝pxelinux.0文件到/var/lib/tftpboot/
rpm -ql syslinux | grep pxelinux.0
/usr/share/syslinux/pxelinux.0
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
10、復制背景菜單文件
[root@centos7 tftpboot]#rpm -ql syslinux | grep menu.c32
/usr/share/syslinux/menu.c32
/usr/share/syslinux/vesamenu.c32
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
11、到光盤下isolinux目錄下復制initrd.img,vmlinuz到/var/lib/tftpboot/目錄
cp /misc/cd/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
12、復制菜單配置文件到/var/lib/tftpboot/pxelinux.cfg/,并且改名default,之后編輯default
cp /misc/cd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
vim default

default menu.c32
timeout 600

menu title install centos

label desktop
menu label ^Install desktop CentOS 7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.67.130/ksdir/7/ks7_desktop.cfg

label check
menu label Test this ^media & install CentOS 7
menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

menu end

Pxe自動化安裝centos6
1、首先確認防火墻和selinux全部關閉
2、yum -y install dhcp tftp-servier httpd syslinux
3、開啟相關服務
chkconfig tftp on
service xinetd restart
Service httpd start
Chkconfig httpd on
4、編輯dhcp配置文件
subnet 192.168.67.0 netmask 255.255.255.0 {
range 192.168.67.50 192.168.67.100;
option routers 192.168.67.254;
option domain-name-servers 8.8.8.8;
next-server 192.168.67.131;
filename “pxelinux.0”;
}
5、啟動dhcp服務并設置開機啟動
Service dhcpd start
Chkconfig dhcpd on
6、在/var/www/html目錄下創建centos/6目錄
mkdir -p centos/6
7、自動掛載光盤
/dev/sr0 /var/www/html/centos/6 iso9660 defaults 0 0
8、創建目錄/var/www/html/ksdir/6,并且生成應答文件ks6_mini.cfg放置其中
mkdir -p /var/www/html/ksdir/6
cp ks6_mini.cfg /var/www/html/ksdir/6
chmod +r ks6_mini.cfg
9、進入到tftp工作目錄/var/lib/tftpboot/,創建目錄pxelinux.cfg
10、找到并復制pxelinux.0到/var/lib/tftpboot/
updatedb
locate
cp /usr/share/syslinux/pxelinux.0 ./
11、到光盤isolinux/目錄下復制initrd.img vmlinuz到/var/lib/tftpboot/目錄下
cp /misc/cd/isolinux/{initrd.img,vmlinuz} ./
12、復制菜單相關文件
cp /misc/cd/isolinux/{splash.jpg,vesamenu.c32} ./
13、復制菜單配置文件到/var/lib/tftpboot/pxelinux.cfg目錄下
cp /misc/cd/isolinux/isolinux.cfg ./pxelinux.cfg/default

本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/99638

(2)
王琪鋒王琪鋒
上一篇 2018-05-28 02:55
下一篇 2018-05-28 08:55

相關推薦

  • 第七周作業

      1、創建一個10G分區,并格式為ext4文件系統; ?(1) 要求其block大小為2048, 預留空間百分比為2, ??卷標為MYDATA, 默認掛載屬性包含acl; ?(2) 掛載至/data/mydata目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳; 1.創建分區/dev/sdb1,容量為10G fdisk /dev/sdb…

    2018-05-02
  • Shell腳本寫的備份還原工具 –reset.sh

    reset.sh腳本分兩個功能模塊,備份模塊和還原模塊;
    備份:備份指定文件到當前目錄,以備份時日期做為文件名
    還原模塊:可選擇性的還原指定時間的備份記錄

    2018-04-14
  • linux中PAM的配置和使用

    linux中PAM的配置和使用方法

    Linux筆記 2018-05-24
  • awk的使用

    awk -v設置變量 -F 指定分隔符 內置變量 FS:輸入字段分隔符,默認為空白字符,讀入內容的分隔符 OFS:輸出字段的分隔符 RS:指定行(記錄)分隔符 ORS:輸出記錄分隔符 NF:字段數量 NR:記錄的數量 ARGC:命令行參數的個數 ARGV:數組,保存的是命令行所有的參數   例1:不依賴文件和標準輸入 [root@centos7 ~…

    Linux筆記 2018-05-21
  • Linux第四周作業

    1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。 ]# cp -r /etc/skel /home/tuser1 ]# chmod -R go= /home/tuser1 2、編輯/etc/group文件,添加組hadoop。 ]# echo “hadoop:x…

    2018-07-09
欧美性久久久久