网络安装ubuntu

来源:互联网 发布:工业企业数据库2014 编辑:程序博客网 时间:2024/05/22 13:15

网络安装操作系统需要以下环境支持:

1、  可以从网络启动的网卡,支持 PXE(Pre-boot Execution Environment)

2、  Dhcp服务:用来给客户机分配IP地址

3、  Tftp服务:用来下载操作系统安装程序的引导程序,它依赖xinetd

4、  http服务或者ftp服务:用来为客户端提供操作系统文件

 

网络安装操作系统原理:

客户端开机,由网卡从网络上DHCP服务器上得到IP地址。

通过网络安装Linux系统
=======================================================
Clinet                            Server
    client
网卡启动pxe程序请求ip地址 ->
    <- server
提供IP地址和bootloader的位置

    client
启动tftpserver获取bootloader ->
    <- server
提供 bootloader文件
pxelinux.0
    client
需要pxelinux.0的参数文件
->
    <- server
提供/pxelinux.cfg/default参数文件

    client
需要linux内核文件vmlinux
    <- server
提供内核启动文件,还有linuxks文件
    ks
文件中配置要nfs://x.x.x.x/iso找安装镜像文件 ->
    <- server
提供 nfs服务,让客户端安装

    client
开始拷贝nfs的镜像并安装

 

1、  加载光盘

mount  /dev/sd3  /media

 

mount 光盘镜像文件

# mkdir -p /media/owlinux36

# mount -t iso9660 /root/OWLinux-3.6-U1.iso /media/owlinux36 -o loop

验证是否成功# cd /media/owlinux36 && ls

 

2、  DHCP服务配置:

sudo apt-get install isc-dhcp-server


vim/etc/default/isc-dhcp-server

#改为对应网卡 ,只响应此网卡上的 dhcp 请求
INTERFACES="eth0"

 sudo vi /etc/dhcp/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

#allow boot from network use PXE
allow booting;
allow bootp;

subnet192.168.95.0netmask255.255.255.0{

#--- default gateway

option routers192.168.95.1;

option subnet-mask255.255.255.0;

option nis-domain"alrise.org";

option domain-name"alrise.org";

option domain-name-servers192.168.95.1;

option time-offset -18000;#Eastern Standard Time

#option ntp-servers 192.168.1.1;

#option netbios-name-servers 192.168.1.1;

#--- Selects point-to-point node (default is hybrid). Don't change this unless

#-- you understand Netbios very well

#option netbios-node-type 2;

range dynamic-bootp192.168.95.192 192.168.95.254;

default-lease-time 21600;

max-lease-time 43200;

#next-server is the tftp server.
#filename is boot image file under tftp root

next-server 192.168.95.1;

filename "pxelinux.0";

#we want the nameserver to appear at a fixed address

host ns {

next-server marvin.redhat.com;

hardware ethernet 12:34:56:78:AB:CD;

fixed-address 207.175.42.254;

}

}


启动:

sudo service isc-dhcp-server restart


3、  TFTP服务器配置:

apt-get install xinetd

apt-get install tftp tftpd

tftpd是服务器端程序;tftp是客户端程序

1.安装tftpd: 

$ sudo apt-get install xinetd tftpd tftp

2.xinetd程序启动:

创建/etc/xinetd.d/tftp,并添加如下内容:

service tftp

{

protocol = udp

port = 69

socket_type = dgram

wait = yes

user = nobody

server = /usr/sbin/in.tftpd

server_args = /media/install/netboot    #ubuntu操作系统光盘提供的从网络安装的启动引导程序位置

disable = no

}

3./media/install/netboot 是前面挂载的光盘文件,这个netboot是操作系统提供的从网络安装的启动引导程序。

4.

$ sudo service xinetd start

1.设置文件可读权限。如果也设置过了,就不用设置了。

$ sudo chmod -R +r/media/install/netboot

$ sudo chown -R nobody/media/install/netboot

 

备注:

上面的实现方法在ubuntu12中没有走通。安装tftp-hpa后,就启动了下面服务。

/usr/sbin/in.tftpd --listen --user tftp --address 0.0.0.0:69 --secure /var/lib/tftpboot

/var/lib/tftpboot:为默认的路径,所以需要把网络引导程序复制到它下面:

cp -R /media/install/netboot/* /var/lib/tftpboot

 

验证:

root@a:/home# tftp 127.0.0.1

tftp> get pxelinux.0

tftp> q

root@a:/home# ls -l

总用量 28

-rw-r--r-- 1 root root 26461 10 27 19:49 pxelinux.0

 

4、  HTTP服务器配置:

apt-get install apach2

 

配置配置文件httpd.conf

Alias /ubuntu /media

<Directory "/media">

    #

    # Possible values for the Options directive are "None", "All",

    # or any combination of:

    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

    #

    # Note that "MultiViews" must be named *explicitly* --- "Options All"

    # doesn't give it to you.

    #

    # The Options directive is both complicated and important.  Please see

    # http://httpd.apache.org/docs/trunk/mod/core.html#options

    # for more information.

    #

    Options Indexes FollowSymLinks

 

    #

    # AllowOverride controls what directives may be placed in .htaccess files.

    # It can be "All", "None", or any combination of the keywords:

    #   Options FileInfo AuthConfig Limit

    #

    AllowOverride None

 

    #

    # Controls who can get stuff from this server.

    #

    Require all granted

</Directory>

 

重启httpd服务

apachctl restart

 

用浏览器访问http://127.0.0.1/ubuntu/md5sum.txt

 

 

参考:

http://blog.csdn.net/huzhenwei/article/details/3447866