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
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | #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 #备注这里需要给执行权限,才可以编辑,默认只读;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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步操作;
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
· [翻译] 为什么 Tracebit 用 C# 开发
· Deepseek官网太卡,教你白嫖阿里云的Deepseek-R1满血版
· 2分钟学会 DeepSeek API,竟然比官方更好用!
· .NET 使用 DeepSeek R1 开发智能 AI 客户端
· 刚刚!百度搜索“换脑”引爆AI圈,正式接入DeepSeek R1满血版