-
-
Save qinshulei/5cb3e4606fa4e0129f1d5c371c6e78de to your computer and use it in GitHub Desktop.
Revisions
-
chenyukang revised this gist
Aug 21, 2014 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -116,6 +116,8 @@ append vga=788 url=http://192.168.199.50/trusty.seed initrd=ubuntu-installer/amd 其中trusty.seed文件是放在/var/www/html/trusty.seed, 这个其实是Ubuntu(或者Debian)系统安装时候的用户指定参数文件: 文件的内容是: ```shell d-i live-installer/net-image string http://192.168.199.50/ubuntu/install/filesystem.squashfs ``` seed文件也可以添加其他的自动安装选项。不过kickstart可能更好点。 -
chenyukang revised this gist
Aug 21, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -117,4 +117,5 @@ append vga=788 url=http://192.168.199.50/trusty.seed initrd=ubuntu-installer/amd 文件的内容是: `d-i live-installer/net-image string http://192.168.199.50/ubuntu/install/filesystem.squashfs` seed文件也可以添加其他的自动安装选项。不过kickstart可能更好点。 -
chenyukang revised this gist
Aug 18, 2014 . 1 changed file with 20 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ ubuntu的官方文档比较久了,步骤也很繁琐,不推荐。 最简单的dhcp.conf即可: ``` allow booting; allow bootp; @@ -28,7 +28,7 @@ subnet 192.168.200.0 netmask 255.255.255.0 { option routers 192.168.200.1; filename "pxelinux.0"; } ``` 注意启动的时候用service,网络上很多教程都是`/etc/init.d/dhcpd start`,这样好像有问题。 @@ -42,26 +42,29 @@ subnet 192.168.200.0 netmask 255.255.255.0 { 启动Nginx或者Apache,保证http://192.168.199.50/ubuntu能访问到镜像: ``` $mkdir /mnt/ubuntu $mount -o loop ubuntu-server.iso /mnt/ubuntu $cd /var/www/html $sudo ln -s /mnt/ubuntu ubuntu ``` ### TFTP服务 准备netboot文件到/var/lib/tftpboot目录,确保用户组权限为nobody。 ``` $sudo mkdir /var/lib/tftpboot $sudo chmod -R 777 /var/lib/tftpboot $sudo chown -R nobody /var/lib/tftpboot $sudo cp -R ubuntu/install/netboot/* /var/lib/tftpboot/ ``` 配置tftp服务,tftp服务由xinetd服务管理。 配置文件: ``` service tftp { protocol = udp @@ -73,22 +76,23 @@ service tftp server_args = /var/lib/tftpboot disable = no } ``` 这里有个坑,虽然我们添加了server_args为我们期望放boot文件的目录:/var/lib/tftpboot目录, 但真正运行起来的时候好像没起作用,查看文件/etc/inetd.conf,其中有一行是: `tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd -s /var/lib/tftpboot` 确保后面的-s路径是我们期望的放netboot文件的目录。tftp默认端口69,启动后检查一下。 更保险的是用另外一台机器去尝试获取动态IP,然后运行tftp保证DHCP和tftp服务都是正常运行的: ``` tftp 192.168.199.50 tftp> get version.info Received 60 bytes in 0.0 seconds tftp> quit ``` ### 启动需要安装的服务器 @@ -100,26 +104,17 @@ tftp> quit 增加参数:url=http://192.168.199.50/trusty.seed, 修改后就是这样: ``` default install label install menu label ^Install menu default kernel ubuntu-installer/amd64/linux append vga=788 url=http://192.168.199.50/trusty.seed initrd=ubuntu-installer/amd64/initrd.gz -- quiet ``` 其中trusty.seed文件是放在/var/www/html/trusty.seed, 这个其实是Ubuntu(或者Debian)系统安装时候的用户指定参数文件: 文件的内容是: `d-i live-installer/net-image string http://192.168.199.50/ubuntu/install/filesystem.squashfs` 也 -
chenyukang revised this gist
Aug 18, 2014 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,12 +42,11 @@ subnet 192.168.200.0 netmask 255.255.255.0 { 启动Nginx或者Apache,保证http://192.168.199.50/ubuntu能访问到镜像: `$mkdir /mnt/ubuntu` `$mount -o loop ubuntu-server.iso /mnt/ubuntu` `$cd /var/www/html` `$sudo ln -s /mnt/ubuntu ubuntu` ### TFTP服务 准备netboot文件到/var/lib/tftpboot目录,确保用户组权限为nobody。 -
chenyukang revised this gist
Aug 18, 2014 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,21 +43,21 @@ subnet 192.168.200.0 netmask 255.255.255.0 { 启动Nginx或者Apache,保证http://192.168.199.50/ubuntu能访问到镜像: ` $mkdir /mnt/ubuntu $mount -o loop ubuntu-server.iso /mnt/ubuntu $cd /var/www/html $sudo ln -s /mnt/ubuntu ubuntu ` ### TFTP服务 准备netboot文件到/var/lib/tftpboot目录,确保用户组权限为nobody。 ` $sudo mkdir /var/lib/tftpboot $sudo chmod -R 777 /var/lib/tftpboot $sudo chown -R nobody /var/lib/tftpboot $sudo cp -R ubuntu/install/netboot/* /var/lib/tftpboot/ ` 配置tftp服务,tftp服务由xinetd服务管理。 -
chenyukang revised this gist
Aug 18, 2014 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ ubuntu的官方文档比较久了,步骤也很繁琐,不推荐。 最简单的dhcp.conf即可: ` allow booting; allow bootp; @@ -28,8 +28,7 @@ subnet 192.168.200.0 netmask 255.255.255.0 { option routers 192.168.200.1; filename "pxelinux.0"; } ` 注意启动的时候用service,网络上很多教程都是`/etc/init.d/dhcpd start`,这样好像有问题。 @@ -43,12 +42,12 @@ subnet 192.168.200.0 netmask 255.255.255.0 { 启动Nginx或者Apache,保证http://192.168.199.50/ubuntu能访问到镜像: ` # mkdir /mnt/ubuntu # mount -o loop ubuntu-server.iso /mnt/ubuntu # cd /var/www/html # sudo ln -s /mnt/ubuntu ubuntu ` ### TFTP服务 准备netboot文件到/var/lib/tftpboot目录,确保用户组权限为nobody。 -
chenyukang created this gist
Aug 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,127 @@ ## 理论部分 阐述最清楚的两篇是两篇中文的: [PXE网络批量安装ubuntu](http://www.williamsang.com/archives/1842.html) [网路启动服务器安装和配置方法(pxe+tftp+dhcpd)](http://www.51know.info/system_install/pxe_server/NetworkBootServer.html) ubuntu的官方文档比较久了,步骤也很繁琐,不推荐。 ## 实践中的坑 注意这里示例里面的IP是192.168.199.50,具体实践过程中会有变动。 ### DHCP服务 `sudo apt-get -y install dhcp3-server` 安装的时候注意dhcp3-server被改名了,现在叫作isc-dhcp-server,网上的很多教程没有相应的更新。 最简单的dhcp.conf即可: {% highlight ruby %} allow booting; allow bootp; subnet 192.168.200.0 netmask 255.255.255.0 { range 192.168.200.100 192.168.200.200; option routers 192.168.200.1; filename "pxelinux.0"; } {% endhighlight %} 注意启动的时候用service,网络上很多教程都是`/etc/init.d/dhcpd start`,这样好像有问题。 `# sudo service isc-dhcp-server start` 默认端口为67,启动以后检查一下: `sudo netstat -nutlp | grep 67` ### ubuntu系统镜像 启动Nginx或者Apache,保证http://192.168.199.50/ubuntu能访问到镜像: {% highlight ruby %} # mkdir /mnt/ubuntu # mount -o loop ubuntu-server.iso /mnt/ubuntu # cd /var/www/html # sudo ln -s /mnt/ubuntu ubuntu {% endhighlight %} ### TFTP服务 准备netboot文件到/var/lib/tftpboot目录,确保用户组权限为nobody。 {% highlight ruby %} # sudo mkdir /var/lib/tftpboot # sudo chmod -R 777 /var/lib/tftpboot # sudo chown -R nobody /var/lib/tftpboot # sudo cp -R ubuntu/install/netboot/* /var/lib/tftpboot/ {% endhighlight %} 配置tftp服务,tftp服务由xinetd服务管理。 配置文件: {% highlight ruby %} service tftp { protocol = udp port = 69 socket_type = dgram wait = yes user = nobody server = /usr/sbin/in.tftpd server_args = /var/lib/tftpboot disable = no } {% endhighlight %} 这里有个坑,虽然我们添加了server_args为我们期望放boot文件的目录:/var/lib/tftpboot目录, 但真正运行起来的时候好像没起作用,查看文件/etc/inetd.conf,其中有一行是: `tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd -s /var/lib/tftpboot` 确保后面的-s路径是我们期望的放netboot文件的目录。tftp默认端口69,启动后检查一下。 更保险的是用另外一台机器去尝试获取动态IP,然后运行tftp保证DHCP和tftp服务都是正常运行的: {% highlight ruby %} tftp 192.168.199.50 tftp> get version.info Received 60 bytes in 0.0 seconds tftp> quit {% endhighlight %} ### 启动需要安装的服务器 系统自检后按照Bios里面设定的次序从CD启动,硬盘启动,然后是PXE。需要的时候按F12从网络启动(一个伤心的坑)。如果正常就应该通过DHCP获取到IP, 然后下载netboot,进入到安装界面。 最后一个巨坑,Ubuntu server 14.04好像有个Bug,详细描述在[这里](http://www.michaelm.info/blog/?p=1378)。 解决方案就是修改文件/var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg: 增加参数:url=http://192.168.199.50/trusty.seed, 修改后就是这样: {% highlight ruby %} default install label install menu label ^Install menu default kernel ubuntu-installer/amd64/linux append vga=788 url=http://192.168.199.50/trusty.seed initrd=ubuntu-installer/amd64/initrd.gz -- quiet {% endhighlight %} 其中trusty.seed文件是放在/var/www/html/trusty.seed, 这个其实是Ubuntu(或者Debian)系统安装时候的用户指定参数文件: 文件的内容是: `d-i live-installer/net-image string http://192.168.199.50/ubuntu/install/filesystem.squashfs` 也可以添加其他的选项,这样在具体安装的过程中可以减少人为的参与,比如添加下面这些: {% highlight ruby %} ### Localization d-i debian-installer/locale string en_US.utf8 d-i console-setup/ask_detect boolean false d-i keyboard-configuration/layoutcode string us {% endhighlight %} 安装的时候就不用手动再选择这些了。