亚欧色一区w666天堂,色情一区二区三区免费看,少妇特黄A片一区二区三区,亚洲人成网站999久久久综合,国产av熟女一区二区三区

  • 發布文章
  • 消息中心
點贊
收藏
評論
分享
原創

Linux x86 ISO系統鏡像定制

2024-07-03 09:53:04
38
0

一、流程簡介

  1. 準備目標系統iso鏡像,將其解壓到某個目錄下。(Linux中可以掛載后再復制光盤內容到目錄下,或者Windows直接打開然后復制到共享目錄下等方法)
  2. 添加需要新增的文件、腳本、軟件包等到該目錄下,可以自己創建新目錄進行管理
  3. 配置kickstart文件,設置用戶密碼、磁盤分區、安裝后運行腳本等
  4. 修改grub.cfg(UEFI安裝模式)或isolinux.cfg(BOOT安裝),在安裝菜單欄選項中補充inst.ks配置,指定kickstart配置文件路徑
  5. 通過genisoimage命令生成新鏡像

二、定制鏡像示例

(一)x86系統

  1. 解壓iso鏡像到某個目錄下,幾個關鍵的目錄說明:
    1. configuration是自己創建的文件夾,將ks配置、shell腳本、驅動等文件都放在該目錄中
    2. EFI放著UEFI模式安裝時使用的引導文件
    3. isolinux放著BOOT模式安裝時使用的
    4. Package放著所有的rpm包
  2. 將所需的shell腳本、驅動包等放入configuration中相應的目錄下,如drivers、shell目錄
  3. 將ks配置文件放到configuration/ks目錄下,ks文件可以找一臺已經安裝好的系統,基于/root/anaconda-ks.cfg為基礎進行修改,或者通過kickstart圖形化工具配置生成
    kickstart官方文檔介紹:第 27 章 Kickstart 安裝 Red Hat Enterprise Linux 7 | Red Hat Customer Portal
    這里為BOOT和EFI安裝模式分別創建了ks-server-7.cfg和ks-server-7-uefi.cfg的ks配置文件
  4. 修改ks配置文件,以BOOT安裝模式的ks-server-7.cfg為例,給出了一個配置示例,在主要地方進行了注釋
    #version=DEVEL
    # System authorization information
    auth --enableshadow --passalgo=sha512
    # Use CDROM installation media
    cdrom
    # Use graphical install
    graphical
    # Run the Setup Agent on first boot
    firstboot --enable
    ignoredisk --only-use=sda
    # Keyboard layouts
    keyboard --vckeymap=us --xlayouts='us'
    # System language
    lang en_US.UTF-8
     
    # Network information
    network  --bootproto=dhcp --hostname=localhost.localdomain --activate
    #network  --bootproto=dhcp --device=eth0
    network  --bootproto=dhcp --device=ens33
    # Reboot after installation
    reboot
    # Root password,在這里設置root密碼,使用sha512加密
    rootpw --iscrypted $6$16_CHARACTER_SAL$7J8EKTQ9M5Ds81llIXBThGsfeuvOdywLs/whlUgfiroltnTm8tPPULCauZGgB8jybcRJ7ILBSCY4VBA8RGUcZ/
    # SELinux configuration
    selinux --disabled
    # System services
    services --disabled="chronyd"
    # Do not configure the X Window System
    skipx
    # System timezone
    timezone Asia/Shanghai --isUtc --nontp
    # System bootloader configuration 需要保證系統有sda磁盤
    bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
    # Clear the Master Boot Record
    zerombr
    # Partition clearing information
    clearpart --all --initlabel
     
    # Disk partitioning information 磁盤自動分區,需要保證有sda磁盤,size單位為MB
    part /boot --fstype="ext4" --size=2001 --ondisk=sda
    part / --fstype="xfs" --grow --size=153601 --ondisk=sda
    part /home --fstype="xfs" --size=20480 --ondisk=sda
     
    #firewall --enabled --service=ssh
     
    # 指定需要預安裝的包,@^minimal和@core的內容可以在光盤目錄下的comps.xml查看
    %packages
    @^minimal
    @core
    # ...此處省略一些包
    %end
     
    %addon com_redhat_kdump --enable --reserve-mb='auto'
    %end
     
    # 安裝后腳本,使用--nochroot將會在臨時系統中執行,此時iso掛載在/run/install/repo,安裝系統掛載在/mnt/sysimage
    # 可以在這里將iso中文件的拷貝到安裝系統中,如果使用掛載的方式經測試有個問題是不確定iso掛載的盤符,例如有可能是/dev/cdrom、/dev/sdb等,沒辦法寫死
    # --log可以指定日志到安裝系統目錄中
    %post --nochroot --log=/mnt/sysimage/root/ks-post-stage1.log
    # iso mount on /run/install/repo, centos mount on /mnt/sysimage
    mkdir -p /mnt/sysimage/root/ks-install/drivers
    # 拷貝一些驅動文件和腳本到安裝系統中
    cp /run/install/repo/configuration/drivers/xxx.zip /mnt/sysimage/root/ks-install/drivers
    %end
     
    # 安裝后腳本,不指定--nochroot,此時將會在安裝系統中執行
    # 可以在這里進行一些腳本的運行,配置文件、服務等等操作,等同于開機后的shell環境
    # --log可以指定日志到安裝系統目錄中
    %post --log=/root/ks-post-stage2.log
    sed -i '/ssh/d' /etc/firewalld/zones/public.xml || true
    # exec shell ...
     
    %end
  5. 修改啟動引導文件
    對于BOOT安裝模式,修改iso中的isolinux/isolinux.cfg,找到 Install CentOS 7 菜單,補充s配置inst.ks=hd:LABEL=CentOS\x207\x20x86_64:/configuration/ks/ks-server-7.cfg,hd:LABEL=CentOS\x207\x20x86_64為安裝介質所在盤符

  6. 對于UEFI安裝模式,修改iso中的EFI/BOOT/grub.cfg,找到 Install CentOS 7 菜單,補充配置inst.ks=hd:LABEL=CentOS\x207\x20x86_64:/configuration/ks/ks-server-7-uefi.cfg
  7. genisoimage生成鏡像
    #!/bin/sh
    # 指定需要制作的目標鏡像的生成路徑
    current_dir=`pwd`
    package_name=$current_dir/centos.iso 
    # 指定iso鏡像解壓并修改后的所在路徑
    cdrom=$current_dir/iso_dir
    cd $cdrom
    rm -rf repodata/
    createrepo -g comps.xml ./
    genisoimage -joliet-long -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -cache-inodes -T -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -V "CentOS 7 x86_64" -o $package_name $cdrom
    
0條評論
作者已關閉評論
c****k
8文章數
0粉絲數
c****k
8 文章 | 0 粉絲
原創

Linux x86 ISO系統鏡像定制

2024-07-03 09:53:04
38
0

一、流程簡介

  1. 準備目標系統iso鏡像,將其解壓到某個目錄下。(Linux中可以掛載后再復制光盤內容到目錄下,或者Windows直接打開然后復制到共享目錄下等方法)
  2. 添加需要新增的文件、腳本、軟件包等到該目錄下,可以自己創建新目錄進行管理
  3. 配置kickstart文件,設置用戶密碼、磁盤分區、安裝后運行腳本等
  4. 修改grub.cfg(UEFI安裝模式)或isolinux.cfg(BOOT安裝),在安裝菜單欄選項中補充inst.ks配置,指定kickstart配置文件路徑
  5. 通過genisoimage命令生成新鏡像

二、定制鏡像示例

(一)x86系統

  1. 解壓iso鏡像到某個目錄下,幾個關鍵的目錄說明:
    1. configuration是自己創建的文件夾,將ks配置、shell腳本、驅動等文件都放在該目錄中
    2. EFI放著UEFI模式安裝時使用的引導文件
    3. isolinux放著BOOT模式安裝時使用的
    4. Package放著所有的rpm包
  2. 將所需的shell腳本、驅動包等放入configuration中相應的目錄下,如drivers、shell目錄
  3. 將ks配置文件放到configuration/ks目錄下,ks文件可以找一臺已經安裝好的系統,基于/root/anaconda-ks.cfg為基礎進行修改,或者通過kickstart圖形化工具配置生成
    kickstart官方文檔介紹:第 27 章 Kickstart 安裝 Red Hat Enterprise Linux 7 | Red Hat Customer Portal
    這里為BOOT和EFI安裝模式分別創建了ks-server-7.cfg和ks-server-7-uefi.cfg的ks配置文件
  4. 修改ks配置文件,以BOOT安裝模式的ks-server-7.cfg為例,給出了一個配置示例,在主要地方進行了注釋
    #version=DEVEL
    # System authorization information
    auth --enableshadow --passalgo=sha512
    # Use CDROM installation media
    cdrom
    # Use graphical install
    graphical
    # Run the Setup Agent on first boot
    firstboot --enable
    ignoredisk --only-use=sda
    # Keyboard layouts
    keyboard --vckeymap=us --xlayouts='us'
    # System language
    lang en_US.UTF-8
     
    # Network information
    network  --bootproto=dhcp --hostname=localhost.localdomain --activate
    #network  --bootproto=dhcp --device=eth0
    network  --bootproto=dhcp --device=ens33
    # Reboot after installation
    reboot
    # Root password,在這里設置root密碼,使用sha512加密
    rootpw --iscrypted $6$16_CHARACTER_SAL$7J8EKTQ9M5Ds81llIXBThGsfeuvOdywLs/whlUgfiroltnTm8tPPULCauZGgB8jybcRJ7ILBSCY4VBA8RGUcZ/
    # SELinux configuration
    selinux --disabled
    # System services
    services --disabled="chronyd"
    # Do not configure the X Window System
    skipx
    # System timezone
    timezone Asia/Shanghai --isUtc --nontp
    # System bootloader configuration 需要保證系統有sda磁盤
    bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
    # Clear the Master Boot Record
    zerombr
    # Partition clearing information
    clearpart --all --initlabel
     
    # Disk partitioning information 磁盤自動分區,需要保證有sda磁盤,size單位為MB
    part /boot --fstype="ext4" --size=2001 --ondisk=sda
    part / --fstype="xfs" --grow --size=153601 --ondisk=sda
    part /home --fstype="xfs" --size=20480 --ondisk=sda
     
    #firewall --enabled --service=ssh
     
    # 指定需要預安裝的包,@^minimal和@core的內容可以在光盤目錄下的comps.xml查看
    %packages
    @^minimal
    @core
    # ...此處省略一些包
    %end
     
    %addon com_redhat_kdump --enable --reserve-mb='auto'
    %end
     
    # 安裝后腳本,使用--nochroot將會在臨時系統中執行,此時iso掛載在/run/install/repo,安裝系統掛載在/mnt/sysimage
    # 可以在這里將iso中文件的拷貝到安裝系統中,如果使用掛載的方式經測試有個問題是不確定iso掛載的盤符,例如有可能是/dev/cdrom、/dev/sdb等,沒辦法寫死
    # --log可以指定日志到安裝系統目錄中
    %post --nochroot --log=/mnt/sysimage/root/ks-post-stage1.log
    # iso mount on /run/install/repo, centos mount on /mnt/sysimage
    mkdir -p /mnt/sysimage/root/ks-install/drivers
    # 拷貝一些驅動文件和腳本到安裝系統中
    cp /run/install/repo/configuration/drivers/xxx.zip /mnt/sysimage/root/ks-install/drivers
    %end
     
    # 安裝后腳本,不指定--nochroot,此時將會在安裝系統中執行
    # 可以在這里進行一些腳本的運行,配置文件、服務等等操作,等同于開機后的shell環境
    # --log可以指定日志到安裝系統目錄中
    %post --log=/root/ks-post-stage2.log
    sed -i '/ssh/d' /etc/firewalld/zones/public.xml || true
    # exec shell ...
     
    %end
  5. 修改啟動引導文件
    對于BOOT安裝模式,修改iso中的isolinux/isolinux.cfg,找到 Install CentOS 7 菜單,補充s配置inst.ks=hd:LABEL=CentOS\x207\x20x86_64:/configuration/ks/ks-server-7.cfg,hd:LABEL=CentOS\x207\x20x86_64為安裝介質所在盤符

  6. 對于UEFI安裝模式,修改iso中的EFI/BOOT/grub.cfg,找到 Install CentOS 7 菜單,補充配置inst.ks=hd:LABEL=CentOS\x207\x20x86_64:/configuration/ks/ks-server-7-uefi.cfg
  7. genisoimage生成鏡像
    #!/bin/sh
    # 指定需要制作的目標鏡像的生成路徑
    current_dir=`pwd`
    package_name=$current_dir/centos.iso 
    # 指定iso鏡像解壓并修改后的所在路徑
    cdrom=$current_dir/iso_dir
    cd $cdrom
    rm -rf repodata/
    createrepo -g comps.xml ./
    genisoimage -joliet-long -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -cache-inodes -T -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -V "CentOS 7 x86_64" -o $package_name $cdrom
    
文章來自個人專欄
文章 | 訂閱
0條評論
作者已關閉評論
作者已關閉評論
0
0