找回密码
 注册
查看: 3752|回复: 4

基于Centos7.6定制自己的系统镜像

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-3-13 22:53:35 | 显示全部楼层 |阅读模式
$ R/ A" ]- G' ^' V
  <environment>4 ]+ _& |5 z! c! }" i( }& r2 v
    <id>ceph</id>
* Y: w9 _+ X/ r8 z4 [) T# ~    <name>CEPH S3 SERVER</name>2 V9 u. H( j( T* [4 N+ Y9 z: ?
    <name xml:lang="zh_CN"> ceph</name>' _2 A* b$ E; ~' R4 X: u. ^+ P7 n
    <description>CEPHServer</description>
7 a4 x& ?6 q; w6 O8 H    <description xml:lang="zh_CN"></description>7 a/ t% w" z  I" a2 Y
    <display_order>9</display_order>
& c$ \7 `; S* r( R    <grouplist>
* j  D9 }+ r7 V( A. Z0 x      <groupid>core</groupid>4 p+ r: f! i) x$ r
      <groupid>gbasic</groupid>
* `; ~) A0 F/ C7 W3 W1 X) w& w/ G/ o( J      <groupid>gceph</groupid>
2 s1 _4 p; H$ y9 P+ `3 w& j
; Z2 z% A9 M  L. p    </grouplist>6 Y7 }; S- i8 k3 q2 o4 \! ?
2 O' C  q& J6 ?* [0 w" [3 u* i
<optionlist>7 Q" V, }3 F7 F# x( h, v- z9 [7 n
; F! ?( U( }* O* H4 \
      <groupid>gim</groupid>; }, v4 B0 f$ C6 e! Q. F+ R
* H' _9 c( b* g. Q5 q) R# i( A
      <groupid>giam</groupid>
7 g8 H) c) S/ }, g, _) P5 g: ^3 s  </environment>! {+ M2 ?+ A6 O& E

0 l7 o) `  }- _' l; B...5 F6 f( b% u3 W& H" r

* @8 o& ?: Y( Z1 y$ g+ L:wq!保存退出  % Y: x2 @; C3 F/ e

9 R5 Y+ P9 \6 C. x& a$ Q: ?5 T以上修改会在安装系统可选软件中列出自己的软件。 optionlist项为可附加可选项。自定义的软件如init-ceph。可以放在根目录的任务文件夹下。我们统一放在 Extra/mirrors/sunrunpaas/
6 N% O( d$ o( o! L
! X7 D2 a# h  @: V如:- |5 m8 n7 Z2 L
" M( T8 c4 A  g) C6 t  x
ceph/          php5.6/        sunrundfs/     sunruniaas/    sunrunim/      sunrunvas/      
& I1 _1 G/ U6 r, l4 wmariadb/       sunrun-common/ sunrunhac/     sunruniam/     sunrunslb/     TRANS.TBL3 V0 a  \$ F! P, W1 `/ y" ~
& M7 f' {" {( D/ l, T5 ]2 @- B

) P! Z6 M. \7 D  A  v: s! x- [7 G& {
: p2 o. G% R$ y6 I% p! E7 L1 v$ A3 C
3 C% r9 m) v7 L. T  K$ t. {9 g4 s2.2 ,定制作自己的界面3 u( I4 Q# z" }/ T
5 k* N$ P) C/ |
   2.2.1定制作引导界面。
& L- a4 R. Q1 |- `) q  `* H; L3 e& U" x5 K5 n
修改 isolinux/isolinux.cfg
* M; s6 z  \$ V5 N" @3 _- [* _4 h4 t- L7 Z8 E. P/ ?
label linux; N; ]; h& J* b- Z8 [
  menu label ^Install SunrunOS 1
! R2 N( s/ ~, a3 u) ?# P) K- K3 g  kernel vmlinuz' {( i) {! S  Q( t4 P! l

8 L. H$ D% x' R9 a  y  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS7 inst.ks=cdrom:/ks.cfg  quiet# P* \( ]$ t3 m5 p4 V& S

8 g0 g5 J1 S2 L/ R/ X  k...
2 L& _+ i' a% x' }' l0 f1 [. ~3 ^. W) ^
2.2.2 定制图标和文字。
: B& f7 i$ }! u; u& Y( b& i8 C. U- Z1 ~
    系统安装界面里的图标与文件修改。对应的图片在LiveOS/squashfs.img中,需要解压,修改,再压缩回去。& }2 j( y, u: m  ]0 k0 o

* {; F7 V" H/ i6 x    unsquashfs squashfs.img2 K! Z/ X3 i! X% z

6 B4 A8 t* }( @1 W  产生squashfs-root 目录。
+ z  W& o8 \* n: A5 F2 n7 ^* \0 ?4 y* n, R/ x! c* W
  squashfs-root/LiveOS/
5 Q7 S7 x7 _. A; ?: f9 Q5 K! w8 M9 {3 j' {
  mkdir tmp
1 K/ J: J$ C+ z6 A/ z
8 ~& D, @0 I7 y' e  mount rootfs.img tmp/' {9 W& {2 ?7 X$ @* Y' g* V

. o# q6 |* ?2 z4 ^. b: {8 ]  下载,修改,替换下图:
% _* E1 R/ d$ Q
& n; w& w9 i8 H0 a3 w' A# \7 y8 g   usr/share/anaconda/pixmaps/sidebar-logo.png   j; }+ ?' l1 A
3 D0 s9 `: t3 C$ I! J& ?
3 N+ _- P# R# a" Q8 P# @8 Z

- P  A, c" m& J修改usr/lib64/python2.7/site-packages/pyanaconda/product.py' L( v8 v4 }+ @8 e* q6 U; ~- ~& x
8 X9 \' s  j/ T$ G5 `/ ?
def distributionText():
  f5 {. n' l2 y) {5 M; L9 a4 Y3 S    return _("%(productName)s %(productVersion)s INSTALLATION") % \9 J, W1 ?1 b# {$ ~
             {"productName": "SUNRUNOS", "productVersion": "1"}* c& K# E8 f9 g7 x1 P0 w

) Q: T+ T# A' o, t( Z7 Z0 @: {' X4 ^: C* U/ t8 @3 T

* w. V; u- R) p! e8 m* O8 y1 d2 E完成修改,生产新的squashfs.img
" ^9 C. E: K- q; Y; \- c+ L* j3 n$ \& Q/ f7 r. v) Z
umount tmp/4 i' u/ ^! J2 _' E# ?0 t; @
& n. U7 `2 ?6 X4 s$ S& a
cd ../../
' b+ E( i# p% s* F5 g
: j5 S& m: i; ^* l9 P* u* Orm squashfs.img
5 ~+ F- B! D. C" f4 {4 r+ s$ V; T* J; f; l4 r% j) J0 W2 g3 P
mksquashfs squashfs-root squashfs.img6 O! M( S& T( E
5 K: z/ S. e2 i& c2 E' z4 `0 f
3, 定制安装流程2 f5 I8 o7 `2 n) H

0 Y+ r8 k0 e- Y   cp /root/anaconda-ks.cfg /cloud/iso/centos7.2/ks.cft& K. L8 c2 p2 k! ]

. h8 v: ]9 c+ F3 [( S如下:
0 V0 @1 v, h8 }: V$ ~! ]; i4 \3 s2 u  _
#version=Chen CentOS( U1 a6 J0 s" J8 n' ^

! a) _" A! H* S$ ^$ O$ r6 w#platform=x86, AMD64, or Intel EM64T 3 d* {$ _& T/ v. R- }
# Install OS instead of upgrade 7 d8 O; x5 j2 `8 h# y
#repo --name="sunrundvd"  --baseurl="file:///opt/sunrun-dvd/Extra/Packages/" 8 k$ _: `: {: v1 U0 I/ q
install
% ]+ P# X) d5 T/ {, X- }# Keyboard layouts
; @, _; @& y! F8 ukeyboard --vckeymap=us --xlayouts='us'
, H+ \% W5 b$ M* w6 ^# p/ v# Root password
- z, X- b, w5 s0 V, w8 mrootpw --iscrypted $1$password$mV5CPMXkUkvImOukQuVs..
% R0 Z- R, Y3 u# System language 0 D% I9 f1 q1 v  }! j; U0 g
lang en_US.UTF-8 : b8 f& x8 q$ H1 E+ M
# Firewall configuration
$ [5 C. {0 [: V) U7 G* f& g0 sfirewall --disabled
( Z6 s$ m% [$ U( |" ^# System authorization information 8 U# c' f0 H" k: e8 i' O& g# N
auth  --useshadow  --passalgo=sha512 & G, P# N" r) Q$ @2 c
# Use CDROM installation media   }5 q8 d* C: J8 d4 p0 \
cdrom
4 c9 F# F& v4 L' M6 b# Use text mode install ! _' N7 C: e# a: H2 S) z# Y0 j$ S
#text
+ i) \" @1 S( s) D3 A8 o! R9 B. N# Run the Setup Agent on first boot
: r) ?! e* O) S0 T4 jfirstboot --enable
/ v/ |- N' R. {7 N2 A" u/ Mignoredisk --only-use=sda ! s8 x* m0 s! a9 {1 C6 Z
# SELinux configuration " G9 t4 u4 X' Y
selinux --disabled
! ^$ p* ~8 B% L3 h- p# Do not configure the X Window System
9 ?$ p7 A1 x! \; l4 G6 L#skipx " z! Z) x( b  g. F& M
; C4 h4 H7 }  P% Q9 C
8 I0 Q  W) W4 X9 v. |) H; j# s
# Network information , D8 t4 D  b3 [; V
network  --bootproto=dhcp --device=ens160 --onboot=yes --ipv6=auto --activate
, F4 d8 @8 W- M! G! @#network  --device=ens160 --hostname=localhost.localdomain % m& N1 t. U. @0 V% |, u  F
( z0 `9 F! U* a$ B4 M

) ^; }  H8 i* }% U- H; _%post --nochroot
* Z" s( K& t" e8 }# 写到rootfs里去
2 S9 K( K, c  x1 i5 k: hrm -rf /mnt/sysimage/etc/yum.repos.d/* ) c$ S4 s& U9 X0 Y' t: q
#mkdir -p /mnt/sysimage/mnt/iso
; ^" j! w$ \4 \# P#\cp -rf /run/install/repo/Extra/repos/* /mnt/sysimage/etc/yum.repos.d/ $ Z2 R8 i- ?# N. g' j
7 j, e- s7 k* J. |/ A# g- ~
%end
" h8 o8 H) I" Y5 e+ Z' `- }
: S0 t7 M: @0 o% ]' x# Reboot after installation
  G2 E$ {9 b: m* Z9 Dreboot . J+ O' Z' Q* ]
# System timezone
. Y5 }- t% t$ u* D9 @timezone Asia/Shanghai --isUtc / Z# ]  ?4 N% ?' B& k! h
# System bootloader configuration
7 O4 k( `+ W1 H4 G9 e4 Tbootloader --location=mbr --driveorder=sda --append=""
* ?. Q2 x( k) [: S# Clear the Master Boot Record * w! w7 G9 L6 ]5 D3 ~: U
zerombr : r4 t4 F8 }% ~0 F/ B
# Partition clearing information
" C8 z* z! R) L6 C7 Y" gclearpart --all --initlabel
# w1 o. R, \  a3 Z+ ^4 D$ Zautopart --type=lvm / `& }" Q+ G+ Q

! |# P/ M+ @/ a! ^* a# a" S+ u' c3 U2 T/ K9 d8 r( v
#%packages
4 t' t3 [& ]9 K4 v( K#@^minimal * p6 j/ H1 g( ~6 p% y
#@core
# l! C0 x. G9 a: e: C7 q* b9 [$ f& i  t# }
% F4 Y' f  L3 w' e5 v
#%end, ^5 D& E! Y- E; w
/ P8 l, X8 W) k, g
0 k9 n# s$ W4 x6 [
4,重新生成镜像:
% N% d: a/ u2 l1 e7 ^3 E% z. P! M, q
rm -rf repodata/*
' [' ]9 H5 K: o4 [! U7 q( O. V% p8 s; Q: t' v' _7 X! d

" m1 U- `7 x& t! `5 F* J
! ?- d/ p; F, D" qcreaterepo -g comps.xml .+ h9 h4 v. A! ^/ V* w  c9 L, s
9 _, c: _' P1 N4 v- h0 B1 }8 N
. z3 L: E' R, x

+ f% c- j4 e- E  c' y' tgenisoimage -v -cache-inodes -joliet-long -R -J -T -V CentOS7 -o ../c76.iso -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -b images/efiboot.img -no-emul-boot ./0 j2 C0 i4 Z6 F! g
- A" c* ~* i- Q( @8 `
5完成   ../c76.iso 即是我们的作品。* t0 g7 e( k( q6 S
  C  J' o1 Q: C

# F7 G9 ?, _/ Q3 X- A. o' j$ [2 S6 \; m2 ]1 O. A% K' C; `: z

2 C( j+ L5 S5 U, q. i/ _1 f

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-3-13 22:53:46 | 显示全部楼层
mkisofs -o CentOS7.4-evglow.iso -input-charset utf-8 -b isolinux/isolinux.bin -c isolinux/boot.cat -
% ?+ u& h/ V( Wno-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T -joliet-long -V EVGLOW /root/iso/CentOS7.4-evglow/
* U% ?$ \3 F* q0 v/ x
& ^: L0 d% v5 `  v% |% f4 _- h

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-3-13 22:54:52 | 显示全部楼层

Centos 7发布也有一段时间了,最近公司有需要在Centos7上测试的需求,于是就开始着手定制。大致和之前写的制作CentOS 6.5一键自安装ISO镜像光盘差不多。这边主要写下和6.5的差别

一、拷贝相关软件包

6.5版本用的是根据安装的install.log,用脚本去筛除不需要的包;但在Centos7的/root下面并没有install.log文件。于是我们可以通过下面脚本用rpm -qa的方式得到所需安装的软件包。

  • #!/bin/bash
  • rpm -qa  >package.txt
  • DVD='/mnt/cdrom/Packages'
  • NEW_DVD='/ISO/Packages'
  • while read LINE
  • do
  • cp ${DVD}/${LINE}*.rpm /${NEW_DVD} || echo "$LINE don't cp......."
  • done < package.txt
  • rm -f package.txt
    4 Q0 t1 L  b$ I3 U

    % ~7 z  y& @& ]! l8 f5 w

, r4 m! Z5 }& R. k
- m/ f- x( C. K# G& i* P* t8 L

二、配置 EFI 引导方式

1、EFI简介

参考百度百科EFI

2、分区

为了同时兼容mbr和efi方式,需同时创建 /boot 和 /boot/efi 分区

3、配置 EFI 引导

进入光盘目录EFI/BOOT/ ,编辑 grub.cfg 文件,和mbr方式类似,指明 ks.cfg 文件位置和安装源位置

三、生成ISO文件

这边和在CENTOS6.5以下版本的区别是,制作镜像需要使用CENTOS7系统,因为两者系统的genisoimage命令的版本不一样, 6的系统制作出来的 iso不能在 efi 环境启动。

如果要在 efi 启动,需要添加如下参数

  • -eltorito-alt-boot -bimages/efiboot.img -no-emul-boot
    $ l; I3 \$ L0 @4 i

6版本以下生成ISO命令:

  • # mkisofs -o CentOS-6.5_x86_64.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /ISO/; ]( C# P" T: _0 a/ z$ [: E$ j
    - o- X- Q! C  H; m

7版本生成ISO命令:

  • # genisoimage -o CentOS-7.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /CentOS/73 O  p; y  x# ]% p$ G

两者的区别就是mkisofs和genisoimage,其实最早时候Linux 系统使用cdrtools工具来管理 iso 及光盘, mkisofs 是 cdrtools 里面的一个工具,后来 cdrtools 更好了了授权许可,从 GPL 修改为 CDDL 许可,开源社区又推出了一套基于 GPL 的工具,cdrkit,mkisofs 也被 genisoimage 去掉,现在系统中的 mkisofs 实际是 genisoimage的软连接

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-3-15 20:59:12 | 显示全部楼层
CentOS7全自动安装光盘制作详解
1 复制光盘文件
1)挂载iso镜像
创建目录用于挂载光盘:
mkdir /root/centos7
挂载iso镜像
mount -o loop CentOS-7.0-1406-x86_64-DVD.iso/root/centos7
2)复制光盘文件到编辑目录进行编辑
因为挂载上iso镜像是只读的,如果要编辑,需要将文件复制出来,再编辑。
首先创建编辑目录:
mkdir /root/centos7_iso
复制光盘文件:
cp -rf /root/centos7/* /root/centos7_iso/
diskinfo文件需求单独拷贝下:
cp /root/centos7/.discinfo /root/iso
2 编辑ks.cfg文件
系统安装的时候,按照ks.cfg文件的内容进行安装,我们把ks.cfg文件放到isolinux目录下:
cd /root/centos7_iso/isolinuxvim ks.cfg
我的ks.cfg文件内容如下:
#version=RHEL/CentOS7 by xiaoli110install# Keyboard layoutskeyboard 'us'# Reboot after installationreboot# Run the Setup Agent on first bootfirstboot --enableignoredisk --only-use=sda# Keyboard layoutskeyboard --vckeymap=us --xlayouts='cn'# System languagelang zh_CN.UTF-8# Network information#network --bootproto=dhcp --device=enp2s0 --onboot=off --ipv6=auto#network --bootproto=dhcp --device=enp3s0 --onboot=off --ipv6=auto#network --hostname=localhost.localdomain# Root passwordrootpw --iscrypted 111111111111111111111111111# System timezonetimezone Asia/Shanghai# System languagelang zh_CN# Firewall configurationfirewall --enabled --ssh # System authorization informationauth --useshadow  --passalgo=sha512# Use CDROM installation mediacdrom# Use graphical installgraphical# SELinux configurationselinux --disabled# Do not configure the X Window Systemskipx# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all# Disk partitioning informationpart /boot --fstype="xfs"--size=500part /boot/efi --fstype="xfs"--size=500part swap --fstype="swap"--size=16000part / --fstype="xfs" --grow--size=1 %packages@base@core@development@hardware-monitoring@performance@remote-system-management%end
注意:
1)因为CentOS7系统网卡规则更复杂,为了ks.cfg更通用,最好ks.cfg不用制定网卡配置。
2)为了兼容mbr方式和EFI方式,同时创建了/boot和/boot/efi分区。
3配置mbr引导方式
编辑isoliuux目录下的isolinux.cfg文件,添加自己的内容,在isolinux.cfg文件中label linux下面添加自己的label:
label linux menu label ^Install CentOS 7 kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS7 quiet label custom menu label ^Custom CentOS 7 by xiaoli110 kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS7 inst.ks=cdrom:/isolinux/ks.cfg
注意点:
1)memu label 后面的内容是在光盘引导起来菜单的内容,^后面的字母是菜单的快捷键;
2)通过inst.ks关键字指明ks.cfg文件位置;
3)inst.stages2标识的是系统按照介质位置,这里使用hd:LABEL表明寻找的是label为CENTOS7的安装介质,使用LABEL关键字的好处是可以精确指定安装介质,为什么label是CENTOS7,是因为我在制作光盘镜像的时候指定的,方法在后面有介绍。
4 配置EFI引导方式
1)EFI简介
EFI可扩展固件接口(ExtensibleFirmware Interface 的缩写),是英特尔主导推出的一种替代BIOS的升级方案。最早由英特尔开发,于2005年将此规范格式交由UEFI论坛来推广与发展,后来并更改名称为Unified EFI(UEFI)。UEFI论坛于2007年1月7日释出并发放2.1版本的规格,其中增加与改进了加密编码(cryptography)、网络认证(network authentication)与用户接口架构(User Interface Architecture)。
EFI是用模块化,C语言风格的参数堆栈传递方式,动态链接的形式构建的系统,较BIOS而言更易于实现,容错和纠错特性更强,缩短了系统研发的时间。
EFI在概念上非常类似于一个低阶的操作系统,并且具有操控所有硬件资源的能力。
2)配置EFI引导
进入光盘目录EFI/BOOT/,编辑grub.cfg文件,添加自己的菜单:
menuentry 'Install CentOS 7' --class fedora--class gnu-linux --class gnu --class os {       linuxefi /p_w_picpaths/pxeboot/vmlinuz inst.stage2=hd:LABEL=CENTOS7 quiet       initrdefi /p_w_picpaths/pxeboot/initrd.img}menuentry 'Install CentOS 7 custom byxiaoli110' --class fedora --class gnu-linux --class gnu --class os {       linuxefi /p_w_picpaths/pxeboot/vmlinuz inst.ks=cdrom:/isolinux/ks.cfginst.stage2=hd:LABEL=CENTOS7 quiet       initrdefi /p_w_picpaths/pxeboot/initrd.img}
和mbr方式类似,指明ks.cfg文件位置和安装源位置。
5 生成iso镜像
经过我踩过多个坑,成功的生成镜像,并且能在EFI和mbr环境安装的镜像生成命令如下:
genisop_w_picpath -v -cache-inodes -joliet-long -R -J -T -V CENTOS7 -o /root/centos7.iso    \-c isolinux/boot.cat    -bisolinux/isolinux.bin      \-no-emul-boot -boot-load-size 4-boot-info-table    \-eltorito-alt-boot     -b p_w_picpaths/efiboot.img       -no-emul-boot .
(1)中间踩过的几个坑:
1)制作镜像要使用CentOS7的系统,不要使用CentOS6的系统,因为两者系统的genisop_w_picpath命令的版本不一样,6的系统制作出来的iso不能在efi环境启动;
2)如果要在efi启动,需要添加如下参数:
-eltorito-alt-boot     -bp_w_picpaths/efiboot.img       -no-emul-boot
3)通过-V参数指定光盘label
(2)genisop_w_picpath命令参数简介
-o 指定映像文件的名称。
-b指定在制作可开机光盘时所需的开机映像文件。
-c 制作可开机光盘时,会将开机映像文件中的no-eltorito-catalog全部内容作成一个文件。
-no-emul-boot  非模拟模式启动。
-boot-load-size 4   设置载入部分的数量。
-boot-info-table 在启动的图像中现实信息。
-joliet-long   使用 joliet 格式的目录与文件名称,长文件名支持。
-R 或 -rock    使用 Rock RidgeExtensions 。
-J 或 -joliet    使用 Joliet 格式的目录与文件名称。
-v 或 -verbose    执行时显示详细的信息。
-T 或-translation-table    建立文件名的转换表,适用于不支持 Rock Ridge Extensions 的系统上。
(3)genisop_w_picpath、mkisofs、xorrios几个命令的区别
说起genisop_w_picpath和mkisofs,其实里面是有点故事的。
最早的时候,Linux系统使用cdrtools工具来管理iso及光盘,mkisofs是cdrtools里面的一个工具,后来cdrtools更好了了授权许可,从GPL修改为CDDL许可,开源社区又推出了一套基于GPL的工具,cdrkit,mkisofs也被genisop_w_picpath去掉,现在系统中的mkisofs实际是genisop_w_picpath的软连接:
ls -l /usr/bin/mkisofs/usr/bin/mkisofs ->/etc/alternatives/mkisofsls -l /etc/alternatives/mkisofs/etc/alternatives/mkisofs ->/usr/bin/genisop_w_picpath
xorrios是另外一个比较流行的制作iso镜像的工具,并且有一个参数-asmkisofs可以和mkiso命令兼容。

6 f( G7 \( j" r! S) `# h: ~4 f( F

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-3-16 11:01:01 | 显示全部楼层
vi /root/ks.cfg
4 F* g) M9 [7 {2 X5 {" O! s* f" ]3 U
install% p0 \9 ~# V% o! ]) r
cdrom0 Y3 O6 W' o4 j" R* o
lang en_US.UTF-8. @/ G+ S5 ~, _, J. _
keyboard us# N! ?# h& T5 u* A. s3 D6 e. N4 l
network --onboot no --device eth0 --bootproto dhcp --noipv6
9 g/ ]5 y; J( U: crootpw  --iscrypted $6$ZI78JvmQ56MxYSe3$dn9UV./VvFieP25R94ciYo4wg7p17sM8gCt2WQa/hqMeHiynnBqL/abF14D0AOSXjnptoBHqLYGhzun6W7Qfr1
% g2 ?8 f9 S  Z2 [firewall --service=ssh
* B# [, ~% `& V+ d" Tauthconfig --enableshadow --passalgo=sha512
& l; ^7 z1 Y& \% G* Z' U2 d5 G' \ignoredisk --only-use=sda7 u# d2 D8 F8 `- }
selinux --disabled, g- L9 ], `# K& F3 S  o
timezone Asia/Shanghai! x9 }" @* P! Y& P. a# c4 C% e: @+ c1 o
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
( N8 }" M- S7 x+ e. C7 k0 Lclearpart --all --initlabel  --drives=sda! ?- k# b2 p! A! C; j
part /boot --fstype=ext4 --size=2008 Z, B, s6 L* `2 h% X
part / --fstype=ext4 --size=20000  m. V" l) O  @0 z% o- h
part swap --size=20482 L/ i' g5 Z+ t" Z, l
part /data --fstype=ext4 --grow --size=1( s; n- G" k/ w- m3 _1 w4 _
reboot2 S  O8 u! u. j# `
%packages
8 e& x* e; E- a3 I  D@core
! A6 S+ ?$ G' |( U2 q@server-policy
( I  e: U" z0 Q- T/ K: X@workstation-policy
7 I4 [: V( `7 O) Z# n: p' V: i) S, }
( l) C/ o6 G  ]%post! @1 s9 R+ R! c7 D% @
#add user0 `& }% V# ]: P; R1 d& y* X# l
useradd pos1 B: ^) q4 j/ w
echo "12341234" | passwd pos --stdin
/ m# k3 M- @$ ?( X* q1 b! q5 @#service
( q) R4 H/ Y0 K, dfor i in `chkconfig --list | grep 3:on | awk '{print $1}'`; do echo $i; chkconfig $i off; done/ b/ d) o9 Q2 n' u7 V9 I5 O. G
for i in auditd crond network  rdma  rsyslog sshd udev-post; do echo $i ; chkconfig $i on; done
+ Z- p) H, B: G( U8 m4 r8 C5 t( w% [: Q
#profile% a: z8 r' A! c. V! q; \, ?/ w6 M
echo "ulimit -SHn 51200">>/etc/profile! ]9 n" y9 V' f1 X) y5 ?' p9 a
echo "TMOUT=6000" >>/etc/profile2 E8 e" d  s4 Z6 d% m2 M
2 h. l* X' _* {1 e
#passwd+ r3 [9 ]! Y& V3 `7 `& D! X8 a
echo "admin"  | passwd root --stdin% x+ U3 h' e/ |$ a  [

: T: V# p9 i3 f/ T#ssh login slowly5 t1 ?5 X& G8 `& c3 }* v
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config( f, t2 j& T% h
sed -i "s/GSSAPICleanupCredentials yes/GSSAPICleanupCredentials no/" /etc/ssh/sshd_config
/ }' A9 j: J0 i. C  I( I' p/etc/init.d/sshd restart% q! p; X3 J/ x* k, F: J
- e" J* ?* M6 L) @9 x8 {- r
rm -fr /tmp/*6 P! e8 }) i7 Q" b
%end6 G6 T* L" P3 A% n
4 D8 z/ O( {. }0 d# C1 `+ D  }
2.  yum install createrepo mkisofs isomd5sum squashfs-tools -y5 e1 M# S1 d+ D9 |" A& x# L1 d
$ o, W' m: Y4 E% K0 _
    mkdir /root/os0 I) M8 w3 c4 A: _5 @) D$ [

: d4 D) B9 z7 C8 J: ~' ~$ _   将以os为iso制作目录.
3 ]4 d6 t* s$ x; i: w- O, b. e# J) ~4 d
mount /etc/cdrom/   /media- @) V) F' K! y( J8 z7 P2 H& f
/ |. E+ v$ a9 w% R
rsync -a --exclude=Packages/ --exclude=repodata/ /media/   /root/os/
4 ?5 Q; W  }, v9 T) M' Z) i
- r$ U  \" w$ ^9 B+ Cmkdir -p /root/os/{Packages,repodata}, K% k, s! R; A" x
$ w/ @" q! D9 X. R% P: t
3.拷贝mimi 包
9 ~7 o% {: o% y3 z9 _% O& ~& W  Q2 T2 \2 K7 f" N0 Z" y4 s  W
cd /root
1 U" i, C  I$ ]9 f1 F( U( f" E" a( E$ p  o' k. `8 y* h8 E9 p) y  G0 \
cat install.log | grep -v "^*" |  awk '{print $2}' >package.txt, z- N' z% c" X3 h: @1 m, r7 C% n

) c3 M# l9 f+ Q3 F2 kfor i in $(cat package.txt); do cp /media/Packages/${i}* /root/os/ ; done0 p* _7 E: V0 @9 C# Z7 g/ A8 k7 t2 V

' ?8 P! A9 {& s; O$ \4.创建光驱yum仓库.* a9 F; [* Y7 y" C% K0 c( O* Z
% j; j1 ?1 f6 g0 o4 P2 [, m
cp /media/repodata/*c6-x86_64-comps.xml  /root/minimal-x86_64.xml; Z+ V& Q+ p  [) ^6 ^! D0 `
$ M! ^- }! k) u, m6 A; |
5.重新生成repo
0 l$ q4 d- x3 }4 x
! I' G3 l! |* b6 z  declare -x discinfo=$(head -1 /root/os/.discinfo
7 h2 d( x# q# ^" n5 c  k
: Q1 G5 X; K. N! H  l. o) R  createrepo -u "media://$discinfo" -g /root/minimal-x86_64.xml /root/os/
  b* j& l# z4 m5 U
( b2 R4 i7 z0 Q6 ~" Q6.cp ks.cfg  /root/os/isolinux/    
9 ~7 K. {7 B1 ]+ s7 {4 [% T' O  x+ |
   cat  /root/os/isolinux/isolinux.cfg * \9 T6 W# x5 V! E5 }+ K% S3 F

; C+ L& A  I% h% y: {2 h! z9 h3 q9 A( X6 l8 l. o

0 H6 q) }* G% x; gdefault vesamenu.c32$ x% x* i! U' s6 N
#prompt 16 Y( I6 C/ q# c) k5 ~4 W
timeout 100! g% G, }5 `1 w3 E0 D

. j% K4 _; t6 Z- Jdisplay boot.msg
4 }; y5 [1 T; V2 D0 M; b5 k! G- r" f
menu background splash.jpg
6 i& M, \. e  i1 c$ jmenu title Welcome to CentOS 6.9!5 S& ~& p* F8 e$ [1 I; U
menu color border 0 #ffffffff #00000000
  b( P8 F  ]& Smenu color sel 7 #ffffffff #ff000000
: @" X! ?# q( \9 C' [7 Amenu color title 0 #ffffffff #00000000
, ^. k0 [) Y1 Amenu color tabmsg 0 #ffffffff #00000000. h. z* O+ v9 u
menu color unsel 0 #ffffffff #00000000! `1 P/ \. x. ^* g
menu color hotsel 0 #ff000000 #ffffffff8 b3 S! [( w% W+ w
menu color hotkey 7 #ffffffff #ff0000008 \$ z( Y7 m, M& ]/ U6 ~
menu color scrollbar 0 #ffffffff #00000000
1 X$ L8 _0 @! ^5 W+ l: ^2 K1 Z3 e! q
+ ~/ q. ~$ n. \* O# G5 X
, V; k2 D/ N. V7 A! e3 {* Y% Y) Rlabel linux
4 `0 _+ x: f  F3 \  menu label ^Install system  6 M% O" Q; Y6 W0 W  I; b: b% Y. s
  menu default
1 |& G( M2 j3 K$ c' y  kernel vmlinuz
6 H8 i# f5 ]) j# P' _# A  append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg# F9 s3 ?$ z3 \* y. x
9 ?$ `6 f5 d0 H2 U2 B- ?: }

4 S; ]( ]& n" _  i& i9 ]0 [
: s' R! Z5 y9 u7 ]3 G) ^7.制作iso
% t' E7 l9 a/ w1 d: X6 E* c2 L! a2 {, e+ \3 C
cd /root4 `3 r4 N8 [$ |! @2 C5 e1 [1 i5 S' Z

- Y# c0 D  F- O1 H" p7 umkisofs -o OS-6.9_64.iso -input-charset utf-8 -b isolinux/isolinux.bin -c      isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T -joliet-long  /root/os/
; U9 I3 M  n5 C) V
+ a) V" i/ p" Q# c/ K
' Y7 O8 M6 W2 }$ G
; G: q3 x1 r; h( T! R8.生成iso文件md5值
& e/ M, C' U8 a/ I/ Z6 s6 T" ?1 o- p( {6 N" r) N' c
implantisomd5    OS-6.9_64.iso, _0 v9 |# _" S

9 W/ \  b& B' s; z$ Q. D# J6 a& v) \
7 U- s& ]3 v  ?6 J, q$ F) n' _4 ?' y5 G0 b- q+ |! u4 L: n* v1 \

0 m6 x+ E6 |% G1 I/ N
* q8 A  J: J1 c8 ?$ _( ^装系统测试^_^+ ^1 n7 B$ S0 K  @
5 t' S7 k2 J# i% A1 q' _
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 03:02 , Processed in 0.021693 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表