linux diskless

本文详细介绍如何通过配置dnsmasq、iptables、NFS、TFTP等服务实现PXE自动安装系统的全过程,并涉及内核编译以支持必要的网络功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1, setup dnsmasq

    /etc/dnsmasq.conf

interface=eth2   // connected to the dhcp client
dhcp-range=192.168.2.50,192.168.2.150,255.255.255.0,12h
dhcp-option=3,192.168.2.1
expand-hosts
dhcp-boot=pxelinux.0,192.168.2.1,192.168.2.1  // pxelinux.0 -> yum install syslinux
enable-tftp
tftp-root=/home/tftp-root  // tftp directory, chmod 777

dhcp-host=00:1d:7d:43:90:d1,192.168.2.10  // bind the dhcp client's mac address to 192.168.2.10

2, iptable打开67,68,69端口

/etc/sysconfig/iptables

-A INPUT -m state --state NEW -m udp -p udp --dport 69 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 68 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 67 -j ACCEPT


3, setup nfs

   /etc/export

/home/tftp-root/192.168.2.10            192.168.2.1/24(insecure,rw,sync,no_root_squash,no_all_squash)

4, setup tftp setting

   /home/tftp-root:

-rwxrwxrwx  1 root root   26828 Sep  1 13:44 pxelinux.0

drwxrwxrwx  2 root root    4096 Sep  8 16:17 pxelinux.cfg

        -rw-r--r-- 1 root root 274 Sep  8 16:05 C0A8020A

               default         2.6.32
               timeout         3

               label           2.6.32
               kernel          192.168.2.10/vmlinuz
               append ip=192.168.2.10:192.168.2.1:192.168.2.1:255.255.255.0:diskless:eth0:off root=/dev/nfsroot rw enforcing=0 nfsroot=192.168.2.1:/home/tftp-root/192.168.2.10

drwxrwxrwx 13 root root    4096 Sep  8 16:32 192.168.2.10

        -rw-r--r--   1 root root 4710128 Sep  8 16:26 vmlinuz

5, compile linux kernel

Code maturity level options  --->
  [*] Prompt for development and/or incomplete code/drivers
  
Device Drivers --->
  [*] Networking support
  Networking options --->
    <*> Packet socket
    <*> Unix domain sockets
    [*] TCP/IP networking
    [*]   IP: multicasting
    [*]   IP: kernel level autoconfiguration
    [*]     IP: DHCP support (NEW)
Networking support  --->
  Networking options  --->  
  [*]   IP: kernel level autoconfiguration                      
    [*]     IP: DHCP support                      
    [*]     IP: BOOTP support  
File systems --->
  Network File Systems  --->
    <*> file system support
    [*]   Provide NFSv3 client support
    [*]   Root file system on NFS
 
* the most import things is that the device driver of dhcp client network adaptor should be include the kernel, not module.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值