CentOS7全自動安裝光盤製做詳解


CentOS7全自動安裝光盤製做詳解node

1 複製光盤文件linux

1)掛載iso鏡像ios

建立目錄用於掛載光盤:redis

mkdir /root/centos7

掛載iso鏡像vim

mount -o loop CentOS-7.0-1406-x86_64-DVD.iso/root/centos7

2)複製光盤文件到編輯目錄進行編輯centos

由於掛載上iso鏡像是隻讀的,若是要編輯,須要將文件複製出來,再編輯。bash

首先建立編輯目錄:網絡

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/isolinux
vim ks.cfg

個人ks.cfg文件內容以下:

#version=RHEL/CentOS7 by xiaoli110
install
# Keyboard layouts
keyboard 'us'
# Reboot after installation
reboot
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='cn'
# System language
lang 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 password
rootpw --iscrypted 111111111111111111111111111
# System timezone
timezone Asia/Shanghai
# System language
lang zh_CN
# Firewall configuration
firewall --enabled --ssh
 
# System authorization information
auth --useshadow  --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs"--size=500
part /boot/efi --fstype="xfs"--size=500
part swap --fstype="swap"--size=16000
part / --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

注意點:

1memu label 後面的內容是在光盤引導起來菜單的內容,^後面的字母是菜單的快捷鍵;

2)經過inst.ks關鍵字指明ks.cfg文件位置;

3inst.stages2標識的是系統按照介質位置,這裏使用hd:LABEL代表尋找的是labelCENTOS7的安裝介質,使用LABEL關鍵字的好處是能夠精確指定安裝介質,爲何labelCENTOS7,是由於我在製做光盤鏡像的時候指定的,方法在後面有介紹。

4 配置EFI引導方式

1EFI簡介

EFI可擴展固件接口(ExtensibleFirmware Interface 的縮寫),是英特爾主導推出的一種替代BIOS的升級方案。最先由英特爾開發,於2005年將此規範格式交由UEFI論壇來推廣與發展,後來並更更名稱爲Unified EFI(UEFI)UEFI論壇於200717日釋出併發放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鏡像

通過我踩過多個坑,成功的生成鏡像,而且能在EFImbr環境安裝的鏡像生成命令以下:

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

 

2genisop_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 的系統上。

3genisop_w_picpathmkisofsxorrios幾個命令的區別

提及genisop_w_picpathmkisofs,其實裏面是有點故事的。

最先的時候,Linux系統使用cdrtools工具來管理iso及光盤,mkisofscdrtools裏面的一個工具,後來cdrtools更好了了受權許可,從GPL修改成CDDL許可,開源社區又推出了一套基於GPL的工具,cdrkitmkisofs也被genisop_w_picpath去掉,如今系統中的mkisofs實際是genisop_w_picpath的軟鏈接:

ls -l /usr/bin/mkisofs
/usr/bin/mkisofs ->/etc/alternatives/mkisofs
ls -l /etc/alternatives/mkisofs
/etc/alternatives/mkisofs ->/usr/bin/genisop_w_picpath

xorrios是另一個比較流行的製做iso鏡像的工具,而且有一個參數-asmkisofs能夠和mkiso命令兼容。

相關文章
相關標籤/搜索