U盘引导通过FTP自动安装CentOS操作系统

1. 制作U盘syslinux引导

这里使用syslinux-4.04.tar.gz 解压

cd /D syslinux-4.04\win32
syslinux.exe -ma H:

这时候U盘下会生成一个隐藏文件 ldlinux.sys

2. 复制CentOS启动文件到U盘

用winrar打开CentOS.iso,把isolinux文件夹拷贝到U盘,并把isolinux.cfg重命名为: syslinux.cfg. 

3. 我是用了一台windows的filezilla server当ftp的,把centos.iso(推荐用DVD版本)解压到E:\centos64,把E:\当作ftp的根目录

修改U盘syslinux文件夹下的syslinux.cfg

default linux
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img ks=nfs:192.168.10.83:/data/lnmp/ks.cfg
label text
kernel vmlinuz
append initrd=initrd.img text ks=nfs:192.168.10.83:/data/lnmp/ks.cfg
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

红颜色的文字是添加的kickstart自动安装脚本,这里我为什么用nfs,而不用放置centos文件的windows ftp服务器呢,因为实验了N次,filezilla传输文件会把ks.cfg变成windows格式,导致文档最后的%post命令无法执行.

下面贴出ks.cfg

# Kickstart file automatically generated by anaconda.

install
url --url ftp://192.168.10.78//CentOS64
lang en_US.UTF-8
keyboard us
text
network --device eth0 --bootproto static --ip 192.168.132.100 --netmask 255.255.255.0 --gateway 192.168.132.1 --nameserver 192.168.12.8 --hostname localhost
rootpw --iscrypted $1$ueR1iSzo$QLhVj0v3/NyKZXSmyP5H20
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda
reboot
firstboot --disable
# The following is the partition information you requested
#
Note that any partitions you deleted are not expressed
#
here so unless you clear all partitions first, this is
#
not guaranteed to work
#clearpart --linux
#part / --fstype ext3 --size=40960
#part swap --size=4096
#
part /data --fstype ext3 --size=1 --grow

%packages
@base
@core
@development-libs
@development-tools
@editors
@ftp-server
@system-tools
@text-internet
keyutils
trousers
fipscheck
device-mapper-multipath
imake
audit

%post --nochroot
#!/bin/bash
mkdir -p /mnt/nfs
mount -t nfs 192.168.10.83:/data/lnmp /mnt/nfs
cp /mnt/nfs/* /mnt/sysimage/tmp

%post
chkconfig acpid off
chkconfig atd off
chkconfig autofs off
chkconfig avahi-daemon off
chkconfig bluetooth off
chkconfig cups off
chkconfig firstboot off
chkconfig gpm off
chkconfig haldaemon off
chkconfig hidd off
chkconfig ip6tables off
chkconfig irqbalance off
chkconfig kudzu off
chkconfig lvm2-monitor off
chkconfig mcstrans off
chkconfig mdmonitor off
chkconfig netfs off
chkconfig nfslock off
chkconfig pcscd off
chkconfig portmap off
chkconfig rawdevices off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig sendmail off
chkconfig xfs off
chkconfig yum-updatesd off

cat>>/etc/security/limits.conf<<EOF
* soft nofile 65535
* hard nofile 65535
EOF
%post --nochroot 和 %post这两部分可以简化我们装完系统的后续配置.
分区部分我注释掉了,个人可以根据自己的分区情况修改.
这里贴出syslinux.cfg指定ks文件的语法
ks
Gives the location of the kickstart file to be used for installation. If only ks is given, the file is assumed to be on NFS. The ks parameter may take these other forms:
  • ks=cdrom:<device>
  • ks=file:<path> (path = 'fd0/ks.cfg', for example)
  • ks=ftp://<path>
  • ks=hd:<dev>:<path> (dev = 'hda1', for example)
  • ks=http://<host>/<path>
  • ks=nfs[:options]:<server>:<path>
  • ks=bd:<biosdev>:<path> (biosdev = '80p1', for example, note this does not work for BIOS RAID sets)

 再来一篇官方文档 http://www.centos.org/docs/5/html/5.2/Installation_Guide/pt-install-advanced-deployment.html

 

posted @ 2011-11-28 23:28  txwsqk  阅读(839)  评论(0编辑  收藏  举报