2010年10月6日 星期三

製作CentOS 自動安裝光碟

我用的OS版本為 CentOS 5.2 32bit, 應該RedHat和Fedora也適用

1. 先手動安裝CentOS
   安裝完後,安裝過程的記錄檔anaconda-ks.cfg會放在/root下

2. 在/tmp下建立目錄cdrom
mkdir /tmp/cdrom

3. 將CentOS DVD光碟裡的檔案複製到/tmp/cdrom
cp -fr /mnt/cdrom /tmp/cdrom  

4. 複製自動安裝腳本檔anaconda-ks.cfg
cp /root/anaconda-ks.cfg /tmp/cdrom/ks.cfg   
多個腳本檔時
mkdir /tmp/cdrom/isolinux/ks

cp /root/anaconda-ks.cfg /tmp/cdrom/isolinux/ks/ks.cfg



5. 修改ks.cfg檔,將你切Partition 的註解#拿掉
# 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


6. 讓安裝時預設使用ks.cfg
vi /tmp/cdrom/isolinux/isolinux.cfg
    第一行改成
default linux ks=cdrom:/ks.cfg
  
6. 產生iso檔
cd /tmp
mkisofs -o full.iso -b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T cdrom


7. 完成

8. 安裝時如要指定不同的腳本檔, 可在安裝CentOS時輸入
linux ks=cdrom:/ks/ks.cfg