快捷搜索:   nginx

网络安装 centos

这次内江需要架个smokeping,但是没有光驱和光盘,只能下载一个光盘镜像。,虽然以前过
但是我觉得还是总结一下:方便以后安装。

一、原理

无 光驱、软驱的一台服务器,想要安装Linux系统。我们需要通过网卡的PXE协议,引导之后安装Linux。流程:机器启动-网卡引导-通过DHCP获得 IP地址-通过tftp获得最基础的内核,使用该内核启动机器-启动之后可以对安装程序配置,选择使用http、ftp、nfs方式远程获得安装 所需要的软件包。

显然,网络安装是必须配置服务器端的。我们的服务端需要提供以下服务:

DHCP

TFTP

HTTP(FTP,NFS)

二、服务配置

1.DHCP

配置文件:

option domain-name "mydomain";

ddns-update-style none;

default-lease-time 600;

max-lease-time 7200;

server-name "bootserver";

subnet 192.168.123.0 netmask 255.255.255.0 {

range 192.168.123.200 192.168.123.201;

deny unknown-clients;

}

host MyP5 {

filename "pxelinux.0";

server-name "bootserver";

hardware ethernet ae:32:20:00:b0:02;

fixed-address 192.168.123.90;

}

这是复制来的配置文件,稍微解释一下:

filename 后面是tftp目录下的文件,pxelinux.0 则是 syslinux 包内的文件。默认 pxelinux.0 可能在 /usr/lib/syslinux 目录下,必须将其复制到 tftp 目录下。

host MyP5 下出现的:

hardware ethernet ae:32:20:00:b0:02;

fixed-address 192.168.123.90;

为客户机(需要安装系统的机器)的 MAC 地址和所分配的IP地址。

2.TFTP

由于必须支持TSIZE协议,所以不能安装最原始的TFTP包。我选择使用 tftp-hpa 。

编辑文件 /etc/xinetd.d/tftp (若没有,则添加tftp文件)(若不存在xinetd.d,请安装 xinetd 包)

# default: off

# description: The tftp server serves files using the trivial file transfer \

# protocol. The tftp protocol is often used to boot diskless \

# workstations, download configuration files to network-aware printers, \

# and to start the installation process for some operating systems.

service tftp

{

disable = no

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /tftpboot

per_source = 11

cps = 100 2

flags = IPv4

}

这里将 /tftpboot 定义为 tftp 服务的默认目录,您可以自行修改。

保存之后重启 /etc/init.d/xinetd 服务,即可开启 tftp 服务。

如何测试 tftp 是否成功开启?

在 tftp 目录下创建一个文件,比如 1.txt 。

在 Shell 中连接 tftp 服务:

tftp 127.0.0.1

tftp>get 1.txt

若服务成功开启,则能看到成功下载文件的提示。并在当前目录下找到1.txt文件。

接着复制光盘中 isolinux 目录下的 vmlinuz、initrd.img 文件到 /tftpboot 目录下。

在 /tftpboot 中创建文件夹 syslinux.cfg 。syslinux.cfg 中保存了 pxelinux 的两个配置文件:default、list。

default:

default linux

label linux

kernel vmlinuz

append initrd=initrd.img devfs=nomount nofb ramdisk_size=9216

三、挂载光盘镜像到目录,并使用nfs共享出来

   mount CentOS-5.1-i386-bin-DVD.iso /iso/ -o loop



下面是我的配置文件

exports

root@ubuntu-T61:/tftpboot/linux/pxelinux.cfg# cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
#        to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#/backup/asher 192.168.10.0/24(rw,sync,no_acl,no_subtree_check,no_root_squash)
/iso 192.168.10.0/24(rw,sync,no_acl,no_subtree_check,no_root_squash)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
root@ubuntu-T61:/tftpboot/linux/pxelinux.cfg#

#}
authoritative;
ddns-update-style    none;
default-lease-time    21600;
max-lease-time        43200;

subnet 192.168.10.0 netmask 255.255.255.0 {
    option routers            192.168.10.1;
    option subnet-mask        255.255.255.0;
    option domain-name-servers    192.168.10.1;
    option ntp-servers        192.168.10.1;
    option netbios-name-servers    192.168.10.1;
##########################
#    option option-128 code 128 = string;
#     option option-129 code 129 = text;
#    option option-129 "MOPTS=nolock,ro,wsize=2048,rsize=2048";
####################
    range dynamic-bootp 192.168.10.5 192.168.10.254;
    filename "linux/pxelinux.0";
    next-server 192.168.10.1;
}
group
{
        default-lease-time      -1;
        use-host-decl-names on;
        filename "linux/pxelinux.0";

}

}
root@ubuntu-T61:/tftpboot/linux/pxelinux.cfg# cat /tftpboot/linux/pxelinux.cfg/default
default linux
prompt 1
timeout 600
display /pxeboot/boot.msg
F1 /pxeboot/boot.msg
F2 /pxeboot/options.msg
F3 /pxeboot/general.msg
F4 /pxeboot/param.msg
F5 /pxeboot/rescue.msg
label linux
kernel /pxeboot/vmlinuz
append initrd=/pxeboot/initrd.img
label text
kernel /pxeboot/vmlinuz
append initrd=/pxeboot/initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论