定製自己的CentOS系統

來源:互聯網
上載者:User

標籤:定製自己的centos系統


將CentOS重新打包成一個新ISO,可以自動分區、選擇原件包,快速安裝系統。

1.掛載光碟機,建立臨時目錄
    mount /dev/cdrom /mnt/cdrom
    mkdir -p /root/iso/CentOS

2.使用cp.sh指令碼提取需要的RPM包,正常安裝好作業系統在/root目錄下會有install.log檔案,這個就是作業系統安裝RPM包的記錄,我們從這些記錄中,將所需的RPM包從/mnt/cdrom/Packages中複製到/root/iso/CentOS裡面去

    #!/bin/bash
    cd /root
    awk ‘/Installing/{print $2}‘ install.log | sed ‘s/^[0-9]*://g‘ >package.txt
    DVD=‘/mnt/cdrom/Packages‘
    PACKDIR=‘/root/package.txt‘
    NEW_DVD=‘/root/iso/CentOS/‘
    while read LINE
    do
    cp ${DVD}/${LINE}*.rpm /${NEW_DVD} || echo "$LINE don‘t cp......."
    done < package.txt

3.把原鏡像除了Packages目錄外的檔案全部複製至/root/iso目錄下

    rsync -a --exclude=Packages /mnt/cdrom/  /root/iso


4.把/root目錄下的anaconda-ks.cfg複製至/root/iso目錄下,並根據自己實際需要修改安裝要求

    #version=DEVEL
    install
    text
    cdrom
    lang en_US.UTF-8
    keyboard us
    network --onboot no --device em1 --bootproto dhcp --noipv6
    network --onboot no --device em2 --bootproto dhcp --noipv6
    rootpw 123456    ----預設密碼
    firewall --disabled  ----關閉防火牆
    authconfig --enableshadow --passalgo=sha512
    selinux --disabled   ----禁用selinux
    timezone --utc Asia/Shanghai
    bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
    # The following is the partition information you requested
    # Note that any partitions you deleted are not expressed
    # here so unless you clear all partitions first, this is
    # not guaranteed to work
    #clearpart --none
    clearpart --all --initlabel
    zerombr
    part /boot --fstype=ext4 --size=200
    part swap --size=32000
    part pv.008003 --grow --size=200
    ignoredisk --only-use=sda
    volgroup volGroup00 --pesize=4096 pv.008003
    logvol / --fstype=ext4 --name=LogVol00 --vgname=volGroup00 --size=200000
    logvol /data --fstype=ext4 --name=LogVol01 --vgname=volGroup00 --size=1655232
    reboot
    #repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100
    %packages
    @chinese-support
    @core
    @server-policy
    %end

5.讓ISO按照anaconda-ks.cfg檔案來執行安裝

    vi /root/iso/isolinux/isolinux.cfg
    Default vesamenu.c32 修改成 default linux ks=cdrom:/anaconda-ks.cfg

6.使用repo.sh指令碼重建repo檔案

    #!/bin/bash
    ISO_DIR=/root/iso
    cd  ${ISO_DIR}
    declare -x discinfo=$(head -1 .discinfo)
    mv   ${ISO_DIR}/repodata/*x86_64-comps.xml     ${ISO_DIR}/repodata/c6-x86_64-comps.xml
    createrepo   -g   ${ISO_DIR}/repodata/c6-x86_64-comps.xml  ${ISO_DIR}
    #createrepo -u "media://$discinfo" -g  ${ISO_DIR}/repodata/c6-x86_64-comps.xml   ${ISO_DIR}
    mv   ${ISO_DIR}/repodata/*x86_64-comps.xml     ${ISO_DIR}/repodata/c6-x86_64-comps.xml
    createrepo -u "media://$discinfo" -g  ${ISO_DIR}/repodata/*c6-x86_64-comps.xml   ${ISO_DIR}

7.製作ISO
    yum -y install mkisofs
    mkisofs -o MyCentOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /root/iso/

執行命令後會在目前的目錄產生一MyCentOS.iso檔案,這樣一個定製版的CentOS就出來了。


 **參考介面**
http://kling.blog.51cto.com/3320545/1249962
http://lihuipeng.blog.51cto.com/3064864/759122

定製自己的CentOS系統

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.