制作iso光盤
今天給大家帶來的是如何制作一個完整的ISO,包括KS應達文件和rpm包。制作完成後拷貝到U盤裏面,就可以直接在別的機器上安裝centos系統。
一、cp光盤內容
cp -rv /misc/cd /app/centos6iso
二、刪除TRANS.TBL
find /app/centos6iso/ -name TRANS.TBL -ok rm {} \;
現在還不需要TRANS.TBL文件,如果不刪除,啟動會失敗
三、刪除repodata
rm -rf /app/centos6iso/repodata
四、還原repodata
createrepo -g /misc/cd/repodata/43d8fd068164b0f042845474d6a22262798b9f0d1f49ad1bf9f95b953089777d-c6-x86_64-comps.xml /app/centos6iso/
repodata裏面記錄了yum源
五、創建KS應達文件
mkdir /app/centos6iso/ksdir
1、創建ks-mini.cfg文件
cp anaconda-ks.cfg ks-mini.cfg
vim ks-mini.cfg內容如下:
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
url --url="http://172.17.0.1/centos/6"
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth1 --bootproto dhcp --noipv6
rootpw --iscrypted $6$tXmSEQTX.96Oxlwf$CS6RX80cUp/M/ME7NudrGH8uMtQA32fq9qWHGpda
VOyFExQGZtG3aBGcbHikxZ5Q69YR5pDJaF98C3MtCDU5b1
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone 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
part /boot --fstype=ext4 --size=1024
part / --fstype=ext4 --size=51200
part swap —size=2048
repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
%packages
@core
@server-policy
@workstation-policy
autofs
%end
%post
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=http://172.17.0.1/centos/6
gpgcheck=0
EOF
useradd wang
echo magedu |passwd --stdin wang
%end
2、創建ks-desktop.cfg文件
cp anaconda-ks.cfg ks-desktop.cfg
vim ks-desktop.cfg內容如下:
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
url --url="http://172.17.0.1/centos/6"
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth1 --bootproto dhcp --noipv6
rootpw --iscrypted $6$tXmSEQTX.96Oxlwf$CS6RX80cUp/M/ME7NudrGH8uMtQA32fq9qWHGpda
VOyFExQGZtG3aBGcbHikxZ5Q69YR5pDJaF98C3MtCDU5b1
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone 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
part /boot --fstype=ext4 --size=1024
part / --fstype=ext4 --size=51200
part /app --fstype=ext4 --size=51200
part swap —size=2048
repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
%packages
@core
@server-policy
@workstation-policy
autofs
@desktop
%end
%post
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=http://172.17.0.1/centos/6
gpgcheck=0
EOF
useradd wang
echo magedu |passwd --stdin wang
%end
cp /root/ks-mini.cfg /app/centos6iso/ksdir
cp /root/ks-desktop /app/centos6iso/ksdir
七、制作菜單文件/app/centos6iso/isolinux/isolinux.cfg
default vesamenu.c32
#prompt 1
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS Autoinstall!
label desktop
menu label Auto Install a ^desktop system
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/ksdir/ks-desktop.cfg
label mini
menu label ^Auto Install a mini system
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/ksdir/ks-mini.cfg
label manual
menu label ^Manual Install a system
kernel vmlinuz
append initrd=initrd.img
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
八、制作光盤
mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 - -boot-info-table -V "Autoinstall centosboot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/centos6boot.iso /app/centos6iso
到此為止一個光盤就安裝成功
制作iso光盤