您的当前位置:首页linux下PXE和KickStart实现Linux下的无人值笔记

linux下PXE和KickStart实现Linux下的无人值笔记

2021-06-27 来源:乌哈旅游
linux下PXE和KickStart实现Linux下的无人值守安装 分类: 服务器配置 2013-11-20 22:17 1873人阅读 评论(0) 收藏 举报 PXEKickStart无人值守安装 目录(?)[+] KickStart无人值守安装的原理: 1. DHCP服务器给需要安装的机器分发IP, 并指定ftp服务器地址和pxelinux.0 [html] view plaincopyprint? 1. next-server 192.168.2.18; 2. filename \"pxelinux.0\";

2. 客户端连接到服务器,读取启动文件 /tftpboot/pxelinux.cfg/default 3. 根据default里面指定的ks.cfg文件的位置,打开KickStart配置文件, 4. 根据ks.cfg的ftp服务器的配置, 读取/var/ftp/pub/文件, 引导安装程序

1. 查看服务状态, 启动服务

1.1 查看三种服务的状态,是否为启动状态

[html] view plaincopyprint?

1. service vsftpd status 2. service xinetd status 3. service dhcpd status

1.2 如果没有默认启动,可以设置为默认启动.

[html] view plaincopyprint?

1. service vsftpd status 2. service xinetd status 3. service dhcpd status

1.3 dhcp服务配置

rpm -ql dhcp | more vim /etc/dhcp/dhcpd.conf

[root@centos6-64 pub]# cat /etc/dhcp/dhcpd.conf

[html] view plaincopyprint?

1. ddns-update-style interim; 2. ignore client-updates; 3. allow booting; 4. allow bootp;

5. subnet 192.168.2.0 netmask 255.255.255.0 {

6. option routers 192.168.2.1; 7. option subnet-mask 255.255.255.0; 8. option domain-name-servers 192.168.2.1; 9. option time-offset -18000; # Eastern Standard Time

10. range dynamic-bootp 192.168.2.60 192.168.2.100; 11. default-lease-time 21600; 12. max-lease-time 43200; 13. next-server 192.168.2.18; 14. filename \"pxelinux.0\"; 15. }

1.4 tftp服务配置

yum intall -y tftp*

tftp服务是xinetd的子服务.

[root@centos6-64 ftp]# cat /etc/xinetd.d/tftp

[html] view plaincopyprint?

1. # default: off

2. # description: The tftp server serves files using the trivial file

transfer \\

3. # protocol. The tftp protocol is often used to boot diskless \\ 4. # workstations, download configuration files to network-aware printers, \\

5. # and to start the installation process for some operating system

s.

6. service tftp 7. {

8. socket_type = dgram 9. protocol = udp 10. wait = yes 11. user = root

12. server = /usr/sbin/in.tftpd 13. server_args = -s /tftpboot 14. disable = no 15. per_source = 11 16. cps = 100 2 17. flags = IPv4 18. }

2. 创建pxe启动所需要的文件和目录

[html] view plaincopyprint?

1. mkdir /tftpboot

2. mkdir /tftpboot/pxelinux.cfg

3. cp /usr/share/syslinux/pxelinux.0 /tftpboot/

挂载安装光盘的镜像,并拷贝以下文件:

[html] view plaincopyprint?

1. cp /mnt/iso/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/defau

lt

2. cp /mnt/iso/images/pxeboot/initrd.img /tftpboot/ 3. cp /mnt/iso/images/pxeboot/vmlinuz /tftpboot/

3. 修改/tftpboot/pxelinux.cfg/default文件

vim /tftpboot/pxelinux.cfg/default

[root@centos6-64 pxelinux.cfg]# cat default

[html] view plaincopyprint?

1. default linux 2. prompt 1 3. timeout 60

4. display boot.msg 5. label linux 6. kernel vmlinuz

7. append initrd=initrd.img text ks=ftp://192.168.2.18/ks.cfg

ks.cfg 是使用kickstart程序生成的文件.后面我们会使用KickStart生成它.

4. 使用kickstart程序生成ks.cfg安装配置文件

安装kickstart: yum list *kic*

yum install system-config-kickstart.noarch

运行system-config-kickstart,进行图形化参数配置界面:

4.1.基本配置:

4.2 安装方法

4.3.创建新的分区:

4.4.网络配置:

4.5.剩下的项目是关于防火墙,selinux的,看个人需求选择. 最后保存配置文件:

5. 修改生成的ks.cfg文件

5.1 将%packages后面的全拷贝到ks.cfg中的%packages后面去

cat /root/anaconda-ks.cfg #系统的安装信息

[html] view plaincopyprint?

1. %packages 2. @base

3. @chinese-support 4. @core 5. @debugging 6. @basic-desktop 7. @desktop-debugging 8. @desktop-platform 9. @directory-client 10. @fonts

11. @general-desktop 12. @graphical-admin-tools 13. @input-methods

14. @internet-applications 15. @internet-browser 16. @java-platform 17. @legacy-x

18. @network-file-system-client 19. @office-suite 20. @print-client

21. @remote-desktop-clients 22. @server-platform 23. @server-policy 24. @x11 25. mtools 26. pax 27. oddjob 28. wodim 29. sgpio 30. genisoimage

31. device-mapper-persistent-data 32. abrt-gui 33. samba-winbind

34. certmonger 35. pam_krb5

36. krb5-workstation 37. gnome-pilot 38. libXmu

5.2 添加key --skip //跳过输入序列号环节

<注意是两个\"-\"> [root@rhce ~]# cat ks.cfg

[root@centos6-64 tftpboot]# cat /var/ftp/ks.cfg [root@centos6-64 ftp]# cat ks.cfg

[html] view plaincopyprint?

1. #platform=x86, AMD64, or Intel EM64T 2. #version=DEVEL

3. # Firewall configuration 4. firewall --disabled

5. # Install OS instead of upgrade 6. install

7. # Use network installation 8. url --url=ftp://192.168.2.18/pub 9. # Root password

10. rootpw --iscrypted $1$YfhInJ/9$hqyxxL34AduJm0Zzfcl/F1 11. # System authorization information 12. auth --passalgo=sha512 13. # Use graphical install 14. graphical

15. firstboot --disable 16. # System keyboard 17. keyboard us 18. # System language 19. lang en_US

20. # SELinux configuration

21. selinux --disabled

22. # Installation logging level 23. logging --level=info 24. 25.

26. key --skip 27. 28.

29. # System timezone 30. timezone Asia/Shanghai 31. # Network information

32. network --bootproto=dhcp --device=eth0 --onboot=on 33. # System bootloader configuration 34. bootloader --location=mbr 35. # Clear the Master Boot Record 36. zerombr

37. # Partition clearing information 38. clearpart --all --initlabel 39. # Disk partitioning information 40. part /boot --fstype=\"ext4\" --size=200 41. part swap --fstype=\"swap\" --size=4096 42. part / --fstype=\"ext4\" --grow --size=1 43. 44.

45. %packages 46. @base

47. @chinese-support 48. @core 49. @debugging 50. @basic-desktop 51. @desktop-debugging 52. @desktop-platform 53. @directory-client 54. @fonts

55. @general-desktop

56. @graphical-admin-tools 57. @input-methods

58. @internet-applications 59. @internet-browser 60. @java-platform 61. @legacy-x

62. @network-file-system-client 63. @office-suite 64. @print-client

65. @remote-desktop-clients 66. @server-platform 67. @server-policy 68. @x11 69. mtools 70. pax 71. oddjob 72. wodim 73. sgpio 74. genisoimage

75. device-mapper-persistent-data 76. abrt-gui 77. samba-winbind 78. certmonger 79. pam_krb5

80. krb5-workstation 81. gnome-pilot 82. libXmu 83. 84. 85. %end

5.3 将配置文件拷贝到ftp目录下

[html] view plaincopyprint?

1. cp ks.cfg /var/ftp/

6. 将系统相关文件拷贝到配置ks.cfg时,指定的ftp目录下

挂载系统镜文件到/vat/ftp/pub/下 [root@centos6-64 ~]# ls -l /var/ftp/

[html] view plaincopyprint?

1. total 8

2. -rw-r--r-- 1 root root 1419 Nov 20 17:58 ks.cfg 3. dr-xr-xr-x 7 root root 4096 Mar 6 2013 pub

[root@centos6-64 ~]# ls -l /var/ftp/pub/

[html] view plaincopyprint?

1. total 676

2. -r--r--r-- 2 root root 14 Mar 6 2013 CentOS_BuildTag 3. dr-xr-xr-x 3 root root 2048 Mar 5 2013 EFI 4. -r--r--r-- 2 root root 212 Mar 3 2013 EULA 5. -r--r--r-- 2 root root 18009 Mar 3 2013 GPL 6. dr-xr-xr-x 3 root root 2048 Mar 5 2013 images 7. dr-xr-xr-x 2 root root 2048 Mar 5 2013 isolinux 8. dr-xr-xr-x 2 root root 649216 Mar 6 2013 Packages 9. -r--r--r-- 2 root root 1354 Mar 3 2013 RELEASE-NOTES-en-US.html

10. dr-xr-xr-x 2 root root 4096 Mar 6 2013 repodata

11. -r--r--r-- 2 root root 1706 Mar 3 2013 RPM-GPG-KEY-CentOS-6 12. -r--r--r-- 2 root root 1730 Mar 3 2013 RPM-GPG-KEY-CentOS-Debug-6

13. -r--r--r-- 2 root root 1730 Mar 3 2013 RPM-GPG-KEY-CentOS-Security-6

14. -r--r--r-- 2 root root 1734 Mar 3 2013 RPM-GPG-KEY-CentOS-Testing-6

15. -r--r--r-- 1 root root 3380 Mar 6 2013 TRANS.TBL

到此配置结束, 启动需要安装系统的机器. 修改BIOS以网卡方式启动.

如果DHCP配置有问题,或PXE找不到安装文件的问题, 请查看/var/log/message 或仔细核对目录是否一致.

#注意如果KickStarts配置在虚拟机中, 虚拟机的网卡要设置为桥接(Bridged)模式.

因篇幅问题不能全部显示,请点此查看更多更全内容