怎样定制windows安装盘自己的Linux系统安装盘

博客访问: 2206813
博文数量: 513
博客积分: 10012
博客等级: 上将
技术积分: 5265
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: LINUX
献给linux初学者:定制自己的Linux系统安装盘
这几天很多朋友问我,U盘如何定制系统,我就贴出一些文档吧,与大家一切分享以下是在虚拟机环境下进行的。1、在VM安装linux系统 2、安装定制工具anaconda repodata createrepo mkisofs
关联太多采用yum安装//定制过程需要产生comps.xml文件以及生成iso
[root@localhost ~]# yum -y install anaconda repodata createrepo mkisofs
3、生成packages.list 所安装的RPM包文件清单
(由于install.log文件在root目录,所以该操作在root目录进行)
[root@localhost ~]# cat install.log | grep Installing | sed 's/Installing //g' & /root/packages.list
//生成后,需要仔细看该文件,一般会在某些文件开始部分如“1:”这样的字符,需要删除这些字符,否在后面执行copy动作会报错4、建立定制Centos的源目录
[root@localhost ~]#mkdir /Disk & && && && && && && && & //定制时要复制RPM包的目录;[root@localhost ~]#mkdir /mnt/cdrom& && && && && && && & //加载光驱目录[root@localhost ~]#mount -o loop /dev/cdrom /mnt/cdrom& &&&//将光盘内容加载到/mnt/cdrom中;
[root@localhost ~]#cp –R /mnt/cdrom/. /Disk
切记,要把光盘中的“.discinfo”文件拷贝过来,如果没有拷贝此文件,在用光盘安装时会提示如下错误:“The CentOS CD was not found in any of your CDROM drives. Please insert the CentOS CD and press OK to retry.”
[root@localhost ~]#rm –f /Disk/CentOS/*.rpm&&//先删除所有RPM包5、通过脚本复制系统安装的包
(注意一定要Unix格式)
[root@localhost ~]#vi copyrpms.sh#!/bin/bashDEBUG=0DVD_CD=/disk/CentOS& && && && && && && &
ALL_RPMS_DIR=/mnt/cdrom/CentOS/& && &&&DVD_RPMS_DIR=$DVD_CDpackages_list=/root/packages.listnumber_of_packages=`cat $packages_list | wc -l`i=1while [ $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* $DVD_RPMS_DIR/"& && && && && & cp $ALL_RPMS_DIR/$name$version* $DVD_RPMS_DIR/& && && && && & # in case the copy failed& && && && && & if [ $? -ne 0 ] ; then& && && && && && && && &echo "cp $ALL_RPMS_DIR/$name$version* "& && && && && && && && &cp $ALL_RPMS_DIR/$name* $DVD_RPMS_DIR/& && && && && & fi& && &&&fi& && &&&i=`expr $i + 1`done
将以上内容保存为copyrpms.sh
[root@localhost ~]#chmod 775 copyrpms.sh[root@localhost ~]#./copyrpms.sh
经过一系列的复制就完成了你要定制的RPM包(在/Disk/CentOS/目录下)6、定制安装控制文件ks.cfg
ks文件主要分为三个部分
1、系统安装及配置
2、自定义安装准备(%post --nochroot)
3、用户自定义安装(%post)
系统安装及配置一般写在ks.cfg文件最前面,定义系统安装设置,以%post –nochroot为结束标志,接着是用户自定义安装准备部分,以“%post --nochroot”作为开始,以“%post”作为结束,
自定义安装部分以“%post”作为开始。
一般方便可以直接由root下面的anaconda-ks.cfg修改
[root@localhost ~]#cp anaconda-ks.cfg /Disk/ks.cfg
样例内容如:
# Kickstart file automatically generated by anaconda.
install (指定开始全新安装系统)
cdrom(系统安装方式,有很多种安装方式:
光驱方式:如果是光驱,这里可直接写成cdrom。
http方式安装:可以写为“url --url ”在这个访问路径下,应该是已经解压的Centos系统的所有文件和目录。
硬盘安装方式:这里要写做“harddrive --partition=sda1 --dir=/iso,其中sda1是linux镜像文件所在的硬盘标识,/iso是镜像文件所在目录。)
lang en_US.UTF-8 (系统语言设定)
keyboard us (键盘设置)
xconfig --startxonboot (设置X桌面)
#network --device eth0 --bootproto static --ip 192.168.12.133 --netmask 255.255.255.0 --gateway 192.168.12.1 (设置系统的IP地址信息,可以根据情况进行指定)
rootpw --iscrypted $1$sXpmDpgD$IOEYOpdpXtxXgw7RmjtZS/ (经过加密的root密码)
firewall –disabled (关闭防火墙)
authconfig --enableshadow --enablemd5 (系统验证方式,这里启用默认md5加密)
selinux –disabled (安装系统时关闭Selinux)
timezone Asia/Shanghai(系统时区设置)
bootloader --location=mbr(引导选项)
# 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 / --fstype ext3 --size=3000
#part /boot --fstype ext3 --size=100
#part /usr --fstype ext3 --size=2000
#part /var --fstype ext3 --size=2000
#part /cicro --fstype ext3 --size=100--grow
#part swap --size=1024
clearpart --all --initlabel (全部格式化系统磁盘所有分区,下面开始进行分区设置)
part / --bytes-per-inode=4096 --fstype="ext3" --size=15000
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part /var --bytes-per-inode=4096 --fstype="ext3" --size=5000
part /usr --bytes-per-inode=4096 --fstype="ext3" --size=10000
part swap --bytes-per-inode=4096 --fstype="swap" --size=8096
part /cicro --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
reboot(这个reboot必须写在系统分区之后)
%pre (表示安装之前执行的命令,这个是系统安装前拷贝数据,由于光盘在进行安装系统前,会首先挂载到系统的/mnt/source目录下,因而下面操作是在这个路径下)
echo "Installing CWS "
mkdir /tmp/custom_data
cp /mnt/source/cws/cws_3.5.102_Linux_fixed.tar.gz /tmp/custom_data
Linux系统安装进程在系统安装完成后,会卸载光盘,因此,象复制安装介质中的文件或 RPM 之类的任务将不能被执行。此时就需要用“%post –nochroot”选项。
可以添加系统在安装完成后要运行的命令。这一节必须位于 kickstart 文件的结尾处,而且必须以 %post 命令开头。
%post --nochroot (系统安装完成后,要运行的脚步,--nochroot表示允许你指定你想在 chroot 环境之外运行的命令)
cp /tmp/custom_data/cws_3.5.102_Linux_fixed.tar.gz/mnt/sysimage/cicro
cd /mnt/sysimage/cicro
tar zxvf/mnt/sysimage/cicro/cws_3.5.102_Linux_fixed.tar.gz
%post(系统安装完成后,要运行的脚步,--nochroot
在root环境下进行的操作,与在真实linux系统下进行操作完全一致。此时光盘已经被系统安装程序自动卸载)
echo "Configing Hostname"
echo "HOSTNAME=webserver" && /etc/sysconfig/network
echo "# Do not remove the following line, or various programs" & /etc/hosts
echo "# that require network functionality will fail." && /etc/hosts
echo "127.0.0.1localhost" && /etc/hosts
echo "127.0.0.1webserver" && /etc/hosts
echo "Config OS iso88591"
echo 'LANG="en_US.iso88591" '&/etc/sysconfig/i18n
echo 'SUPPORTED="en_US.iso885915:en_US:en" '&&/etc/sysconfig/i18n
echo 'SYSFONT="lat0-sun16" '&&/etc/sysconfig/i18n
echo 'SYSFONTACM="iso15" '&&/etc/sysconfig/i18n
echo "Truning OS And Starting Services"
chkconfig --level 35 sendmail off
/cicro/cws3/bin/startdb.sh
chown -R mysql:mysql /cicro/cws3/data/db/mysql
/cicro/cws3/bin/startas.sh
%packages (系统需要安装的软件包)/* %packages有两个可用选项。--resolvedeps安装列举的软件包,并自动解决软件包依赖关系。如果该选项没有被指定,而软件包依赖关系却存在,自动安装就会暂停并提示用户。例如:
%packages --resolvedeps--ignoredeps忽略未解决的依赖关系,并安装所列举的没有依赖关系的软件包。例如:
%packages --ignoredeps--ignoremissing[1]忽略缺少的软件包或软件包组,而不是暂停安装来向用户询问是中止还是继续安装。例如:
%packages --ignoremissing
@development-libs
@gnome-software-development
@x-software-development
@gnome-desktop
@legacy-software-development
@java-development
@kde-software-development
@development-tools
@graphical-internet
mesa-libGLU-devel
device-mapper-multipath
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
7、修改isolinux.cfg文件
// 将/Disk/isolinu/目录下的isolinux.cfg文件第一行default linux修改成default linux ks=cdrom:/ks.cfg
样例文件如:
default linux ks=cdrom:/ks.cfg
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
&&kernel vmlinuz
&&append ks initrd=initrd.img
label local
&&localboot 1
label memtest86
&&kernel memtest
&&append -8、生成comps.xml
[root@localhost ~]# cd /Disk/& && && && && && && && && &&&
[root@localhost ~]# createrepo -g repodata/comps.xml /Disk/& &&&
到此以上定制任务已经完成。9、制作IOS文件
[root@localhost ~]#cd /Disk/
[root@localhost disk]#mkisofs -o MyCentOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /Disk/
/Disk/ 目录下产生的MyCentOS.iso 生成的ISO文件。
测试定制版本
可以测试这个iso的正确性,通过VM的iso镜像安装即可测试定制系统的正确性。
自定义启动界面 在isolinux里面有三个文件和自定义安装界面有关boot.msg是定义启动界面如何显示isolinux.cfg决定如何处理用户的输入,并执行对应的安装过程splash.lss是启动界面的背景图片1、 boot.msgboot.msg内容大致如下:^L^Xsplash.lss-To install or upgrade in graphical mode, press the ^O0b&ENTER&^O07 key.-To install or upgrade in text mode, type: ^O0blinux text &ENTER&^O07.-Use the function keys listed below for more information.^O0f[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]^O07boot.msg中的^X用ctrl+X输入^Xsplash.lss表示使用splash.lss作为启动界面的背景图片后面就是启动时界面下的提示信息^O0f和^O07之间的内容作为高亮显示。2、splash.lsssplash.lss是启动界面的背景图片,该图形文件比较特殊,只能使用14色(标准16色除去黑白两色)的原始图片来生成。首先创建一个16色(包含黑白两色)的gif文档,名为splash.gif,还可以通过Linux下的gimp工具编辑gif图片,在gimp 的“图像”菜单中把“模式”改为索引色,数量为14,因为还有黑色和白色,加在一起一共是16种颜色。修改后,保存这个gif文件。接着将该文件转换为lss格式#giftopnm & splash.gif | ppmtolss16 & splash.lss此步骤也可以分为两步完成:#giftopnm &splash.gif & splash.pnm#ppmtolss16 &splash.pnm &splash.lssGiftopnm工具需要netpbm工具包。可以通过yum install netpbm*安装即可,需要安装netpbm-progs、netpbm-devel和netpbm三个包。
阅读(1496) | 评论(1) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
你好!博客狠棒If you are looking for
and . I will tell you that
is well-known for its positive effect to human body. MBT is one technology originally,
clearance sale, it began in Masai which is a tribe of Eastern Africa. <a href="http://w
请登录后评论。定制属于自己的Linux操作系统_Linux教程_Linux公社-Linux系统门户网站
你好,游客
定制属于自己的Linux操作系统
来源:Linux社区&
作者:zhang789
本文主要通过裁剪现有Linux系统,打造一个属于自己的Linux小系统,让其能够装载网卡驱动,并配置IP地址,实现网络功能。
自制Linux系统
步骤概述:
1、新建一个硬盘2、在该新硬盘上新建两个分区,一个当boot分区,一个当/分区3、格式化并且挂载两个分区4、安装grub至目标磁盘5、为grub提供配置文件6、复制内核文件和initrd文件7、创建目标主机根文件系统8、移植bash命令和其库文件到根文件系统9、装载模块,实现网络功能10、启动测试
特别提醒如果在vmvare上做此实验,在新建虚拟机创建新磁盘的时候,一定要选&Store virtual disk as a single file&,否则,也会出现内核恐慌kennel panic。
步骤演示详解过程:
1、新建一个硬盘
2、在该新硬盘上新建两个分区,一个当boot分区,一个当/分区首先,我们要在目标磁盘上分两个区,并进行格式化。第一个分区100M,用来装引导程序;第二个分区19G,用来装根文件系统。然后再进行挂载操作,将/dev/sdb1挂载到/mnt/boot下,将/dev/sdb2挂载到/mnt/root下。
sdb& & & & & & & & &
0& & 20G& 0 disk ├─sdb1& & & & & & & & 8:17&
0 109.8M& 0 part └─sdb2& & & & & & & & 8:18&
0& 19.9G& 0 part [root@localhost ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 21.5 GB,
bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xdd8058c2
Device Boot& & & Start& & & &
End& & & Blocks&
Id& System/dev/sdb1& & & & & & &
1& & & & & 14& & & 112423+& 83& Linux/dev/sdb2& & & & & & & 15& & & & 2610& & &
3、格式化并且挂载两个分区注意,其中boot分区的挂载目录一定是boot名字的目录
[root@localhost ~]# mkfs.ext4 /dev/sdb1[root@localhost ~]# mkfs.ext4 /dev/sdb2[root@localhost ~]# mkdir -p /mnt/{root,boot}[root@localhost ~]# ll /mnt/total 8drwxr-xr-x 2 root root 4096 Jul 25 08:52 bootdrwxr-xr-x 2 root root 4096 Jul 25 08:52 root[root@localhost ~]# mount /dev/sdb1 /mnt/boot/[root@localhost ~]# mount /dev/sdb2 /mnt/root/[root@localhost ~]# df -hFilesystem& & & & & & Size& Used Avail Use% Mounted on/dev/sdb1& & & & & &
103M& 1.6M&
2% /mnt/boot/dev/sdb2& & & & & & & 20G&
1% /mnt/root
4、安装grub至目标磁盘一个系统能启动,就需要引导,所以我们首先要安装一个grub引导程序到我们的新磁盘上,安装grub引导程序主要有两个命令,一个是grub-install,另一个是setup,这里最好使用grub-install来安装。因为:
①grub-install会安装grub引导第二阶段的文件 ②setup不会安装第二阶段的引导程序,是安装引导信息到MBR //第二个需要注意的地方就是--root-directory=后面接的路径应该是boot目录所在的地方,而不是/mnt/boot,因为boot目录在mnt下;目标磁盘是/dev/sdb [root@localhost ~]# grub-install --root-directory=/mnt /dev/sdbProbing devices to guess BIOS drives. This may take a long time.Installation finished. No error reported.This is the contents of the device map /mnt/boot/grub/device.map.Check if this is correct or not. If any of the lines is incorrect,fix it and re-run the script `grub-install'.
/dev/fd0(hd0)&
/dev/sda(hd1)&
/dev/sdb[root@localhost ~]# cd /mnt/boot/[root@localhost boot]# lltotal 13drwxr-xr-x 2 root root& 1024 Jul 25 08:58 grubdrwx------ 2 root root 12288 Jul 25 08:51 lost+found安装完grub后,进入grub目录,会发现没有grub.conf配置文件,这样就导致我们的引导程序是不健全的,所以我们需要手动写一个配置文件在里边。
5、为grub提供配置文件上面移植了内核和initrd文件,我们就可以根据内核版本和initrd版本来编写grub.conf配置文件了:
default=0timeout=5title
to ZhangHe Soft-Linuxroot (hd0,0)kernel /vmlinz-soft ro root=/dev/sda2 quiet selinux=0 init=/bin/bashinitrd /initramfs-soft.imgquiet是静默安装,不再显示安装时的一大堆信息。后面要把selinux关掉,而且init要使用/bin/bash,告诉内核不要再去找init程序了。如果不指定这一步,在启动过程中就会报kernel panic(内核恐慌),以为系统就它一个了,没有init进程,恐慌的不行。
6、复制内核文件和initrd文件init是系统中用来产生其它所有进程的程序。它以守护进程的方式存在,其进程号为1,init是所有进程的父进程,老祖宗,所以不移植是不行的。它通过调用/etc/inittab这个配置文件,然后再去执行/etc/rc.d/rc.sysinit的系统初始化脚本。 将内核文件和initrd文件复制到/dev/sdb下的boot目录中。
[root@localhost grub]# cp /boot/vmlinuz-2.6.32-642.el6.x86_64 /mnt/boot/vmlinuz-soft[root@localhost grub]# cp /boot/initramfs-2.6.32-642.el6.x86_64.img /mnt/boot/initramfs-soft.img
7、创建目标主机根文件系统使用命令行展开创建文件系统
[root@localhost grub]# mkdir -pv /mnt/sysroot/{etc/rc.d,usr,var,proc,sys,dev,lib,lib64,bin,sbin,boot,srv,mnt,media,home,root}mkdir: created directory `/mnt/sysroot'mkdir: created directory `/mnt/sysroot/etc'mkdir: created directory `/mnt/sysroot/etc/rc.d'mkdir: created directory `/mnt/sysroot/usr'mkdir: created directory `/mnt/sysroot/var'mkdir: created directory `/mnt/sysroot/proc'mkdir: created directory `/mnt/sysroot/sys'mkdir: created directory `/mnt/sysroot/dev'mkdir: created directory `/mnt/sysroot/lib'mkdir: created directory `/mnt/sysroot/lib64'mkdir: created directory `/mnt/sysroot/bin'mkdir: created directory `/mnt/sysroot/sbin'mkdir: created directory `/mnt/sysroot/boot'mkdir: created directory `/mnt/sysroot/srv'mkdir: created directory `/mnt/sysroot/mnt'mkdir: created directory `/mnt/sysroot/media'mkdir: created directory `/mnt/sysroot/home'mkdir: created directory `/mnt/sysroot/root'[root@localhost mnt]# ls root/bin& boot& dev& etc& home& lib& lib64& lost+found& media& mnt& proc& root& sbin& srv& sys& usr& var
8、移植bash命令和其库文件到根文件系统[root@localhost scripts]# bash cporder.sh Enter a command: bashEnter a command: shutdownEnter a command: vimEnter a command: rebootEnter a command: touchEnter a command: mkdirEnter a command: lsEnter a command: rmEnter a command: catEnter a command: lessEnter a command: treeEnter a command: ifconfigEnter a command: ipEnter a command: routeEnter a command: pingEnter a command: quitquit
附:命令移植脚本
#!/bin/bash& #& target=/mnt/root& clearCmd() {& if which $cmd && /dev/ then& cmdPath=`which --skip-alias $cmd`& else& echo "No such command"& return 5& fi& }& cmdCopy() {& cmdDir=`dirname $1`& [ -d ${target}${cmdDir} ] || mkdir -p ${target}${cmdDir}& [ -f ${target}${1} ] || cp $1 ${target}${cmdDir}& }& libCopy() {& for lib in `ldd $1 | grep -o "/[^[:space:]]\{1,\}"`; do& libDir=`dirname $lib`& [ -d ${target}${libDir} ] || mkdir -p ${target}${libDir}& [ -f ${target}${lib} ] || cp $lib ${target}${libDir}& done& }&
do& read -p "Enter a command: " cmd& if [ "$cmd" == 'quit' ] ;then& echo "quit"& exit 0& fi& clearCmd $cmd& [ $? -eq 5 ] && continue& cmdCopy $cmdPath& libCopy $cmdPath& done&
9、装载模块,实现网络功能Linux是一个模块化的操作系统,好多功能组件都是通过模块化的工具来实现的,而且支持动态装载和卸载,我们要是想实现某种功能,只需加载相应的模块即可,就可以实现我们的Linux操作系统大瘦身了。
1、查看宿主机的网卡模块信息
[root@localhost ~]# lsmod | grep e1000e1000& & & & & & & &
2、查看网卡的详细信息
[root@localhost ~]# modinfo e1000filename:& & &
/lib/modules/2.6.32-642.el6.x86_64/kernel/drivers/net/e.koversion:& & & & 7.3.21-k8-NAPIlicense:& & & & GPLdescription:& & Intel(R) PRO/1000 Network Driverauthor:& & & &
Intel Corporation, &linux.&srcversion:& &
AEFC2A93BCFCF6Aalias:& & & & & pci:v02E6Esv*sd*bc*sc*i*alias:& & & & & pci:v010B5sv*sd*bc*sc*i*alias:& & & & & pci:v01099sv*sd*bc*sc*i*alias:& & & & & pci:v0108Asv*sd*bc*sc*i*//这里查询到了网卡模块的路径,把它复制到/dev/sdb的库文件下:[root@localhost ~]# mkdir /mnt/root/lib64/modules[root@localhost ~]# cp /lib/modules/2.6.32-642.el6.x86_64/kernel/drivers/net/e.ko /mnt/root/lib64/modules/e1000.ko
3、init程序 现在虽然是模块复制过去了,但是还不能用,而且现在也不满足我们的流程需要,因为连最起码的init程序都没有,如果我们想要这个init,有两个选择,第一,移植宿主系统的,但是格式会复杂一些;所以我们还是先自己动手写脚本吧,把脚本当作init来用,能够让小系统跑起来。init一般在sbin目录下,所以我们要在/dev/sdb2这个分区上编写一个init脚本。
[root@localhost ~]# cd /mnt/root/sbin[root@localhost sbin]# cd /mnt/root/sbin/#!/bin/bash #print Welcome info echo -e "Welcome to \033[34m nmshuishui soft-Linux\033[0m" #mount wei wenjian system when the system is running. mount -n -t proc proc /procmount -n -t sysfs sysfs /sys#mount ethernet driver autl when the system is start. insmod /lib64/modules/e1000.ko[ $? -eq 0 ] && echo -e "Load e1000 module succeeded& & & & & & & & & & [\033[32m0K\033[0m]" ifconfig lo 172.0.0.1/8ifconfig eth0 172.16.251.235/16#mount the /dev/sda2 to make it can be write and read. mount -n -o remount,rw /dev/sda2 /#run /bin/bash /bin/bash
写完这个init脚本后,我们要把我们要给其一个执行权限,让其能够被执行;此脚本中还用到mount,insmod这些命令,所以要用上一个脚本把这些命令移植过去。最后还需要把/mnt/boot/grub/grub.conf中的init=/bin/bash换成init=/sbin/init,因为我现在要用这个init脚本来执行系统启动了,再也不需让/bin/bash来替换了。
10、启动测试上面的步骤完成后,就可以把/dev/sdb挂到另一台主机上体验我们的私人订制小系统了。
到此,一个迷你版的Linux诞生了,可以装在自己移动U盘等设备上面,这里不做过多解释
本文永久更新链接地址:
相关资讯 & & &
& (02/04/:46)
& (04/04/:19)
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款怎样定制自己的Linux系统安装盘_Linux系统_ThinkSAAS
怎样定制自己的Linux系统安装盘
怎样定制自己的Linux系统安装盘
内容来源: 网络
怎样定制自己的Linux系统安装盘
1、在VM安装linux系统
2、安装定制工具anaconda repodata createrepo mkisofs
关联太多采用yum安装//定制过程需要产生comps.xml文件以及生成iso
[ ~]# yum -y install anaconda repodata createrepo mkisofs
3、生成packages.list 所安装的RPM包文件清单
(由于install.log文件在root目录,所以该操作在root目录进行)
[ ~]# cat install.log | grep Installing | sed &s/Installing //g& & /root/packages.list
//生成后,需要仔细看该文件,一般会在某些文件开始部分如“1:”这样的字符,需要删除
这些字符,否在后面执行copy动作会报错
4、建立定制Centos的源目录
[ ~]#mkdir /Disk
//定制时要复制RPM包的目录;
[ ~]#mkdir /mnt/cdrom
//加载光驱目录
[ ~]#mount -o loop /dev/cdrom
/mnt/cdrom
//将光盘内容加载到/mnt/cdrom中;
[ ~]#cp –R /mnt/cdrom/. /Disk
切记,要把光盘中的“.discinfo”文件拷贝过来,如果没有拷贝此文件,在用光盘安装时
会提示如下错误:“The CentOS CD was not found in any of your CDROM drives.
Please insert the CentOS CD and press OK to retry.”
[ ~]#rm –f /Disk/CentOS/*.rpm
//先删除所有RPM包
5、通过脚本复制系统安装的包
(注意一定要Unix格式)
[ ~]#vi copyrpms.sh
#!/bin/bash
DVD_CD=/disk/CentOS
ALL_RPMS_DIR=/mnt/cdrom/CentOS/
DVD_RPMS_DIR=$DVD_CD
packages_list=/root/packages.list
number_of_packages=`cat $packages_list | wc -l`
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
if [ $DEBUG -eq "1" ] ; then
echo $i: $line
echo $name
echo $version
if [ $DEBUG -eq "1" ] ; then
ls $ALL_RPMS_DIR/$name-$version*
if [ $? -ne 0 ] ; then
echo "cp $ALL_RPMS_DIR/$name$version* "
echo "cp $ALL_RPMS_DIR/$name-$version* $DVD_RPMS_DIR/"
cp $ALL_RPMS_DIR/$name$version* $DVD_RPMS_DIR/
# in case the copy failed
if [ $? -ne 0 ] ; then
echo "cp $ALL_RPMS_DIR/$name$version* "
cp $ALL_RPMS_DIR/$name* $DVD_RPMS_DIR/
i=`expr $i + 1`
将以上内容保存为copyrpms.sh
[ ~]#chmod 775 copyrpms.sh
[ ~]#./copyrpms.sh
经过一系列的复制就完成了你要定制的RPM包(在/Disk/CentOS/目录下)
6、定制安装控制文件ks.cfg
ks文件主要分为三个部分
1、系统安装及配置
2、自定义安装准备(%post --nochroot)
3、用户自定义安装(%post)
系统安装及配置一般写在ks.cfg文件最前面,定义系统安装设置,以%post –nochroot
为结束标志,接着是用户自定义安装准备部分,以“%post --nochroot”作为开始,以“%post”
作为结束,自定义安装部分以“%post”作为开始。
一般方便可以直接由root下面的anaconda-ks.cfg修改
[ ~]#cp anaconda-ks.cfg /Disk/ks.cfg
样例内容如:
# Kickstart file automatically generated by anaconda.
install (指定开始全新安装系统)
(系统安装方式,有很多种安装方式:
光驱方式:如果是光驱,这里可直接写成cdrom。
http方式安装:可以写为“url --url http://192.168.12.142/centos/”在这个访问路径下,
应该是已经解压的Centos系统的所有文件和目录。
硬盘安装方式:这里要写做“harddrive --partition=sda1 --dir=/iso,其中sda1是linux
镜像文件所在的硬盘标识,/iso是镜像文件所在目录。)
lang en_US.UTF-8 (系统语言设定)
keyboard us (键盘设置)
xconfig --startxonboot (设置X桌面)
#network --device eth0 --bootproto static --ip 192.168.12.133 --netmask 255.255.255.0
--gateway 192.168.12.1 (设置系统的IP地址信息,可以根据情况进行指定)
rootpw --iscrypted $1$sXpmDpgD$IOEYOpdpXtxXgw7RmjtZS/ (经过加密的root密码)
firewall –disabled (关闭防火墙)
authconfig --enableshadow --enablemd5 (系统验证方式,这里启用默认md5加密)
selinux –disabled (安装系统时关闭Selinux)
timezone Asia/Shanghai(系统时区设置)
bootloader --location=mbr(引导选项)
# 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 / --fstype ext3 --size=3000
#part /boot --fstype ext3 --size=100
#part /usr --fstype ext3 --size=2000
#part /var --fstype ext3 --size=2000
#part /cicro --fstype ext3 --size=100 --grow
#part swap --size=1024
clearpart --all --initlabel (全部格式化系统磁盘所有分区,下面开始进行分区设置)
part / --bytes-per-inode=4096 --fstype="ext3" --size=15000
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part /var --bytes-per-inode=4096 --fstype="ext3" --size=5000
part /usr --bytes-per-inode=4096 --fstype="ext3" --size=10000
part swap --bytes-per-inode=4096 --fstype="swap" --size=8096
part /cicro --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
reboot(这个reboot必须写在系统分区之后)
%pre (表示安装之前执行的命令,这个是系统安装前拷贝数据,由于光盘在进行安装系统前,
会首先挂载到系统的/mnt/source目录下,因而下面操作是在这个路径下)
echo "Installing CWS "
mkdir /tmp/custom_data
cp /mnt/source/cws/cws_3.5.102_Linux_fixed.tar.gz /tmp/custom_data
Linux系统安装进程在系统安装完成后,会卸载光盘,因此,象复制安装介质中的文件或 RPM
之类的任务将不能被执行。此时就需要用“%post –nochroot”选项。
可以添加系统在安装完成后要运行的命令。这一节必须位于 kickstart 文件的结尾处,而且必须
以 %post 命令开头。
%post --nochroot (系统安装完成后,要运行的脚步,--nochroot表示允许你指定你想在
chroot 环境之外运行的命令)
IXDBA.NET社区论坛
cp /tmp/custom_data/cws_3.5.102_Linux_fixed.tar.gz
/mnt/sysimage/cicro
cd /mnt/sysimage/cicro
/mnt/sysimage/cicro/cws_3.5.102_Linux_fixed.tar.gz
%post(系统安装完成后,要运行的脚步,--nochroot
在root环境下进行的操作,与在真实linux系统下进行操作完全一致。此时光盘已经
被系统安装程序自动卸载)
echo "Configing Hostname"
echo "HOSTNAME=webserver" && /etc/sysconfig/network
echo "# Do not remove the following line, or various programs" & /etc/hosts
echo "# that require network functionality will fail." && /etc/hosts
echo "127.0.0.1
localhost" && /etc/hosts
echo "127.0.0.1
webserver" && /etc/hosts
echo "Config OS iso88591"
echo &LANG="en_US.iso88591" &&/etc/sysconfig/i18n
echo &SUPPORTED="en_US.iso885915:en_US:en" &&&/etc/sysconfig/i18n
echo &SYSFONT="lat0-sun16" &&&/etc/sysconfig/i18n
echo &SYSFONTACM="iso15" &&&/etc/sysconfig/i18n
echo "Truning OS And Starting Services"
chkconfig --level 35 sendmail off
/cicro/cws3/bin/startdb.sh
chown -R mysql:mysql /cicro/cws3/data/db/mysql
/cicro/cws3/bin/startas.sh
%packages (系统需要安装的软件包)
有两个可用选项。
--resolvedeps
安装列举的软件包,并自动解决软件包依赖关系。如果该选项没有被指定,而软件包依赖关系却
存在,自动安装就会暂停并提示用户。例如:
%packages --resolvedeps
--ignoredeps
忽略未解决的依赖关系,并安装所列举的没有依赖关系的软件包。例如:
%packages --ignoredeps
--ignoremissing[1]
忽略缺少的软件包或软件包组,而不是暂停安装来向用户询问是中止还是继续安装。例如:
%packages --ignoremissing
@development-libs
@gnome-software-development
@x-software-development
@gnome-desktop
@legacy-software-development
@java-development
@kde-software-development
@development-tools
@graphical-internet
mesa-libGLU-devel
device-mapper-multipath
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
7、修改isolinux.cfg文件
// 将/Disk/isolinu/目录下的isolinux.cfg文件第一行default linux修改成default linux
ks=cdrom:/ks.cfg
样例文件如:
default linux ks=cdrom:/ks.cfg
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
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
8、生成comps.xml
[ ~]# cd /Disk/
[ ~]# createrepo -g repodata/comps.xml /Disk/
到此以上定制任务已经完成。
9、制作IOS文件
[ ~]#cd /Disk/
[ disk]#mkisofs -o MyCentOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /Disk/
/Disk/ 目录下产生的MyCentOS.iso 生成的ISO文件。
测试定制版本
可以测试这个iso的正确性,通过VM的iso镜像安装即可测试定制系统的正确性。
自定义启动界面
在isolinux里面有三个文件和自定义安装界面有关
boot.msg是定义启动界面如何显示
isolinux.cfg决定如何处理用户的输入,并执行对应的安装过程
splash.lss是启动界面的背景图片
1、 boot.msgboot.msg内容大致如下:
^Xsplash.lss
To install or upgrade in graphical mode, press the ^O0b&ENTER&^O07 key.
To install or upgrade in text mode, type: ^O0blinux text &ENTER&^O07.
Use the function keys listed below for more information.
^O0f[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]^O07
boot.msg中的^X用ctrl+X输入
^Xsplash.lss表示使用splash.lss作为启动界面的背景图片
后面就是启动时界面下的提示信息^O0f和^O07之间的内容作为高亮显示。
2、splash.lss
splash.lss是启动界面的背景图片,该图形文件比较特殊,只能使用14色(标准16色除去黑白两色)
的原始图片来生成。
首先创建一个16色(包含黑白两色)的gif文档,名为splash.gif,还可以通过Linux下的gimp工具
编辑gif图片,在gimp 的“图像”菜单中把“模式”改为索引色,数量为14,因为还有黑色和白色,
加在一起一共是16种颜色。修改后,保存这个gif文件。
接着将该文件转换为lss格式
#giftopnm & splash.gif | ppmtolss16 & splash.lss
此步骤也可以分为两步完成:
#giftopnm &splash.gif & splash.pnm
ppmtolss16 &splash.pnm &splash.lss
Giftopnm工具需要netpbm工具包。可以通过yum install netpbm*安装即可,需要安装netpbm-progs、
netpbm-devel和netpbm三个包。
PHP开发框架
开发工具/编程工具
服务器环境
ThinkSAAS商业授权:
ThinkSAAS为用户提供有偿个性定制开发服务
ThinkSAAS将为商业授权用户提供二次开发指导和技术支持
让ThinkSAAS更好,把建议拿来。
开发客服微信

我要回帖

更多关于 怎样刻录系统安装盘 的文章

 

随机推荐