下龙山一号楼

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Ubuntu:16.04(需要安装桌面),作为服务端

服务端IP:192.168.193.128

实践:

1.安装dhcp服务

apt-get install isc-dhcp-server -y    #如果提示E: 无法定位软件包 isc-dhcp-Server,执行此命令apt-get update

2.配置dhcp服务(主要是两个文件)

     a.vim /etc/default/isc-dhcp-server

        INTERFACES="ens33"       # 指定的网络接口名字

     b.vim /etc/dhcp/dhcpd.conf    #在文件末尾添加即可

        subnet 192.168.193.0 netmask 255.255.255.0 {      #dhcpserver 分配ip的子网192.168.193网段,必须和PXE server的一个网卡同一个网段 

        range 192.168.193.100 192.168.193.200;     #为客户端分配ip范围

        default-lease-time 600;

        max-lease-time 7200;

        filename "pxelinux.0";     #通过tftp找到pxelinux.0文件,并下载

        next-server 192.168.193.128;    #指定tftp server的ip

        }

     配置完重启系统

     systemctl restart isc-dhcp-server

     查看服务

     netstat -tunlp|grep 67

     udp        0      0 0.0.0.0:67              0.0.0.0:*                           2119/dhcpd 

3.安装tftp服务

apt-get install tftpd-hpa -y      #安装完成就ok了,使用默认配置即可,tftp目录是 /var/lib/tftpboot/

vim /etc/default/tftpd-hpa   #默认配置

# /etc/default/tftpd-hpa

 

TFTP_USERNAME="tftp"

TFTP_DIRECTORY="/var/lib/tftpboot"

TFTP_ADDRESS=":69"

TFTP_OPTIONS="--secure"

4.安装apache2

apt-get install apache2 -y   #也是安装完就可以了,http根目录是 /var/www/html/

5.拷贝及修改所需文件

 

mkdir /var/www/html/ubuntu

rm -fr /var/www/html/index.html 

mount /dev/cdrom /mnt

cp -r /mnt/* /var/www/html/ubuntu/

cp -r /var/www/html/ubuntu/install/netboot/* /var/lib/tftpboot/

cp /var/www/html/ubuntu/preseed/ubuntu-server.seed /var/www/html/

vim /var/www/html/ubuntu-server.seed   #文件最后添加

live-installer/net-image=http://192.168.193.128/ubuntu/install/filesystem.squashfs

6.安装kickstart

kickstart需要GUI界面,我因为是安装的server,所以需要安装桌面(如果是desktop版本就不需要),如下安装

 

apt-get install ubuntu-desktop -y

apt-get install system-config-kickstart -y

安装完之后,重启一下进入桌面

打开终端执行system-config-kickstart

 

 

在命令行root家目录

 

cp ks.cfg /var/www/html/

 

vim /var/www/html/ks.cfg   #添加安装的软件包

 

skipx    #下面添加需要安装的软件包

 

%packages

 

openssh-server

 

编辑txt.cfg

 

vim /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg

 

default install

 

label install

 

        menu label ^Install

 

        menu default

 

        kernel ubuntu-installer/amd64/linux

 

        append ks=http://192.168.193.128/ks.cfg vga=788 initrd=ubuntu-installer/amd64/initrd.gz live-installer/net-image=http://192.168.193.128/ubuntu/install/filesystem.squashfs

 

label cli

 

        menu label ^Command-line install

 

        kernel ubuntu-installer/amd64/linux

 

        append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=788 initrd=ubuntu-installer/amd64/initrd.gz --- quiet 

 

编辑文件default

 

vim /var/lib/tftpboot/pxelinux.cfg/default

 

# D-I config version 2.0

 

# search path for the c32 support libraries (libcom32, libutil etc.)

 

path ubuntu-installer/amd64/boot-screens/

 

include ubuntu-installer/amd64/boot-screens/menu.cfg

 

default ubuntu-installer/amd64/boot-screens/vesamenu.c32

 

prompt 0

 

timeout 10  #默认是0(手动),改为101秒后自动选择install选项)

 

ks.cfg

#Generated by Kickstart Configurator
#platform=x86

#System language
lang en_US
#Language modules to install
langsupport zh_CN --default=en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $1$MtDQyPtj$pEGGLGCaEHyIrR.JRDnYC1
#Initial user
user --disabled
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use Web installation
url --url http://192.168.1.85/ubuntu
#System bootloader configuration
bootloader --location=mbr 
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype ext4 --size 200 --asprimary
part / --fstype ext4 --size 10000
part swap --size 2000
part /boot/efi --fstype vfat --size 200
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled
#
%pre parted -s /dev/sda mklabel gpt %end #Do not configure the X Window System skipx %packages openssh-server vim

 

 

配置支持PXE的启动程序

PXE引导配置

syslinux是一个功能强大的引导加载程序,并且兼容各种介质

syslinux是一个小型的linux操作系统,目的是简化linux首次安装的时间,并建立维护或其他特殊用途的启动盘

如果没有找到pxelinux.0这个文件,可以安装下syslinux

apt-get install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp -a /var/www/html/centos7/isolinux/* /var/lib/tftpboot/

mkdir  /var/lib/tftpboot/pxelinux.cfg  ==》创建一个pxelinux.cfg目录,存放客户端的配置文件
cp /var/www/html/centos7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

 

[root@kisckstart ~]# vim /etc/xinetd.d/tftp
service tftp
{
       socket_type            = dgram
       protocol         = udp
       wait               = yes
       user               = root
       server                    = /usr/sbin/in.tftpd
       server_args            = -s /var/lib/tftpboot
       disable                  = no    ##由原来的yes变为no
       per_source             = 11
       cps                 = 100 2
       flags              = IPv4
}

 

posted on 2020-04-26 14:37  下龙山王俊凯  阅读(523)  评论(0编辑  收藏  举报