网络安装ubuntu10.04.3tls 需要客户端机器支持pxe启动
dhcp+tftp-hpa+apache2+kickstart
我的环境
dhcp服务器192.168.0.1 用现有的 下面是一部分配置
47 # tbq测试机
48 host tbqtest {
49 #tbq增加的-----------------------------
50 allow booting;
51 allow bootp;
52 #tbq增加的-----------------------------
53 hardware ethernet 6C:62:6D:DE:94:BA;
54 fixed-address 192.168.0.100;
55 next-server 192.168.0.99;
56 filename "pxelinux.0";
57 }
安装源192.168.0.99
tbq@tbq:~/www/iso$ cat /etc/issue
Ubuntu 10.04.3 LTS \n \l
tftp安装配置
安装sudo apt-get install tftpd-hpa tftp-hpa
基本配置
sudo vi /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot" #tftp主目录
TFTP_ADDRESS="0.0.0.0:69"
#TFTP_OPTIONS="--secure"
TFTP_OPTIONS="-l -s"
#TFTP_OPTIONS="-l -c -s" #c表示可以put
启动状态
sudo /etc/init.d/tftpd-hpa status
tbq@tbq:/var/lib/tftpboot$ ps afx | grep ftp
9792 ? Ss 0:00 /usr/sbin/in.tftpd --listen --user tftp --address 0.0.0.0:69 -l -s /var/lib/tftpboot
ps:不知咋验证,感觉还是pure-ftpd 配合mysql验证好用
apache2配置
httpd.conf配置
Options ExecCGI Indexes
Order allow,deny
Allow from all
可以看到
Index of /iso- Parent Directory
- .disk/
- README.diskdefines
- cdromupgrade
- dists/
- doc/
- install/
- isolinux/
- md5sum.txt
- pics/
- pool/
- preseed/
sudo mkdir /usr/local/apache2/htdocs/iso
直接挂载镜像文件
tbq@tbq:~/www/iso$ sudo mount -o loop /D/iso/ubuntu-10.04.3-server-amd64.iso /usr/local/apache2/htdocs/iso/
tbq@tbq:/usr/local/apache2/htdocs/iso$ ll
总用量 160
-r-xr-xr-x 1 root root 1115 2010-04-24 10:29 cdromupgrade
dr-xr-xr-x 3 root root 2048 2011-07-20 04:03 dists
dr-xr-xr-x 3 root root 2048 2011-07-20 04:03 doc
dr-xr-xr-x 3 root root 2048 2011-07-20 04:04 install
dr-xr-xr-x 2 root root 16384 2011-07-20 04:04 isolinux
-r--r--r-- 1 root root 132170 2011-07-20 04:04 md5sum.txt
dr-xr-xr-x 2 root root 2048 2011-07-20 04:03 pics
dr-xr-xr-x 3 root root 2048 2011-07-20 04:03 pool
dr-xr-xr-x 2 root root 2048 2011-07-20 04:03 preseed
-r--r--r-- 1 root root 237 2011-07-20 04:03 README.diskdefines
lr-xr-xr-x 1 root root 1 2011-07-20 04:03 ubuntu -> .
有时候如果提示找不到镜像可以按alt+f2切到终端看日志
一般是缺
tbq@tbq:/usr/local/apache2/htdocs/iso$ ll dists/unstable/Release
-r--r--r-- 1 root root 3036 2011-07-20 04:04 dists/unstable/Release
出现在win下解压iso,因为是符号链接
复制下面的到/var/lib/tftpboot
tbq@tbq:/usr/local/apache2/htdocs/iso$ ll install/netboot/
总用量 3
lr-xr-xr-x 1 root root 33 2011-07-20 04:04 pxelinux.0 -> ubuntu-installer/amd64/pxelinux.0
lr-xr-xr-x 1 root root 35 2011-07-20 04:04 pxelinux.cfg -> ubuntu-installer/amd64/pxelinux.cfg
dr-xr-xr-x 3 root root 2048 2011-07-15 19:14 ubuntu-installer
-r--r--r-- 1 root root 58 2011-07-15 19:20 version.info
tbq@tbq:/var/lib/tftpboot$ ll
总用量 0
lrwxrwxrwx 1 tbq tbq 33 2011-08-26 10:38 pxelinux.0 -> ubuntu-installer/amd64/pxelinux.0
lrwxrwxrwx 1 tbq tbq 36 2011-08-26 10:38 pxelinux.cfg -> ubuntu-installer/amd64/pxelinux.cfg/
drwxrwxrwx 3 tbq tbq 72 2011-08-26 11:42 ubuntu-installer
至此可以网络安装了
安装的时候更新源选手动输入192.168.0.99 目录改成iso 根据自己配置的修改
接下来我弄弄自动安装
先要安装kickstart
sudo apt-get install system-config-kickstart
在 “应用程序\系统工具”中打开kickstart 可以图形配置
配置:
修改启动文件
tbq@tbq:/var/lib/tftpboot/ubuntu-installer/amd64/boot-screens$ vi text.cfg
default install
label install
menu label ^Install
menu default
kernel ubuntu-installer/amd64/linux
append ks=ks.cfg vga=normal initrd=ubuntu-installer/amd64/initrd.gz -- quiet
label cli
menu label ^Command-line install
kernel ubuntu-installer/amd64/linux
append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=normal initrd=ubuntu-installer/amd64/initrd.gz -- quiet
红色字体是增加的部分
再通过网卡启动安装即可
接下来看看怎么配置ks.cfg选择安装的软件包(失败了,不知道怎么选)
下面是我用的ks.cfg配置
- #Generated by Kickstart Configurator
-
#platform=AMD64 or Intel EM64T
-
-
#System language
-
lang zh_CN
-
#Language modules to install
-
langsupport zh_CN
-
#System keyboard
-
keyboard cn
-
#System mouse
-
mouse
-
#System timezone
-
timezone Asia/Shanghai
-
#Root password
-
rootpw --disabled
-
#Initial user
-
user tbq --fullname "" --iscrypted --password $1$dOvDCvQA$5Qp6xqhts6NLs30bB9WCX0
-
#Reboot after installation
-
reboot
-
#Use text mode install
-
text
-
#Install OS instead of upgrade
-
install
-
#Use Web installation
-
url --url
-
#System bootloader configuration
-
bootloader --location=mbr
-
#Clear the Master Boot Record
-
zerombr yes
-
#Partition clearing information
-
clearpart --all --initlabel
-
#Disk partitioning information
-
part swap --size 2048
-
part /boot --fstype ext4 --size 200
-
part /home --fstype ext4 --size 256000
-
part / --fstype ext4 --size 1 --grow
-
#System authorization infomation
-
auth --useshadow --enablemd5
-
#Network information
-
#network --bootproto=dhcp --device=eth0
-
#network --hostname=ubuntu
-
#Firewall configuration
-
firewall --disabled --ssh
-
#Do not configure the X Window System
-
skipx
-
#%packages
-
#@ssh
-
#@gcc
-
#@g++
-
#上面这几个就是软件包,但是我不知道应该叫什么,乱写的,失败了所以注释掉
-
%post --interpreter=/bin/sh
-
-
mkdir -p /home/src
-
cd /home/src
-
echo 'start' >> tbq.txt
-
date > tbq.txt
-
#get一个初始化脚本,实现最基本的自动配置
-
wget src/initialize.sh
-
chmod a+x initialize.sh
-
./initialize.sh
-
date >> tbq.txt
-
echo 'end' >> tbq.txt
再看看initialize.sh脚本
- #!/bin/sh
-
-
#同步时间
-
ntpdate time.nist.gov > /dev/null
-
- #测试代码
- #pwd >> tbq1.txt
- #id >> tbq2.txt
- #sudo /bin/pwd >> tbq3.txt
-
-
#更新一些自己的软件
-
wget src/mysql-5.5.13-linux2.6-x86_64.tar.gz
-
#tar zxvf mysql-5.5.13-linux2.6-x86_64.tar.gz
-
#mv mysql-5.5.13-linux2.6-x86_64 /usr/local/mysql
-
-
#更新自动更新源列表
-
wget src/sources.list
-
cp sources.list /etc/apt/
-
#更新必要的一些软件
-
apt-get update
-
apt-get -y install openssh-server
-
apt-get -y install mysql-server
-
apt-get -y install apache2
-
apt-get -y install php5
-
apt-get -y install php5-mysql
-
apt-get -y install php5-gd
-
apt-get -y install subversion
-
#解决perl DBD::mysql安装 找不到mysql_config
-
apt-get -y install libmysqlclient-dev
-
apt-get -y install gcc g++
-
apt-get -y install vim
-
#sudo apt-get -y install samba #装整个超级慢 是网速问题 不知道为什么不从我自己的源安装
-
-
#更新系统一些东西
-
echo 'kernel.shmmax = 536870912' >> /etc/sysctl.conf
-
-
#修改apache2配置
-
echo 'ServerName tt' > /etc/apache2/httpd.conf
-
sed -i '/php_admin_value engine Off/s/php_admin_value engine Off/#php_admin_value engine Off/' /etc/apache2/mods-enabled/php5.conf
-
sed -i 's/webmaster@localhost/tbq@xxx.net/ ; /ScriptAlias/s/^/#/ ; /Directory/s/\/usr\/lib\/cgi-bin/\/var\/www\//' /etc/apache2/sites-enabled/000-default
-
sed -i '/cgi-script/s/#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi .pl/' /etc/apache2/mods-available/mime.conf
-
#下载apache2测试文件
-
wget src/testpl.p
-
wget src/info.ph
-
chmoe 777 /var/www
-
mv testpl.p /var/www/testpl.pl
-
mv info.ph /var/www/info.php
-
-
-
#增加下vim的相关配置
-
echo '"tbq vimrc' >> /etc/vim/vimrc
-
echo 'set tabstop=4' >> /etc/vim/vimrc
-
echo 'set shiftwidth=4' >> /etc/vim/vimrc
-
echo 'set softtabstop=4' >> /etc/vim/vimrc
-
echo 'set showcmd' >> /etc/vim/vimrc
-
echo 'set cindent' >> /etc/vim/vimrc
-
echo 'set ruler' >> /etc/vim/vimrc
-
echo 'set hlsearch' >> /etc/vim/vimrc
-
echo '"set nobk' >> /etc/vim/vimrc
-
echo 'set fileencodings=utf8,gbk,gb2312,gb18030,big5,utf16' >> /etc/vim/vimrc
-
-
#修改主机名之类的
-
echo 'tt' > /etc/hostname
-
sed -i '/127.0.0.1/s/kickseed/localhost/g' /etc/hosts
-
sed -i '/127.0.1.1/s/kickseed/tt/g' /etc/hosts
-
sed -i '/127.0.1.1/s/localhost/tt/g' /etc/hosts
-
sed -i 's/22/9922/' /etc/ssh/sshd_config
-
-
#锁定root
-
passwd -l root
还可以再智能点呵呵以后再写
阅读(2194) | 评论(0) | 转发(0) |