歡迎您光臨本站 註冊首頁

RH133-1 利用PXE自動安裝linux配置

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

利用PXE自動安裝linux配置

環境:server:192.168.32.20 client:192.168.32.21 原理:客戶端PXE網卡啟動--DHCP伺服器獲得IP--從TFTP目錄上下載pxelinux.0、default--根據配置文件default指定的vmlinuz、initrd啟動系統內核--通過內核指定地點去下載ks.cfg文件--跟據ks.cfg去(HTTP、FTP、NFS)伺服器下載RPM包並安裝系統----完成安裝 1、NFS伺服器配置 [root@server1 ~]# cat /etc/exports /var/ftp/pub *(ro) #rhel5.5安裝光碟存放目錄/var/ft/pub下 [root@server1 ~]# /etc/init.d/nfs start [root@server1 ~]#chkconfig nfs on [root@server1 ~]# /etc/init.d/portmap start 註:nfs服務是基於rpc服務的,即需要開啟portmap服務 2、DHCP伺服器配置 [root@server1 ~]#cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf [root@server1 ~]#vi /etc/dhcpd ddns-update-style interim; #定義所支持的DNS動態更新類型,該參數必選且必須放在第一行,一般為none和interim ignore client-updates; subnet 192.168.32.0 netmask 255.255.255.0 { #定義dhcp的網段 # --- default gateway option routers 192.168.32.254; option subnet-mask 255.255.255.0; option nis-domain "notexample"; option domain-name "example.com"; option domain-name-servers 192.168.32.20; option time-offset -18000; # Eastern Standard Time # option ntp-servers 192.168.1.1; # option netbios-name-servers 192.168.1.1; # --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well # option netbios-node-type 2; range dynamic-bootp 192.168.32.25 192.168.32.27; default-lease-time 21600; max-lease-time 43200; next-server 192.168.32.20;

#定義提供PXE服務的tftp伺服器地址 filename "/pxelinux.0"; #定義PXE啟動文件pxelinux.0存放位置 # we want the nameserver to appear at a fixed address host ns { next-server marvin.redhat.com; hardware ethernet 12:34:56:78:AB:CD; fixed-address 207.175.42.254; } } 註:DHCP配置文件中每個選項行必須以;結尾,否則DHCP會啟動失敗 [root@server1 ~]#service dhcpd start #啟動dhcp服務 [root@server1 ~]#chkconfig dhcpd on #添加到開機自起動 3、tftp伺服器配置 [root@server1 ~]#vi /etc/xinetd.d/tftp service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot disable = no #將此行默認不啟動,no為啟動 per_source = 11 cps = 100 2 flags = IPv4 } [root@server1 ~]#/etc/init.d/xinetd restart [root@server1 ~]#chkconfig xinetd on 4、PXE配置 [root@server1 ~]#cp /usr/lib/syslinux/pxelinux.0 /tftpboot/pxelinux.0 [root@server1 ~]#cp /var/ftp/pub/isolinux/vmlinuz /tftpboot/vmlinuz [root@server1 ~]#cp /var/ftp/pub/isolinux/initrd.img /tftpboot/initrd.img [root@server1 ~]#mkdir /tftpboot/pxelinux.cfg [root@server1 ~]#cp /var/ftp/pub/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default [root@server1 ~]#vi /tftpboot/pxelinux.cfg/default default linux

#如果啟動時不按任何選項,默認執行lable linux安裝 prompt 1 #啟動時候等待參數,設置為0 表示啟動不等待參數,直接進入,網路安裝必須為1 timeout 10 display boot.msg #.msg文件是啟動時的顯示界面,圖像文件,可不要,要則複製到/tftpboot/目錄下 F1 boot.msg F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label linux kernel vmlinuz append initrd=initrd.img ks=nfs:192.168.32.220:/var/ftp/pub/ks.cfg #指定kickstart配置文件 label text kernel vmlinuz append initrd=initrd.img text label ks kernel vmlinuz append ks initrd=initrd.img label local localboot 1 label memtest86 kernel memtest append - 5、通過kickstart生產ks.cfg配置文件 5.1、配置yum源 #運行kickstart時,在選擇安裝所需軟體包時需要yum的支持 [root@server1 ~]#vi /etc/yum.repos.d/server1.repo [base] #注此處必須為[base]或[core]否則kickstart啟動時無法找到軟體包源,此為perl的bug name=server baseurl=file:///var/ftp/pub/Server enabled=1 gpgcheck=0 [root@server1 ~]#yum makecache 5.2、進入5級別,圖形界面中,利用kickstart創建ks.cfg文件 [root@server1 ~]#system-config-kickstart #按照提示進行配置,並將其文件保存為/var/ftp/pub/ks.cfg [root@server1 ~]#vi /var/ft/pub/ks.cfg #platform=x86, AMD64, 或 英特爾 EM64T # System authorization information auth --useshadow --enablemd5 key --skip #必須加入此行,否則在pxe安裝時會要求輸入sn號而中斷

# System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Use text mode install text # Firewall configuration firewall --disabled # Run the Setup Agent on first boot firstboot --disable # System keyboard keyboard us # System language lang zh_CN # Installation logging level logging --level=info # Use NFS installation media nfs --server=192.168.32.20 --dir=/var/ftp/pub/ #指定安裝盤所在位置 # Network information network --bootproto=dhcp --device=eth0 --onboot=on # Reboot after installation reboot #Root password rootpw --iscrypted $1$JJqgz1nm$gGpOgJGbq24TxU32NG0r4. # SELinux configuration selinux --permissive # System timezone timezone America/New_York # Install OS instead of upgrade install # X Window System configuration information xconfig --defaultdesktop=GNOME --depth=32 --resolution=1024x768 # Disk partitioning information #分區信息,默認是普通分區,可手動修改成lvm分區 part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100 part swap --bytes-per-inode=4096 --fstype="swap" --size=1024 part / --bytes-per-inode=4096 --fstype="ext3" --size=10240 #part /boot --fstype ext3 --size=100 --ondisk=sda #創建lvm分區 #part pv.2 --size=0 --grow --ondisk=sda #volgroup VolGroup00 --pesize=32768 pv.2 #logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow #logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=4032 %packages @development-libs @gnome-desktop @base @base-x @admin-tools @legacy-software-development @development-tools @printing @chinese-support @server-cfg @legacy-network-server @legacy-software-support @system-tools @text-internet @editors @ftp-server @network-server @smb-server

本文出自 「netsword.blogchina.com」 博客,請務必保留此出處http://netsword.blog.51cto.com/13993/554515


[火星人 ] RH133-1 利用PXE自動安裝linux配置已經有653次圍觀

http://coctec.com/docs/linux/show-post-48744.html