在ubuntu下安装PXE(dhcp,tftp,nfs)服务

This is a guide to setup a PXE environment on host machine.

### Introduction ###

PXE boot depends on DHCP, TFTP and NFS services. So before verifing PXE, you need to setup a working DHCP, TFTP, NFS server on one of your host machine in local network. In this case, my host OS is Ubuntu 12.04.

### Setup DHCP server on Ubuntu ###

Refer to https://help.ubuntu.com/community/isc-dhcp-server . For a simplified direction, try these steps:

# Install DHCP server package

    sudo apt-get install -y isc-dhcp-server syslinux

# Edit /etc/dhcp/dhcpd.conf to suit your needs and particular configuration.
    Make sure filename is consistent with the file in tftp root directory.
    Here is an example: This will enable board to load "grubaa64.efi" from TFTP root to target board and run it, when you boot from PXE in UEFI Boot Menu.

    $ cat /etc/dhcp/dhcpd.conf
    # Sample /etc/dhcpd.conf
    # (add your comments here)
    default-lease-time 600;
    max-lease-time 7200;
    subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.210 192.168.1.250;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 192.168.1.1;
        option routers 192.168.1.1;
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.1.255;
        # Change the filename according to your real local environment and target board type.
        # And make sure the file has been put in tftp root directory.
        # grubaa64.efi is for ARM64 architecture.
        # grubarm32.efi is for ARM32 architecture.
        filename "grubaa64.efi";
        #filename "grubarm32.efi";
        #next-server 192.168.1.107
    }
    #

# Edit /etc/default/isc-dhcp-server to specify the interfaces dhcpd should listen to. By default it listens to eth0.

    INTERFACES=""

# Use these commands to start and check DHCP service

    sudo service isc-dhcp-server restart

    Check status with "netstat -lu"

    Expected output:
    Proto Recv-Q Send-Q Local Address           Foreign Address         State      
    udp        0      0 *:bootpc                *:*                                

### Setup TFTP server on Ubuntu ###
# Install TFTP server and TFTP client(optional, tftp-hpa is the client package)

    sudo apt-get install -y openbsd-inetd tftpd-hpa tftp-hpa lftp

# Edit /etc/inetd.conf
    Remove "#" from the beginning of tftp line or add if it’s not there under “#:BOOT:” comment as follow.

    tftp    dgram   udp wait    root    /usr/sbin/in.tftpd  /usr/sbin/in.tftpd -s /var/lib/tftpboot

# Enable boot service for inetd

    sudo update-inetd --enable BOOT

# Configure the TFTP server, update /etc/default/tftpd-hpa like follows:

    TFTP_USERNAME="tftp"
    TFTP_ADDRESS="0.0.0.0:69"
    TFTP_DIRECTORY="/var/lib/tftpboot"
    TFTP_OPTIONS="-l -c -s"

# Set up TFTP server directory

    sudo mkdir /var/lib/tftpboot
    sudo chmod -R 777 /var/lib/tftpboot/

# Restart inet & TFTP server

    sudo service openbsd-inetd restart
    sudo service tftpd-hpa restart
    
    Check status with "netstat -lu"
    
    Expected output:
    Proto Recv-Q Send-Q Local Address           Foreign Address         State
    udp        0      0 *:tftp                  *:*                          

### Put files in the TFTP root path ###

Put the corresponding files into TFTP root directory, they are:




### Setup NFS server on Ubuntu ###
# Install NFS server package
        
    sudo apt-get install nfs-kernel-server nfs-common portmap
                
# Modify configure file /etc/exports for NFS server

    Add following contents at the end of this file.
                      
    </rootnfs> *(rw,sync,no_root_squash)
                                    
    Note: </rootnfs> is your real shared directory of rootfs of distributions for NFS server.

# Uncompress a distribution to </rootnfs>

    To get them, please refer to Distributions_Guider.txt

# Restart NFS service
    

    sudo service nfs-kernel-server restart




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值