一、 设置本地光盘为YUM源
[root@server ~]# ll /dev |grep cdrom
lrwxrwxrwx 1 root root 3 May 31 00:52 cdrom -> hdc
lrwxrwxrwx 1 root root 3 May 31 00:52 cdrom-hdc -> hdc
查看得知光盘对应设备为:/dev/hdc
[root@server ~]# mkdir /mnt/cdrom #建立光盘挂载目录
[root@server ~]# echo "/dev/hdc /mnt/cdrom iso9660 defaults 0 0" >> /etc/fstab
#在/etc/fstab下追加光盘自动挂载信息
[root@server ~]# vim /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/home /home ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda5 swap swap defaults 0 0
/dev/hdc /mnt/cdrom iso9660 defaults 0 0
[root@server ~]# mount –a #执行挂载命令
[root@server ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda3 on /home type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt/cdrom type iso9660 (ro)
[root@server ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/server.repo
#拷贝一份yum配置模板server.repo
[root@server ~]# vim /etc/yum.repos.d/server.repo
[core] #设置名称为core,后面配置sytem-config-kickstart时才能看到软件包的选取界面
name=Red Hat Enterprise Linux
baseurl=file:///mnt/cdrom/Server
enabled=1 #启用yum源
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@server ~]# yum list #查看yum源可用配置成功
二、 设置nfs共享
[root@server ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 854 6755332+ 83 Linux
/dev/sda3 855 985 1052257+ 83 Linux
/dev/sda4 986 1305 2570400 5 Extended
/dev/sda5 986 1050 522081 82 Linux swap / Solaris
Disk /dev/sdb: 5368 MB, 5368709120 bytes #查看到本地还有一块硬盘/dev/sdb
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
[root@server ~]# fdisk /dev/sdb #利用fdisk命令对sdb硬盘进行分区
Command (m for help): n #新建分区
Command action
e extended
p primary partition (1-4)
p #新建一个主分区
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): + 4000m #新建 4G 左右分区
Command (m for help): w #保存配置
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@server ~]# partprobe #激活分区
Warning: Unable to open /dev/hdc read-write (Read-only file system). /dev/hdc has been opened read-only.
[root@server ~]#fdisk -l
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 487 3911796 83 Linux
#fdisk –l查看到新建分区为/dev/sdb1
[root@server ~]# mkfs.ext3 /dev/sdb1 #格式化分区
[root@server ~]# mkdir /kickstart #建立新分区的挂载目录
[root@server ~]# echo "/dev/sdb1 /kickstart ext3 defaults 0 0" >> /etc/fstab
[root@server ~]# mount -a
[root@server ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 6.3G 2.7G 3.4G 44% /
/dev/sda3 996M 34M 911M 4% /home
/dev/sda1 99M 12M 83M 12% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hdc 2.9G 2.9G 0 100% /mnt/cdrom
/dev/sdb1 3.7G 72M 3.5G 3% /kickstart #看到已经成功挂载新分区/dev/sdb1
[root@server ~]# ls /kickstart/
lost+found
[root@server ~]# cd /mnt/cdrom/
[root@server cdrom]# cp -r ./* /kickstart #拷贝/mnt/cdrom下所有文件到/kickstart
[root@server cdrom]# echo "/kickstart *(rw,sync)" > /etc/exports #设置nfs共享
[root@server cdrom]# service portmap restart #启动portmap服务
Stopping portmap: [ OK ]
Starting portmap: [ OK ]
[root@server cdrom]# service nfs start #启动nfs服务
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@server cdrom]# chkconfig portmap on
[root@server cdrom]# chkconfig nfs on
[root@server cdrom]# showmount –e #查看nfs共享
Export list for server:
/kickstart *
三、安装相应程序
[root@server ~]# yum -y install tftp dhcp system-config-kickstart
#yum安装tftp、dhcp、kickstart程序
四、拷贝无人职守安装系统所需文件
[root@server ~]# cp /mnt/cdrom/isolinux/vmlinuz /tftpboot/ #拷贝光盘中vmlinuz到/tftpboot下
[root@server ~]# cp /mnt/cdrom/isolinux/initrd.img /tftpboot/ #拷贝光盘中initrd.img到/tftpboot下
[root@server ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/ #拷贝本地pxelinux.0到/tftpboot下
[root@server ~]# mkdir /tftpboot/pxelinux.cfg
[root@server ~]# cp /mnt/cdrom/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
#拷贝光盘中isolinux.cfg到/tftpboot/pxelinux.cfg目录下的default文件
五、配置tftp
[root@server ~]# vim /etc/xinetd.d/tftp #tfpt配置文件
# 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
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no #将此处的yes改为no即可
per_source = 11
cps = 100 2
flags = IPv4
}
[root@server ~]# service xinetd restart #启动xinetd服务
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@server ~]# chkconfig xinetd on
六、配置dhcp
[root@server ~]# cp /usr/share/doc/dhcp- 3.0.5 /dhcpd.conf.sample /etc/dhcpd.conf
#拷贝dhcp配置文件模板到/etc下
[root@server ~]# vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 { #修改网段为本机所在的网段
filename "/pxelinux.0"; #新添加内容
next-server 192.168.1.20; #新添加内容,指定dhcp服务器
# --- default gateway
option routers 192.168.1.20; #ip改dhcp服务器ip
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.20; #ip改dhcp服务器ip
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-bootp 192.168.1.100 192.168.1.200; #设定dhcp地址池
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;
}
}
[root@server ~]# service dhcpd start #启动dhcpd服务
Starting dhcpd: [ OK ]
[root@server ~]# chkconfig dhcpd on
七、配置default文件和生成ks.cfg文件
[root@server ~]# vim /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 6 #更改超时时间
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append ks=nfs:192.168.1.20:/kickstart/ks.cfg initrd=initrd.img #添加ks.cfg文件位置
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
[root@server ~]#system-config-kickstart #生成ks.cfg文件
设置时区语言等:
设置安装方式:
进行分区设置,一定要选择“clear master boot record”和“remove all existing partitions”两项,要不安装时会出现提示,这样就不是无人职守安装了
设置网卡eth0为dhcp
禁用防火墙,保留selinux
设置x window信息
选择要安装的软件包,在前面yum设置时server.repo里yum名称要写成
core要不此处不会有包选择显示
点击file进行保存即可,ks.cfg保存到/root下
[root@server ~]# vim ks.cfg
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
key –-skip #打开ks.cfg后添加此行,跳过key,不然安装时会有输入key的提示
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# Installation logging level
logging --level=info
# Use NFS installation media
nfs --server=192.168.1.20 --dir=/kickstart
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$xEOa51li$LzKNsjIC87B4gDbnOZykg0
# SELinux configuration
selinux --enforcing
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --defaultdesktop=GNOME --depth=32 --resolution=800x600 --startxonboot
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=200
part swap --bytes-per-inode=4096 --fstype="swap" --size=512
part /home --bytes-per-inode=4096 --fstype="ext3" --size=1024
part / --bytes-per-inode=4096 --fstype="ext3" --size=6000
%packages
@gnome-software-development
@base-x
@gnome-desktop
@development-libs
@development-tools
@x-software-development
@admin-tools
@legacy-software-development
@system-tools
@server-cfg
@ruby
@chinese-support
@printing
@java-development
@text-internet
@graphical-internet
@editors
@java
[root@server ~]# cp ks.cfg /kickstart/ #将ks.cfg文件拷贝到nfs共享目录中即/kickstart
kickstart+nfs+tftp+dhcp无人值守安装rhel5.5.doc
http://down.51cto.com/data/223652