CentOS构建自己的发行版
来源:互联网 发布:金庸群侠传x如何删数据 编辑:程序博客网 时间:2024/04/26 18:47
-----thanks NetSeek
环境说明:CentOS 5.5-i386 + Vmware Workstation.
装好的虚拟机母系统的磁盘为一个IDE 10G,能连接互联网.
DIY CD的装机图片,GRUB图片会去掉,不要华丽,用原始。
从页面上复制脚本粘贴进LINUX后,注意DOS UNIX格式的问题,否则脚本执行会报错。可用vi -b filename查看修改。
制作好的光盘结构介绍
* isolinux 目录存放光盘启动时的安装界面信息
* images 目录包括了必要的启动映像文件
* CentOS 目录存放安装软件包及信息
* .discinfo 文件是安装价质的识别信息
* TRANS.TBL
一.制作TANK-OS具体过程
0. 在虚拟机里安装一个centos母系统。
如果做服务器版本CD的话,尽量把常用的文本界面下的工具安装上。
注意:容量问题。本次实验母系统装好后1.3G,DIY好的光盘容量560M。使制作好的容量尽量保持在一张CD容量内(<700M),方便携带安 装.
1.安装制作发行版所需的基本软件包
# yum -y install anaconda-runtime createrepo yum-utils anaconda anaconda-help busybox-anaconda mkisofs
2. 制作tank-os源文件夹
# mkdir /tank-os
# mkdir /mnt/cdrom
# mount -t iso9660 -o loop /dev/cdrom /mnt/cdrom/ 挂载光盘镜像
或者挂载ISO文件到/mnt/cdrom
# mount -t iso9660 -o loop centos.xxx.iso /mnt/cdrom 将CentOS的ISO文件挂载到/mnt/cdrom目录
# cd /mnt/cdrom
将/mnt/cdrom里的 images isolinux repodata三个目录 .discinfo TRANS.TBL两个文件拷贝到/tank-os这个目录下.
并#mkdir /tank-os/CentOS 建立存放rpm包的目录.
/tank-os/下的目录结构应如下:
[root@server tank-os]# ls -al
total 100
drwxr-xr-x 6 root root 4096 Apr 11 21:00 .
drwxr-xr-x 27 root root 4096 Apr 12 05:26 ..
drwxr-xr-x 2 root root 36864 Apr 8 16:06 CentOS //空目录
-rw-r--r-- 1 root root 97 Apr 8 16:43 .discinfo
drwxr-xr-x 4 root root 4096 Mar 21 23:04 images
drwxr-xr-x 2 root root 4096 Apr 12 00:00 isolinux
drwxr-xr-x 2 root root 4096 Apr 11 21:00 repodata
-r--r--r-- 1 root root 7048 Mar 21 23:05 TRANS.TBL
3.定制package.list软件包清单
在母系统~root目录下有安装 母系统产生的日志,/root/install.log。用脚本从中提取软件包.
#cd /root
#cat install.log | grep Installing | sed 's/Installing //g'|sed 's/^[0-9]\+://g' > packages.list
#wc -l packages.list
466 packages.list
将定制 tank-os所要的rpm复制到/tank-os/CentOS目录
#cat packages.list |while read name ;do cp -a /mnt/cdrom/CentOS/$name.rpm /tank-os/CentOS/ ;done
#cd /tank-os
#createrepo -g repodata/comps.xml . //注意最后的"."不可漏了.
4. 配置kickstart脚本
安装母系统以后,会在系统里产生一个kickstart安装脚本,/root/anaconda-ks.cfg
(就 是以后自动安装DIY系统的系统配置文件,其参数自己视情况修改,如磁盘分区容量,hostname...;当然安装时不选auto自动安装也可以选择 centos原来提供的其他安装方式自己根据提示设置.)
# cp anaconda-ks.cfg /tank-os/isolinux/ks.cfg
# vi /tank-os/isolinux/ks.cfg 自己动手修改脚本如下,不要随意复制粘贴后就执行。
# Kickstart file automatically generated by anaconda.
# Install CentOS instead of Upgrade
install
text
#install from cd-rom
cdrom
lang en_US.UTF-8
keyboard us
# Skip the X Configuration
skipx
network --device eth0 --bootproto dhcp --hostname tank-os.test.org
rootpw tank-os #如果去掉该行,安装时提示输入ROOT密码。
# Setup the firewall with SSH, HTTP/S, Syslog, Webmin, and Netflow enabled
firewall --enabled --port=22:tcp --port=80:tcp --port=443:tcp
authconfig --enableshadow --enablemd5
# Disable SELinux
selinux --disabled
timezone --utc Asia/Shanghai
# Clear the Bootloader and load it to the Master Boot Record
bootloader --location=mbr
zerombr yes
# Set the Mouse
mouse generic3ps/2
# 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 --all --initlabel
#如果没有下面的分区设置,安装时会有默认分区,当然也可以自行设置。
part /boot --fstype ext3 --size=100 --asprimary
part / --fstype ext3 --size=6000
part swap --size=512
part /data --fstype ext3 --size=1 --grow
#--- Reboot the host after installation is done
reboot #如果没有该行,安装结束时需要点击“reboot”方可重启。
%packages
@base
@core
@dns-server
@dialup
@editors
@ftp-server
@legacy-network-server
@mail-server
@network-server
@news-server
@server-cfg
@text-internet
@web-server
@smb-server
keyutils
trousers
fipscheck
device-mapper-multipath
#some changers after install packegs.
%post
if [ -f /boot/grub/splash.xpm.gz ];then rm -f /boot/grub/splash.xpm.gz; fi >/dev/null 2>&1
if [ -f /etc/redhat-release ];then sed -i 's/CentOS/TANK-OS/' /etc/redhat-release; fi >/dev/null 2>&1
if [ -f /etc/issue ];then sed -i 's/CentOS/TANK-OS/' /etc/issue; fi >/dev/null 2>&1
if [ -f /boot/grub/grub.conf ];then sed -i 's/CentOS/TANK-OS/' /boot/grub/grub.conf; fi >/dev/null 2>&1
chkconfig sendmail off >/dev/null 2>&1
chkconfig portmap off >/dev/null 2>&1
chkconfig cups off >/dev/null 2>&1
chkconfig rpcidmapd off >/dev/null 2>&1
5. 添加auto项,让系统从kickstart配置启动
# vi /tank-os/isolinux/isolinux.cfg
default auto
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
label text
kernel vmlinuz
append initrd=initrd.img text
label auto
kernel vmlinuz
append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
二.个性化定制你的系统
去 掉装机图片:修改/tank-os/isolinux/boot.msg文件,删除“splash.lss”。
删除/tank-os/isolinux/splash.lss这个图片。
去掉安装过程中的CentOS字样:
在安装光盘里面有两个.buildstamp文件,一个位于stage2.img中,一个位于initrd.img中,
安装光盘运行时读取的是initrd.img中的那个.buildstamp文件,所以只要把initrd.img文件改了就可以了。
2.6内核中的initrd.img采用cpio压缩,不再是2.4内核使用的ext2格式,无法使用mount -o loop 挂载。需
要使用gunzip解压缩,然后再使用利用cpio给img解包
# cd /tank-os/isolinux/
# cp initrd.img /tmp/initrd.img.gz
# cd /tmp
# gunzip initrd.img.gz
# mkdir initrd
# mv initrd.img initrd
# cd initrd
# cpio -ivmd < initrd.img
然后修改.buildstamp文件,将CentOS改为tank-os即可.当然,里面的网址也 可以改。
生成新的initrd.img文件:
#cd /tmp/initrd
# find . | cpio -c -o > ../initrd.img
# gzip ../initrd.img
#cd ..
# mv initrd.img.gz initrd.img
# cp initrd.img /tank-os/isolinux/
然后将 initrd.img复制到/tank-os/isolinux/,覆盖旧的。
三.打包发布
# cd /tank-os
# declare -x discinfo=`head -1 .discinfo` //指定环境变量discinfo
# createrepo -u "media://$discinfo" -g repodata/comps.xml . //生成repodata数据库。
说明:repodata 数据库精确描述一个rpm包的详细信息,如依赖关系,包含文件,校验码信息。它的文件主要是XML格式。
生成ISO文件
#cd /tank-os
#mkisofs -R -J -T -r -l -d -allow-multidot -allow-leading-dots -no-bak -o /tmp/tank-os-0.1-i386.iso \
-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
生成Md5,供下载后校验ISO
#md5sum /tmp/tank-os-0.1-i386.iso > tank-os-0.1-i386.iso.md5
四.另建立个虚拟机 测试安装该ISO
- CentOS构建自己的发行版
- 如何构建自己的 Linux 发行版
- 构建属于自己的 Linux 发行版
- 构建属于自己的 Linux 发行版
- 构建属于自己的 Linux 发行版
- 构建属于自己的 Linux 发行版
- 根据CentOS定制自己的发行版
- 用Fedora构建自己的Linux发行版
- 用Fedora构建自己的Linux发行版
- 快速构建自己的linux发行光盘
- ubuntu_使用 Ubuntu builder 来构建自己的 Ubuntu发行版
- 建设一个自己的Linux发行版
- Remastersys制作自己的Linux发行版
- Linux入门-选择自己的发行版
- 从零开始编译自己的 Linux 发行版
- centos 发行版安装
- 打造自己的centos/linux发行版 订制精简ISO压缩包文件[初级版](转)
- 开放嵌入式:构建嵌入式Linux发行版的又一途径
- Qt creator工程项目移植时因环境变换造成qmake错误的解决方案
- 通过命令行执行PHP文件写字符到外部文本 & server端与客户端的当下绝对路径 & PHP的时间设定
- C++ traits编程方法
- Mysql 的 Cascade/Restrict/No action
- CharacterControllerr的碰撞检测
- CentOS构建自己的发行版
- linux shell 中判断进程存在
- 在编译linux kernel时出现 “make: arm-none-linux-gnueabi-gcc:命令未找到”
- EXT核心API详解(六)-Ext.Fx
- 关于从sql*plus中往数据库插入数据却查询不到的原因
- CSS3_HTML5_JS好站
- Qt ProgressBar
- (七)Ext.KeyNav/KeyMap/JSON/Format/DelayedTask/TaskRunner/TextMetrics/XTemplate
- js submit 出错