linux 定制

转载至http://luyafei.blog.51cto.com/1092421/1131532

测试环境:

VMware Workstation 8.0

CentOS 6.7 x86_64

1.安装所需的软件包:
[root@localhost ~]# yum -y install createrepo mkisofs isomd5sum

2.根据当前系统已安装的软件包生成安装系统所需要的rpm列表
[root@localhost ~]# awk '/Installing/{print $2}' install.log |sed 's/^[0-9]*://g' >/root/packages.list

3.建立定制所需要的目录并把除Packages目录以外的文件复制到新的系统目录

[root@localhost ~]# mkdir  /mnt/cdrom
[root@localhost ~]# mkdir -p /data/OS
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
[root@localhost ~]# rsync -a --exclude=Packages /mnt/cdrom/ /data/OS/ 
[root@localhost ~]# mkdir /data/OS/Packages

4.使用脚本自动复制所需要的RPM包到新建立的光盘目录中Packages

[root@localhost ~]# vim cprpms.sh

 

    #!/bin/bash   
    SRC_RPMS=/mnt/cdrom/Packages      
    DST_RPMS=/data/OS/Packages      
    packages_list=/root/packages.list  
    number_of_packages=`cat $packages_list | wc -l`  
    i=1  
    while [ $i -le $number_of_packages ] ;  
     do  
        name=`head -n $i $packages_list | tail -n -1`  
             echo "cp $SRC_RPMS/$name* $DST_RPMS/"   
             cp $SRC_RPMS/$name* $DST_RPMS/          
        i=`expr $i + 1`  
    done 

 

 [root@localhost ~]# sh cprpms.sh

5.配置kickstart脚本
[root@localhost ~]# vim /data/OS/isolinux/ks.cfg

 

#platform=x86, AMD64, or Intel EM64T  
# Firewall configuration  
firewall --disabled  
# Install OS instead of upgrade  
install  
# Use CDROM installation media  
cdrom  
# Root password default is "redhat"  
rootpw --iscrypted $1$JJuQiyTA$fbBF2fBqHB1P5PpFNy5f.1
# System authorization information  
auth  --useshadow  --passalgo=md5 
# Use text mode install  
text  
firstboot --disable  
# System keyboard  
keyboard us  
# System language  
lang en_US  
# SELinux configuration  
selinux --disabled  
# Do not configure the X Window System  
skipx  
# Installation logging level  
logging --level=info 
# Reboot after installation  
reboot  
# System timezone  
timezone  Asia/Shanghai  
# Network information  
network  --bootproto=dhcp --device=eth0 --onboot=on –noipv6  
# System bootloader configuration  
bootloader --location=mbr 
# Clear the Master Boot Record  
zerombr  
# Partition clearing information  
clearpart --all --initlabel  
# Disk partitioning information  
ignoredisk --only-use=sda
part /boot --fstype="ext4" --size=1024 
part swap --recommended
part / --fstype="ext4" --grow --size=1 
%packages
@additional-devel
@base
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@desktop-platform-devel
@development
@directory-client
@eclipse
@emacs
@fonts
@general-desktop
@graphical-admin-tools
@graphics
@input-methods
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@performance
@perl-runtime
@print-client
@remote-desktop-clients
@server-platform
@server-platform-devel
@server-policy
@tex
@technical-writing
@virtualization
@virtualization-client
@virtualization-platform
@workstation-policy
@x11
libgcrypt-devel
libXinerama-devel
openmotif-devel
libXmu-devel
xorg-x11-proto-devel
startup-notification-devel
libgnomeui-devel
libbonobo-devel
junit
libXau-devel
libXrandr-devel
popt-devel
gnome-python2-desktop
libdrm-devel
libxslt-devel
libglade2-devel
gnutls-devel
mtools
pax
python-dmidecode
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
systemtap-client
abrt-gui
desktop-file-utils
ant
rpmdevtools
jpackage-utils
rpmlint
samba-winbind
certmonger
pam_krb5
krb5-workstation
netpbm-progs
openmotif
libXmu
libXp
perl-DBD-SQLite
libvirt-java
%end

 

 6.让系统从kickstart配置启动安装
[root@localhost OS]# vim /data/OS/isolinux/isolinux.cfg   #备注这里需要给执行权限,才可以编辑,默认只读;

 

default ks
prompt 1
timeout 60
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
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

 

 7.生成rpm包的依赖关系
[root@localhost ~]# cd /data/OS/
[root@localhost OS]# createrepo -g repodata/*-comps.xml /data/OS/
[root@localhost OS]# declare -x discinfo=`head -1 .discinfo`
[root@localhost OS]# createrepo -u "media://$discinfo" -g repodata/*-comps.xml /data/OS/

8.生成ISO镜像文件
[root@localhost ~]# cd /data/OS/
[root@localhost OS]# mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot \
 -allow-leading-dots -no-bak -o /data/CentOS-6.7-x86_64.iso \
 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
 -boot-load-size 4 -boot-info-table /data/OS

9.生成MD5校验码
[root@localhost ~]# implantisomd5 /data/CentOS-6.3-x86_64.iso

10.测试

如果安装提示“unable to read group information from repositories。This is problem with the generation of your install tree.” 是没生产MD5效验码,也就是忘记执行博文的第9步操作;

 

posted @ 2017-05-29 17:09  KaShing  阅读(2087)  评论(0编辑  收藏  举报