定制屬於自己的自動化安裝的linux系統鏡像


使用軟件和平台
1、基於平台:                  Vmware workstation 8.0
2、基於系統鏡像:               rhel-server-5.8-i386-dvd.iso  
3、ISO編輯軟件:               UltraISO
4、自定義配置文件:             ks.cfg
5、需要重新編輯的配置文件:      isolinux.cfg
6、其他:                     針對不需要的文件包進行刪減
 
        
 
        
第一步生成ks.cfg文件
我這里使用的遠程連接工具是Xmanager Enterprise 4,可以支持在當前系統上打開遠程主機的圖形軟件界面。
1、首先確認kickstart是否安裝,沒有安裝的話使用yum進行安裝
1
2
3
4
5
6
7
8
9
10
11
12
#檢查 kickstart是否安裝
[root@lovelace ~] # rpm -qa | grep kickstart
system-config-kickstart-2.6.19.9-2.el5
pykickstart-0.43.9-1.el5
#使用yum安裝 kickstart
[root@lovelace ~] # yum install system-config-kickstart -y
Loaded plugins: katello, security
Repository rhel-debuginfo is listed more than once in the configuration
Unable to read consumer identity
Setting up Install Process
Package system-config-kickstart-2.6.19.9-2.el5.noarch already installed and latest version
Nothing to do
2、啟動Xmanager - Passive服務,然后在終端上輸入命令system-config-kickstart &  
xerror
如果執行上面的命令彈出錯誤,請在終端輸入以下兩條命令
xhost
3、再次進行測試,如果還不成功,請查看服務是否開啟,上面兩條命令執行是否成功
 
        
注:這里為了方便大家進行配置,直接在現有系統的基礎上進行編輯。
4、在彈出的圖形界面點擊文件---->打開文件---->root目錄下---->anaconda-ks.cfg文件---->確定。
啟動項
5、開始我們的ks.cfg文件編輯過程(選擇語言,鍵盤類型,時區,設置根口令,安裝后是否重啟引導系統,在文本模式下進行安裝)
kickstart界面
6、安裝方法的選擇(這里我們是對磁盤進行全新封裝的,選擇執行新安裝,安裝方法為光盤驅動器)
安裝方式選擇

7、引導裝載程序選項,(給內核傳遞參數rhgb quiet ,其他默認即可)

mbr安裝

8、分區信息設置,這里我們新建三個分區(/分區:5G, /boot:200M, swap分區:1G)

分區划分

9、網絡配置(這里選擇添加eth0網卡,IP為dhcp自動分配)

網絡設置

10、驗證方式默認即可

驗證配置

11、防火牆配置(這里選擇禁用)

防火牆設置

12、顯示配置(這里我們選擇安裝X界面,色彩深度調整為16,RHEL上默認安裝的是gnome)

顯示配置

13、軟件包安裝選擇(按需自定義選擇)

軟件包安裝

14、預安裝腳本(按需進行設置)

預安裝腳本

15、安裝后腳本(按需進行設置)

14、保存配置好的文件(可自定義存放路徑,這里我們存放到/home目錄下)

文件保存

查看生成的ks.cfg配置文件

 

1
2
3
4
#驗證ks.cfg文件是否存在
[root@lovelace home] # pwd;ll ks.cfg
/home
-rw-r--r-- 1 root root 1649 05-27 04:20 ks.cfg

查看ks.cfg文件     具體參數請查看kickstart文檔

 

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
[root@lovelace home] # cat ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --append= "rhgb quiet" --location=mbr --driveorder=sda
# Partition clearing information
clearpart --none
# Use text mode install
text
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
key --skip
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use CDROM installation media
cdrom
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$ /3RmiuX/ $ZqpoSJEqBLYu93wL6a60R1
# SELinux configuration
selinux --enforcing
# System timezone
timezone --isUtc Asia /Shanghai
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig  --defaultdesktop=GNOME --depth=8 --resolution=640x480
# Disk partitioning information
part / --bytes-per-inode=4096 --fstype= "ext3" --size=6000
part /boot --bytes-per-inode=4096 --fstype= "ext3" --size=200
part swap --bytes-per-inode=4096 --fstype= "swap" --size=1024
%packages
@base
@development-libs
@core
@development-tools
@sound-and-video
@x-software-development
@gnome-desktop
@base-x
@printing
@gnome-software-development
@admin-tools
@legacy-software-support
@editors
@text-internet
@dialup
@graphics
@office
@java
@graphical-internet
@games
kexec-tools
iscsi-initiator-utils
fipscheck
device-mapper-multipath
sgpio
python-dmidecode
imake
emacs
libsane-hpaio
mesa-libGLU-devel
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb

 

 

第二步:修改isolinux.cfg配置文件(有多種方向進行選擇,這里不再演示)

修改后內容為(Note:網上好多關於這個配置文件各不相同,只要能夠實驗成功就行)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@lovelace home] # cat isolinux.cfg
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: /ks .cfg initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

  

 

第三步:重新封裝iso鏡像文件(win下操作)

1、打開原版iso鏡像文件(刪除自動的isolinux.cfg文件,然后把我們重新編輯過的文件添加進去)

定制iso替換isolinux文件

2、添加我們制作的ks.cfg文件到光盤根目錄下,然后進行iso文件生成即可

添加ks.cfg文件

第四步:測試安裝(這里截兩張圖驗證下)

測試安裝3

最終

 

 

后記:其實做這個也沒有多大意義,因為生產環境中都是批量部署的,這里希望大家能夠了解下關於ks.cfg文件的編輯方法,如果你很熟悉的話,也可以脫離圖形編輯,直接命令行進行設置…..

存在的bug:

1、安裝后swap分區沒有被自動掛載

2、沒有對系統包和組件進行裁剪,只是添加了ks.cfg文件和對isolinux.cfg文件進行了添加和修改

3、進入系統后沒有主機名為.不知道是啥情況

4、只在虛擬機上進行驗證


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM