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

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-3-13 22:53:35 | 显示全部楼层 |阅读模式

. d/ c" K8 K( i) U( g  <environment>  b# w( Y  S8 k' `, r0 A) c; g0 U
    <id>ceph</id>
6 [8 R1 q9 }& ?, \4 }9 X    <name>CEPH S3 SERVER</name>
  V. H, z: \: h( N: I, v    <name xml:lang="zh_CN"> ceph</name>
/ x9 V/ M3 H: T( p3 O* e    <description>CEPHServer</description>
/ `) L% V6 Y( h    <description xml:lang="zh_CN"></description>' }: J' _8 F5 f  t9 ]- M
    <display_order>9</display_order>
+ a2 \& r2 |. c& C- y6 m" k! L    <grouplist>- ~6 J$ N0 j/ }6 T, J
      <groupid>core</groupid>
" c5 w. `, E# c1 a, b* o0 y      <groupid>gbasic</groupid>/ R* T( `% z  x
      <groupid>gceph</groupid>9 `  p: {: C3 Y2 X

, S3 S& T" w4 y. J, J3 o    </grouplist>+ ^' m( E% r! F* K

  G& G. w1 j/ { <optionlist>( o/ R( {$ x: O8 K" ~8 w, C7 e
3 K/ a9 f' p  P0 Q. P- U1 ?1 Q! z3 n
      <groupid>gim</groupid>2 S0 c+ a" E+ l7 S: H9 Y; C$ j
5 }' `+ K6 u3 H7 i: z& g0 ?
      <groupid>giam</groupid>$ c5 R: M, T  u
  </environment>0 r8 p1 L* Q' y# Y9 u) _1 l

* d. D- O7 N3 c4 x$ L+ i* i8 L7 \...
. ?" Z$ `% N/ H& v5 e+ p! `  J$ b- V& i# b: I  X- K
:wq!保存退出  
! v  [0 k1 f, P5 J! Y
& b1 T9 u+ S; G: `' B  Z: e以上修改会在安装系统可选软件中列出自己的软件。 optionlist项为可附加可选项。自定义的软件如init-ceph。可以放在根目录的任务文件夹下。我们统一放在 Extra/mirrors/sunrunpaas/5 @6 R: i9 p" W& ~

& y5 H7 K* ]$ j* [, ~5 j如:. Y0 `. J. i( H8 U  x4 N, L' z

3 a' H$ ~: Y5 G( H. f1 Y/ `ceph/          php5.6/        sunrundfs/     sunruniaas/    sunrunim/      sunrunvas/      
4 X; y2 P4 h6 o  V  Z3 q5 }* M& Hmariadb/       sunrun-common/ sunrunhac/     sunruniam/     sunrunslb/     TRANS.TBL3 C" r9 Q* f" \+ {: w8 ]

; l! r- e( r" n3 d) C5 D) v: X7 V2 m& L
0 Y. G/ W& M- N! u4 r
) w& s# q' A* v1 X& d% z
2.2 ,定制作自己的界面
1 l9 t' Q( H! w; f3 M( n6 W7 q/ r- R& s( W
   2.2.1定制作引导界面。
8 P) R* z. ^- b2 s( k
# F4 ~- U+ P2 `# q. h- ? 修改 isolinux/isolinux.cfg0 A2 [5 Z0 j2 l. z) f! z; p- ]
/ i6 U9 b; Y2 |+ U* J8 _
label linux
9 V, d. G/ G1 z1 Z& p( H6 ^  menu label ^Install SunrunOS 1/ f+ {$ j( I1 E: d
  kernel vmlinuz
, k/ Z+ I: {" o  y; \2 u9 n* c8 \$ y$ a( l% Y
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS7 inst.ks=cdrom:/ks.cfg  quiet
1 Z" g8 o( O+ ?+ V( ]; q
3 F* l. V* d7 m6 S' `...4 p7 Q  m, x- A

, p, B+ n8 l2 ?  Z/ Z 2.2.2 定制图标和文字。, \- d( b# M  `7 T+ j

5 W6 C$ H* I1 q) Y( S: I  F    系统安装界面里的图标与文件修改。对应的图片在LiveOS/squashfs.img中,需要解压,修改,再压缩回去。
9 x; b8 ?' {/ U+ I# x) ^. `
) L  X& ^8 z9 o" \    unsquashfs squashfs.img
3 K5 x6 z1 h. K% h; l  e# r
& l! S4 [1 N4 x: V9 C7 A0 s  K) P  Y  产生squashfs-root 目录。
' |+ B0 K% t  C3 a' H: X/ c2 Y7 Q4 }$ z* s0 }/ [8 v8 H
  squashfs-root/LiveOS/
! K, c+ @5 e3 z! U' R3 Z+ t( t& b
! s, g3 I( R7 y  mkdir tmp
" i* e! i- j% z0 }& s# i6 K. o, c: a4 J' `$ S
  mount rootfs.img tmp/
4 R! D+ o* s! q. u2 S4 w3 ~
0 `3 I; o$ |) {  X; M& B# R0 r- ]  下载,修改,替换下图:
0 P# Q1 d7 t8 j# _& A" ?$ {' x
  E8 U$ O$ @. n. o+ |6 |) l6 @   usr/share/anaconda/pixmaps/sidebar-logo.png
7 C& p$ R4 a7 f. D' P* a, d8 k7 I$ E9 _: R: [5 ?1 W

/ H6 i3 U/ b# ?( P3 N
8 {4 j& H( p; G5 r7 j( w/ r修改usr/lib64/python2.7/site-packages/pyanaconda/product.py
* A% n; o' j* p# _3 ~
. C. d! B. D* g0 e  s9 r% J8 ?def distributionText():
3 a) @1 x6 p2 u6 W+ J8 f! D& y    return _("%(productName)s %(productVersion)s INSTALLATION") % \
* H5 K5 B; \* g& Z7 h             {"productName": "SUNRUNOS", "productVersion": "1"}
2 ?; h! t3 Q" a$ ^4 `
9 f3 G8 ^) z. z6 q" L- k7 e0 X/ K

. V$ T# z' E4 O9 w% e- P' R5 w2 }完成修改,生产新的squashfs.img. h. y2 Z: D* z( p# e$ s

$ l' }9 L0 j( {  _: {2 Fumount tmp/
+ P5 s1 S5 ]6 w' }; |/ q- }, r8 b, l2 M9 t1 ~  o
cd ../../# b2 [, W& Y1 V3 a( h6 w

# H' n& F4 x9 A7 O0 w, jrm squashfs.img5 S: `0 F3 M4 {7 u9 }" {& u

% s" g" E& C; S8 v. M- x+ \ mksquashfs squashfs-root squashfs.img
8 I- v8 h* t6 ^* p& h
. D$ @: `$ [: \6 i' G3, 定制安装流程" w- E' D  N& K4 \% _6 K# U
/ m2 o0 f9 ^0 h, e- r9 Z( j
   cp /root/anaconda-ks.cfg /cloud/iso/centos7.2/ks.cft
6 ~5 z* s6 a6 N
9 F1 M8 W1 r- G) F. d# j如下:" H) _0 x4 l; r" J  L

3 w. Y- y# L- n' H; I$ W#version=Chen CentOS
& h6 u8 }9 D* a. h( D. I2 s! j$ m0 i; k7 h
#platform=x86, AMD64, or Intel EM64T
3 r' f* ?$ F$ ^, B0 D4 ]: I5 y# Install OS instead of upgrade
4 s' p3 S  R* B  M: Z" Q#repo --name="sunrundvd"  --baseurl="file:///opt/sunrun-dvd/Extra/Packages/"
) u" T" j# u, e$ F, G9 a3 E  Tinstall 3 M: k0 w9 v& ~. T
# Keyboard layouts - g: `& H5 [( b' w3 [
keyboard --vckeymap=us --xlayouts='us' ' K9 c8 l# G( a/ J" |0 x
# Root password
- n# {- s! x8 z; ]2 qrootpw --iscrypted $1$password$mV5CPMXkUkvImOukQuVs..
) v( W' F# G, l+ Z; n- q# System language
4 l/ t9 a" Y+ B" F+ L& l7 Ylang en_US.UTF-8 4 x3 I& B; v/ n5 p( i. x6 h
# Firewall configuration
+ d% e: O6 E  jfirewall --disabled
5 e+ r3 k+ J7 e# System authorization information
2 {/ P* j% s- V4 |auth  --useshadow  --passalgo=sha512 5 x  g$ q* V) q! ^3 l& S! P
# Use CDROM installation media
' O5 Q- @1 U" c  z; ~1 I: f& vcdrom 3 Z9 ^5 ?* ^9 U' m, x6 L
# Use text mode install
. G9 S7 d+ U  m: f% f#text   E: R- e; ]: D
# Run the Setup Agent on first boot
8 Z5 k5 s1 F8 {firstboot --enable : m( j5 d0 E4 ]# T8 j
ignoredisk --only-use=sda 1 X% _- P+ Y; W1 B& D
# SELinux configuration + r6 O& m7 y* X& u
selinux --disabled 1 ^4 Z2 U/ `! P8 T* m* `
# Do not configure the X Window System
; E0 w/ N' n. Y  V' O- A4 y- w#skipx $ \9 P* Q2 }+ i2 u5 g
8 F( E+ k2 q8 @+ y
0 [( D: Z  P! z$ \$ U5 _0 D
# Network information 8 U0 B1 ~% ]/ W% {" B( {) b
network  --bootproto=dhcp --device=ens160 --onboot=yes --ipv6=auto --activate
3 z  F) C0 k+ q#network  --device=ens160 --hostname=localhost.localdomain
* f6 W  b! ^( b- I" L$ F/ r+ s1 c4 l9 z! l
. H; [: O8 W4 x7 X; O
%post --nochroot 5 {9 l9 Q( \7 w
# 写到rootfs里去
5 x: t! o& c, A2 s* Irm -rf /mnt/sysimage/etc/yum.repos.d/* 6 F4 y& P$ B( n* k1 u$ n4 c* P- I* C
#mkdir -p /mnt/sysimage/mnt/iso # T/ A8 X1 }2 m3 Z
#\cp -rf /run/install/repo/Extra/repos/* /mnt/sysimage/etc/yum.repos.d/
" y0 ^. w  Z/ `; u2 O# T! B6 K  F) r) y/ \
%end
" a: E: t/ t$ [# c/ T
( w, w6 {+ {/ b8 E# Reboot after installation % v0 N* S7 x6 W$ Z' h( N3 w
reboot
8 M3 O$ a% Y% Y- h9 B5 S! w# System timezone
& ~+ E+ S; p' `. U6 Ktimezone Asia/Shanghai --isUtc
8 o9 j1 b* i3 y) F9 C# System bootloader configuration
& S' l# P. c, c1 Ibootloader --location=mbr --driveorder=sda --append="" % r! ~- c7 \/ H5 f& F$ X
# Clear the Master Boot Record 0 Y- C4 U: x8 E6 r' f( x# B. ~% u
zerombr
  j( D+ @3 }" c7 V# Partition clearing information
# P* d' h1 C% T. H! g5 X" B- z  jclearpart --all --initlabel
0 L, t( R: \9 e1 B2 c" D( W* N- Qautopart --type=lvm 6 h' X3 k: B8 c  a8 ]

5 x: g$ l) D% Y4 W& D9 _. A0 O2 u7 W  K# b$ s  a! e1 H
#%packages
# ^" ]! G4 h8 o: _8 I#@^minimal
3 L* }, l/ ~* @  m5 D! N; q#@core 6 C! }8 g! K& i1 @8 F( I$ s# x8 p

1 m; D: H) R; c/ x  a% `' K1 @" r# a) U
#%end9 t; \, B+ X5 V" R

& E" o/ Y; |6 L" Y  ?% ~
5 N) o' y; z8 h5 U$ K. q8 e4,重新生成镜像:
. g2 Q! n2 ^1 N) s, k' C0 f2 F, Z1 i% n$ Q" T1 E6 }$ n7 [4 C
rm -rf repodata/*
2 ~. }) _4 `2 T4 \/ V
% g8 X# \! n6 G9 I6 O; v8 Q) s! o" W5 s8 g: w, G# z" D8 `$ B; l' j

% s; B# H% t# Z" B! \5 Ncreaterepo -g comps.xml .% B& X3 h* f( ~$ c+ u
2 J' b' F/ n8 N  m0 ^' R

9 F8 f& `3 W" o) z  R8 a
0 l, `5 J3 S! |genisoimage -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 ./
" t8 D  i! m+ @% D# }
1 P/ l, _9 H; n7 w5 o# @5完成   ../c76.iso 即是我们的作品。$ f+ g3 M6 O) J$ I8 o; I# m
% R) |: y2 b1 r, N6 V8 L) k
; U% F4 T8 B: v% D2 f; A# t

) @8 r8 l; H. \4 k1 C) Q( p: ^) J9 {/ X) u- ^% c

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 -: {! H; t+ ?3 W, F+ a
no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T -joliet-long -V EVGLOW /root/iso/CentOS7.4-evglow/
- R5 [6 E0 D* o/ ?' i. N. p
1 R6 f, r& H* L( w

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
    9 M7 }4 ?* G# _2 R$ g

    9 O, U  L( [/ r/ }
. z3 f2 R, }( s7 ~" H

8 v' }. V# w1 R, j3 O  G: T2 N" R

二、配置 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( V; T) a/ k: U- R9 r+ b, G

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/4 s6 j/ O' o- A9 u
    * [/ C3 N/ s8 w  s& t8 w9 u! t: t

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/7+ p% `' V% m- ^1 \; h7 L

两者的区别就是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命令兼容。
% R4 M" @  y4 r7 l3 Q# s0 R" R4 T

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-3-16 11:01:01 | 显示全部楼层
vi /root/ks.cfg5 @. |# E9 l' \: h' f

7 f7 \% r( `5 p& J# n0 |install6 G2 O! n/ z4 w, s+ R- R+ ^
cdrom/ h3 h1 A: i4 E8 @0 w( `- G2 |9 Q* M
lang en_US.UTF-8! L4 o: _% t. v
keyboard us' f) O) N" J) `6 h1 ^& l3 m  T" Z
network --onboot no --device eth0 --bootproto dhcp --noipv6. O' H2 j% ^0 @( V) J9 c
rootpw  --iscrypted $6$ZI78JvmQ56MxYSe3$dn9UV./VvFieP25R94ciYo4wg7p17sM8gCt2WQa/hqMeHiynnBqL/abF14D0AOSXjnptoBHqLYGhzun6W7Qfr1  r6 a9 X4 N2 k) d0 U
firewall --service=ssh! d. \! Y) R) v- l- j
authconfig --enableshadow --passalgo=sha512
' ?; `5 @( x- d+ d5 T) ?ignoredisk --only-use=sda
! r% h8 J0 |) ]/ B" qselinux --disabled% f4 ^/ c$ |% X/ ~
timezone Asia/Shanghai! `" X& D; Y. F0 u
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
/ T! R" m) A* }# tclearpart --all --initlabel  --drives=sda9 f9 D( A+ O2 _9 v
part /boot --fstype=ext4 --size=200) \% Z7 ]# b1 h( o
part / --fstype=ext4 --size=20000( ?( k" h' i  J5 f
part swap --size=2048
. y) O( E! V7 o# spart /data --fstype=ext4 --grow --size=1
* P' \" l& e; T" k) L/ V& ureboot
2 y+ b/ V0 R1 I  C' B) \$ d%packages
0 z6 E* q/ v8 Z@core
8 D2 W& u3 d' F: V@server-policy0 @  `1 G6 j. B" u' i! j5 ]2 p* Y
@workstation-policy- v5 B% _; ~8 c

3 |! N! g1 ]+ }+ S+ ]- B%post$ ]9 J6 h/ M. E' ~* v
#add user9 Q( w* U  R, p. `
useradd pos
+ K* o$ G  {+ n3 o: z" \echo "12341234" | passwd pos --stdin! D4 e# X2 \% A0 B
#service
8 H  y4 F" m1 p$ `. H7 d1 x3 z. z( Hfor i in `chkconfig --list | grep 3:on | awk '{print $1}'`; do echo $i; chkconfig $i off; done
/ ^- C4 s% q5 n7 K) f! v5 \for i in auditd crond network  rdma  rsyslog sshd udev-post; do echo $i ; chkconfig $i on; done7 u  u# A" n+ Y

  Y& e1 X7 m5 G4 u) _8 U" h9 Y#profile
. ^  a* j) G7 v$ V1 f* {2 yecho "ulimit -SHn 51200">>/etc/profile
% J( i$ n! T4 `- a- R6 iecho "TMOUT=6000" >>/etc/profile
: T0 k! o$ w& \. a/ G1 s) R/ p
* Y5 D! |" f- J6 Y+ O  j/ n#passwd& f% Y1 }# ]4 N* i) d/ l
echo "admin"  | passwd root --stdin" ]* `4 s; Z2 W* b$ @+ e) K* @
" d+ z% `2 s0 G8 y  L+ c
#ssh login slowly2 n; D  s8 |, L3 Y
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
8 L$ V" l8 T) k2 X' C" used -i "s/GSSAPICleanupCredentials yes/GSSAPICleanupCredentials no/" /etc/ssh/sshd_config& ^: G' R: W% W6 }
/etc/init.d/sshd restart: E( ?3 k! j1 Z8 S  Q4 v' w
% y6 M( @# w0 Y% E4 i# x3 G. J
rm -fr /tmp/*
$ {2 _( y' W4 F2 }) F, t%end1 n% B' j* P2 d) x4 Z. A+ d4 K% e
& H0 i' S& d4 l. ]
2.  yum install createrepo mkisofs isomd5sum squashfs-tools -y# d9 V2 z+ S( D! s* j+ ~
& F9 y1 u  w3 w
    mkdir /root/os
3 c1 N7 }: \# `* M. S9 }  I  e2 x$ V/ k) N- e9 G, w7 |
   将以os为iso制作目录.
, F) n, C" c: ^- A
; }4 J+ R: ~% ^5 }9 I( K$ Zmount /etc/cdrom/   /media, `8 I7 n3 v2 U6 D( c# c& B

- H& B8 H+ p" Q+ Z# i- G! R& U; I6 \rsync -a --exclude=Packages/ --exclude=repodata/ /media/   /root/os/8 s. y1 V3 k6 D, c
* G. f2 w; \. Y' P! v. x
mkdir -p /root/os/{Packages,repodata}9 Z9 ?( _: k8 E2 }

. R, Y2 n/ A1 P3.拷贝mimi 包3 y. r$ G& z- w, e
; X4 r3 n5 _6 I
cd /root0 w* R% y3 |: v& V
4 J' O% T$ s# I# l) m! y
cat install.log | grep -v "^*" |  awk '{print $2}' >package.txt
7 \3 w8 k2 U3 ?0 e) |( d+ N
6 J2 z* h; J1 \$ ~, I. l. A+ D- _for i in $(cat package.txt); do cp /media/Packages/${i}* /root/os/ ; done
' _& I  n9 N/ J; F' m* C
* Y' A- Y% h6 j* L& k4.创建光驱yum仓库.
+ \+ I, j4 Q, j# x" l) B$ W
: v- x6 Z% h; H& Q0 Lcp /media/repodata/*c6-x86_64-comps.xml  /root/minimal-x86_64.xml
5 o9 p8 K% h& V9 C3 {' a. T
& M% i8 d4 x) A( h' x  J5.重新生成repo3 z* l) J$ ^- `% B

0 T5 [5 p, e' f% c6 D1 w; s  declare -x discinfo=$(head -1 /root/os/.discinfo! g0 p& L% b5 Z
5 a5 N1 Q( ]5 \( D! U4 ?8 X
  createrepo -u "media://$discinfo" -g /root/minimal-x86_64.xml /root/os/. P+ D0 r" {# f; }( c: O
" U- S4 [( q$ n" H. c
6.cp ks.cfg  /root/os/isolinux/    
( k, ^: L) s( D3 R5 o' W6 f( Z! {& X
   cat  /root/os/isolinux/isolinux.cfg 3 X5 O9 R. A- o3 D( N
/ @% {# D  W( \$ j
, R& V4 ?* l  |1 [1 v

3 [" s, t( @- }3 A: w( _( Bdefault vesamenu.c32/ E) W7 h, M2 l' x2 P: I3 z
#prompt 1
2 N/ ^4 f) Z5 Q  K" T' _! P6 c! ctimeout 100* n8 t& B! c- W% r% ?

& W4 I" q1 d0 k5 h  y* |display boot.msg
+ H  W0 {3 b% g8 E0 f/ @4 L% G* Q2 X9 s* s
menu background splash.jpg3 V% s. M3 f' t4 H- |
menu title Welcome to CentOS 6.9!
1 I) j1 r( t+ M. y" ~menu color border 0 #ffffffff #00000000
' n0 p& d' p5 ~6 i0 _. ]0 i  s/ l, rmenu color sel 7 #ffffffff #ff0000005 O4 o; m, ~7 o( ^5 S! V4 Y
menu color title 0 #ffffffff #00000000
2 U3 n/ r1 m: }" }2 W/ K. C& amenu color tabmsg 0 #ffffffff #00000000
5 K4 G3 R: T* A- a8 D/ o( dmenu color unsel 0 #ffffffff #00000000# T, Q' s/ s: n  W5 }* u1 ~
menu color hotsel 0 #ff000000 #ffffffff  m% G% L; K- m/ Z  G
menu color hotkey 7 #ffffffff #ff000000
9 o0 d4 b  ^0 a, c) [; ]' X- D. [  Omenu color scrollbar 0 #ffffffff #00000000
+ o/ @9 l8 `$ D* x& M
; ]* i) U: d% i' C" s. [! b% b+ [+ Q) L  e+ Y9 l3 ]. W
label linux
7 Y& d4 M8 q# n" d/ }, O8 Y  menu label ^Install system  
* H! ?4 y# B2 L. O# B1 s1 z6 E* m& d  menu default
) ]+ G5 C5 j+ {3 K  kernel vmlinuz4 z$ m+ [9 K( c" G8 o: o9 @
  append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg
7 t' d: i  I1 b5 ~
7 f& {: u8 L+ e6 s+ W; ~" O2 Z
8 }) |  U8 g& q' `+ A0 b% O& u: \: j: v! S2 N7 {
7.制作iso
$ D/ g* v& [6 A9 j, G3 e, o# K
( R. a+ f: ^9 ycd /root
( \' L. P" r/ s; u" l* c5 h9 m& j
8 U* V1 k' M3 smkisofs -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/, @; c" ]1 z5 {( c; r" k6 H

! @) H, t$ J" i5 l2 P) D' Q3 [
. \* s* w9 }2 n2 q) l
8.生成iso文件md5值
; G( R" O+ _. l4 ~4 U3 Z4 ]: _+ D: |, y( t+ L4 u2 s1 }
implantisomd5    OS-6.9_64.iso5 S* @" r7 D' G0 N' Z8 ^; Z

9 k3 w# s& ]' d6 N. x- H. l/ q9 i% P# Q' _, m6 i: `, S4 _

: a% p' l* b2 M
* n3 `% z, t9 ]3 R: V  I. h/ c  I( F  R' q# z7 G) {( ]  e0 D* j
装系统测试^_^
3 G5 t7 P/ q* T0 t) j7 }4 B3 f' D" z
$ r/ I+ ^  Q6 Z+ t6 [
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 04:10 , Processed in 0.026708 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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