linux无人值守安装实验,linux 无人值守安装

linux 无人值守安装

(整理日期:2010-1-15)

作用:

1、可以解决大批量的快速安装问题;

2、解决要安装的机器上没有光驱或没有相应的安装光盘的问题;

3、可以解决远程安装操作系统的问题;

先决条件:

1、待安装的机器需要在一个网络之中;

2、待安装的机器的网卡需要支持PXE引导模式;

3、需要有DHCP服务器和tftp服务器;

4、要有linux安装光盘的镜像文件或安装文件;

实施步骤:

1、安装DHCP服务器,具体的方法是:

1)rpm –ihv dhcp-3.0.1-12_EL.i386.rpm

然后修改和设置配置文件:

#cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample/etc/dhcpd.conf

# vi/etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

# --- default gateway

option routers                  192.168.0.1;

option subnet-mask              255.255.255.0;

option nis-domain               "domain.org";

option domain-name              "domain.org";

option domain-name-servers      192.168.1.1;

option time-offset              -18000; # Eastern Standard Time

next-server 192.168.0.1;

filename "/pxelinux.0";

#       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-bootp 192.168.0.128 192.168.0.254;

default-lease-time 21600;

max-lease-time 43200;

# 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;

}

}

上面的记录可以根据需要修改,但是红色部分是需要添加的,其中:

next-server:用来指定tftp服务器的地址

filename "/pxelinux.0";指定通过PXE启动时所需要引导文件。

2.当在待安装的机器所在的网络中有现成的windows系统组成的DHCP服务器时,也可以直接用这个DHCP服务器,操作方法是:

在“作用域选项”-》“配置选项”-》选中066和067在066“启动服务器主机名”输入TFTP服务器的名字或IP地址,而在067的“启动文件名”中填上启动的文件名/pxelinux.0实际测试时就是用这种办法的。

3.安装配置TFTP服务器

a.直接通过rpm包安装,rpm–ihv tftp-0.39-1.i386.rpm  rpm tftp-server-0.39-1.i386.rpm

# vi /etc/xinted.d/tftp

将disable =yes修改成disable=no

然后重启xinted服务service xinted restart。然后在根目录下会建立一个/tftpboot目录。

b. 将/usr/lib/syslinux/pxelinux.0文件拷到/tftpboot下面,这里用来支持网络启动的文件。

# cp /usr/lib/syslinux/pxelinux.0 /tftpboot

c. 在/tftpboot下面建立一个pxelinux.cfg目录,并将redhat第一张光盘下的isolinux/isolinux.cfg拷贝到/tftpboot/pxelinux.cfg/default文件

# cp /iso/isolinux/isolinux.cfg/tftpboot/pxelinux.cfg/default

修改/tftpboot/pxelinux.cfg/default文件

default linux

prompt 1

timeout 600

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

F7 snake.msg

F8 list.msg

label linux

kernel vmlinuz

append initrd=initrd.img ramdisk_size=8192

label text

kernel vmlinuz

append initrd=initrd.img text ramdisk_size=8192

label expert

kernel vmlinuz

append expert initrd=initrd.img ramdisk_size=8192

label ks

kernel vmlinuz

append ks initrd=initrd.img ramdisk_size=8192

label lowres

kernel vmlinuz

append initrd=initrd.img lowres ramdisk_size=8192

label local

localboot 1

label memtest86

kernel memtest

append -

label autoinstall

kernel vmlinuz

append ks=nfs:192.168.1.4:/jongo/os/ks.cfg ksdevice=eth0 initrd=initrda.img ramdisk_size=8192

其它的根据需要修改,但是需要注意的是红色部是需要添加的。

将第一张光盘上的images/pxeboot下的initrd.img和initrd.img拷贝到/tftpboot目录下面,用于网络引导系统

# cp /iso/images/pxeboot/initrd.img /tftpboot

# cp /iso/images/pxeboot/vmlinuz /tftpboot

将第一张光盘下的isolinux/下面的文件都拷贝到/tftpboot目录下

# cp /iso/isolinux/* /tftpboot

4.配置nfs服务

将存放安装文件和ks.cnf文件的目录共享出去。例如这里:

# vi /etc/exports增加:

/jongo/os       *(ro,no_root_squash,sync)

重启nfs服务

# serviceportmaprestart

# service nfs restart

可以在其它机器上试图挂接一下,看看是否共享成功了

5.建立和配置ks.cnf文件

在安装好的系统的/root下面有一个anaconda-ks.cfg,可以将这个文件拷成/jongo/os/ks.cnf

# cp /root/anaconda-ks.cfg/jongo/os/ks.cnf

然后对这个文件进行修改,修改成需要的。

也可以用system-config-kickstart工具来建立这个文件。方法是安装system-config-kickstart-2.5.16-2.noarch.rpm软件包,然后在图形化的界面上运行system-config-kickstart命令,根据提示,来建立ks.cnf文件。以下本次实施时的

ks.cnf文件内容:

#Generated by Kickstart Configurator

#platform=x86, AMD64, or Intel EM64T

#System  language

lang en_US#设置系统语言

#Language modules to install

langsupport zh_CN --default=en_US#系统支持的语言

#System keyboard

keyboard us

#System mouse

mouse

#Sytem timezone

timezone --utc Asia/Shanghai#时区

#Root password

rootpw bwyy1679#root用户的密码也可以:

rootpw --iscrypted $1$B1FMlwDt$DQmaWnE/arngF0UltW5ZX1这时候密码是密文的形式。

#Reboot after installation#安装好,重启系统

reboot

#Install OS instead of upgrade#方法是全新安装

install

#Use NFS installation Media#安装介质获取的方法

nfs --server=192.168.1.4  --dir=/jongo/os/as4

#System bootloader configuration

bootloader --location=mbr

#Clear the Master Boot Record

zerombr yes

#Partition clearing information

clearpart --all –initlabel#清去磁盘所有的分区,如果是新盘,一定要添加确良—initlabe 选项,否则在安装时会有提示信息的

#Disk partitioning information#磁盘分区信息,单位是兆

part /boot --fstype ext3 --size 100

part / --fstype ext3 --size 5000

part /home --fstype ext3 --size 500

part /var --fstype ext3 --size 500

part /tmp --fstype ext3 --size 1000

part /usr --fstype ext3 --size 5000

part /usr/local --fstype ext3 --size 5000

part /opt --fstype ext3 --size 100

part swap --size 600

#System authorization infomation

auth  --useshadow  --enablemd5

#Network information#配置网卡设置

network --bootproto=static --ip=192.168.1.13 --netmask=255.255.255.0 --gateway=192.168.1.1 --nameserver=192.168.1.8 --device=eth0

#Firewall configuration#防火墙设置

firewall --enabled --trust=eth0 --http --ftp --ssh --telnet --smtp

#XWindows configuration information

xconfig --depth=24 --resolution=800x600 --defaultdesktop=GNOME --startxonboot

#Package install information

%packages –resolvedeps#要安装的软件包

@ base-x

@ gnome-desktop

@ kde-desktop

@ editors

@ engineering-and-scientific

@ graphical-internet

@ text-internet

@ office

@ sound-and-video

@ graphics

@ server-cfg

@ web-server

@ mail-server

@ smb-server

@ dns-server

@ ftp-server

@ sql-server

@ news-server

@ development-tools

@ kernel-development

@ x-software-development

@ gnome-software-development

@ kde-software-development

@ admin-tools

@ system-tools

%post#安装后以后执行的脚本或命令。如:

/usr/sbin/useradd test

6.创建安装介质的目录层次结构

a)将安装光盘的第一张中的RELEASE-NOTES*文件都拷贝到nfs的共享路径下,如:

# cp /iso/ RELEASE-NOTES*/jongo/os/as4

b)在 /jongo/os/as4下建立RedHat目录

# mkdir RedHat

然后将第一张光盘下的RedHat下的文件都拷贝到这个目录下:

# cp–au /iso/RedHat/* /jongo/os/as4/RedHat/

同时将2~4张光盘下的RedHat/RPMS下的文件都拷贝到/jongo/os/as4/RedHat/RPMS下面。如

# cp–au /iso/RedHat/RPMS/* /jongo/os/as4/RedHat/RPMS/

然后将每张光盘下的/RedHat/RPMS/TRANS.TBL文件内容都合并到/jongo/os/as4/RedHat/RPMS/TRANS.TBL里面,如:

# cat /iso/RedHat/RPMS/TRANS.TBL>>/jongo/os/as4/RedHat/RPMS/TRANS.TBL

7.实施安装

将待安装的机器的启动方式设置成网卡PXE启动模式第一顺序,然后重新开启待安装机器。安装后需要将启动顺序修改回来,以勉重复安装系统。

8.关于PXELINUX参考文档

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值