定制CentOS 5.6精简的自动安装版与心得

本文发布时间: 2019-Mar-22
工作中有客户设备放在外地机房托管,有时候需要重新安装系统,让机房值班人员帮忙安装,这个方式让自己觉得比自己来安装都累,关键是有些东西在电话里说不清楚,所以就想到做一套完全自动安装系统的光盘出来给机房邮寄过去,这样下回再有设备需要安装系统就省事多了。话不多说,接下来开始:1.首先按照客户的安装要求安装一遍centos,可以在vmware workstation环境中实现,本文就是在虚拟机里做的测试。2.安装制作发行版所需的基本软件包yum –y install createrepo mkisofs isomd5sum3.生成安装系统所需的rpm文件列表awk '/Installing/{print $2}' install.log |sed 's/^[0-9]*://g' >/root/packages.list4.创建定制工作目录mkdir -p /mnt/cdrommkdir -p /data/OSmount /dev/cdrom /mnt/cdromrsync -a --exclude=CentOS /mnt/cdrom/* /data/OS/mkdir /data/OS/CentOS5.复制精简后的RPM包vi /data/cprpms.sh#创建自动复制RPM包脚本#!/bin/bash DEBUG=0 CentOS_DVD=/mnt/cdrom ALL_RPMS_DIR=/mnt/cdrom/CentOS #源光盘RPM包存放的目录 KOS_RPMS_DIR=/data/OS/CentOS #精简后RPM包存放的目录 packages_list=/root/packages.list #精简后的RPM包列表 number_of_packages=`cat $packages_list | wc -l` i=1 while [ $i -le $number_of_packages ] ; do line=`head -n $i $packages_list | tail -n -1` name=`echo $line | awk '{print $1}'` version=`echo $line | awk '{print $3}' | cut -f 2 -d :` if [ $DEBUG -eq "1" ] ; then echo $i: $line echo $name echo $version fi if [ $DEBUG -eq "1" ] ; then ls $ALL_RPMS_DIR/$name-$version* if [ $? -ne 0 ] ; then echo "cp $ALL_RPMS_DIR/$name-$version* " fi else echo "cp $ALL_RPMS_DIR/$name-$version* $KOS_RPMS_DIR/" cp $ALL_RPMS_DIR/$name-$version* $KOS_RPMS_DIR/ # in case the copy failed if [ $? -ne 0 ] ; then echo "cp $ALL_RPMS_DIR/$name-$version* " cp $ALL_RPMS_DIR/$name* $KOS_RPMS_DIR/ fi fi i=`expr $i + 1` done执行:chmod +x cprpms.sh./cprpms.sh6.配置kickstart脚本vi /data/OS/isolinux/ks.cfg#platform=x86, AMD64, 或 Intel EM64T# System authorization informationauth --useshadow --enablemd5# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all --initlabel# Use text mode installtext# Firewall configurationfirewall --disabled# Run the Setup Agent on first bootfirstboot --disable# System keyboardkeyboard us# System languagelang en_US# Installation logging levellogging --level=info# Use CDROM installation mediacdrom# Network informationnetwork --bootproto=static --device=eth0 --gateway=192.168.1.1 --ip=192.168.1.86 --nameserver=8.8.8.8 --netmask=255.255.255.0 --onboot=on# Reboot after installationreboot#Root passwordrootpw --iscrypted $1$3k/5qcrx$Yl0uM7D/nt400cGTM4fAj.# SELinux configurationselinux --disabled# System timezonetimezone --isUtc Asia/Shanghai# Install OS instead of upgradeinstall# X Window System configuration informationxconfig --defaultdesktop=GNOME --depth=8 --resolution=640x480# Disk partitioning informationpart swap --asprimary --bytes-per-inode=4096 --fstype="swap" --ondisk=sda --size=16000part / --asprimary --bytes-per-inode=4096 --fstype="ext3" --grow --ondisk=sda --size=1%packages@base@development-tools@development-libs@editors7.生成comps.xmlcd /data/OScreaterepo –g repodata/comps.xml /data/OS/8.让系统从kickstart配置启动安装vi /data/OS/isolinux/isolinux.cfgdefault auto#prompt 1timeout 600display boot.msgmenu background splash.jpgmenu title Welcome to CentOS 5.6!menu color border 0 #ffffffff #00000000menu color sel 7 #ffffffff #ff000000menu color title 0 #ffffffff #00000000menu color tabmsg 0 #ffffffff #00000000menu color unsel 0 #ffffffff #00000000menu color hotsel 0 #ff000000 #ffffffffmenu color hotkey 7 #ffffffff #ff000000menu color scrollbar 0 #ffffffff #00000000label autokernel vmlinuzappend ks=cdrom:/isolinux/ks.cfg initrd=initrd.imglabel linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append initrd=initrd.imglabel vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img xdriver=vesa nomodesetlabel rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescuelabel local menu label Boot from ^local drive localboot 0xfffflabel memtest86 menu label ^Memory test kernel memtest append -9.生成comps.xml 解决安装包的依赖关系。cd /data/OScreaterepo –g repodata/comps.xml /data/OS/10.生成ISO镜像cd /data/OSdeclare -x discinfo=`head -1 .discinfo`***若执行上条命令出错,提示找不到.discinfo这个文件,可能在之前复制光盘过程没能把这个文件复制过来,所以需要执行一下命令,将这个文件从光盘根目录下复制过来。***#cd /mnt/cdrom/#ls –a# cp /mnt/cdrom/.discinfo /data/OS/# cp /mnt/cdrom/.treeinfo /data/OS/然后再执行那条命令就可以了。createrepo -u "media://$discinfo" -g repodata/comps.xml /data/OS/mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot -allow-leading-dots -no-bak -o /data/centos5.6x64_shengda.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /data/OS10.生成MD5检验码/usr/bin/md5sum /data/centos5.6x64_shengda.iso至此整个制作过程完毕。


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:11pm
栏目列表