2017-4-30 - create customized CentOS ISO & Installation Udisk
2017-4-30 - create customized CentOS ISO & Installation Udisk
ISO Generation
- install minimal CentOS6.9
1.1 network is disabled after firstboot, so enable it
- sed -i '/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-eth0
- service network restart
1.2 enable yum cache, so that we can figure out the extra packages under /var/cache/yum/…
- sed -i '/keepcache=o/keepcache=1/g' /etc/yum.conf
1.3 install wget and unzip, rsync used to download and unzip oakmgr install image
- mkdir -p /root/oakmgr_install
- cd /root/oakmgr_install
- yum install -y wget unzip rsync
- wget -O 1.zip 'http://139.196.170.238:8000/f/90b5b579b9/?raw=1'
- unzip 1.zip
- prepare the new ISO root directory, and sync all files from original CD except Packages, and repdata directory
- mkdir /dev/cdrom
- mount /dev/cdrom /mnt/cdrom
- mkdir -p /ISO/{Packages,repodata}
- rsync -a --exclude=Packages/ --exclude=repodata/ /mnt/cdrom/ /ISO/
- analyze /root/install.log and cp the useful rpm to new ISO root directory
- cd /root
- awk '/Installing/{print $2}' install.log | sed 's/^*://g' > package.txt
-
- DVD='/mnt/cdrom/Packages'
- PACKDIR='/root/package.txt'
- NEW_DVD='/ISO/Packages'
-
- while read LINE
- do
- cp ${DVD}/${LINE}*.rpm /${NEW_DVD} || echo "$LINE don't cp..."
- done < package.txt
-
- rm -rf package.txt
- generate ks.cfg based on /root/anaconda-ks.cfg
- cd /ISO
- cp /root/anaconda-ks.cfg isolinux/ks.cfg
- vi isolinux/ks.cfg
ks.cfg
- # Kickstart file automatically generated by anaconda.
-
- #version=DEVEL
- install
- text
- cdrom
- lang en_US.UTF-8
- keyboard us
- network --onboot yes --device eth0 --bootproto dhcp --noipv6
- rootpw --iscrypted $6$3o1deF8J0xweYap4$2vG3kVQfJxhYBb.v/qGaHeJApOcwK16fOrfkwu6kYjTBYnrKyaPTHGshgVIg3YQf/ZPS8u/Biq2gxse.weYOp.
- firewall --service=ssh
- authconfig --enableshadow --passalgo=sha512
- selinux --enforcing
- firstboot --disable
- 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 --all --initlabel --drives=sda
-
- part /boot --fstype=ext4 --size=500
- part pv.008002 --grow --size=1
-
- volgroup vg_oakmgr --pesize=4096 pv.008002
- logvol / --fstype=ext4 --name=lv_root --vgname=vg_oakmgr --grow --size=1024 --maxsize=51200
- logvol swap --name=lv_swap --vgname=vg_oakmgr --grow --size=2048 --maxsize=2048
-
- #repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
-
- reboot --eject
-
- %packages --nobase
- @core
-
- %post --nochroot --log=/mnt/sysimage/root/post_cp.log
- umount /dev/cdrom
- mkdir -p /mnt/source
- mount /dev/cdrom /mnt/source
-
- %post --log=/root/post_install.log
- cd /mnt/source/oakmgr_install
- ./setup.sh
-
-
- %end
-
- add ks.cfg into isolinux.cfg to enable it during install
- chomd 644 isolinux/isolinux.cfg
- vi isolinux/isolinux.cfg
- chmod 444 isolinux/isolinux.cfg
isolinux.cfg
- append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img
- modify oakmgr_install/installer/installer.sh
- read -t3 -n 1 PRODUCT_TYPE
- [ "$?" -ne 0 ] && PRODUCT_TYPE="4"
- read -t 3 -n 1 isContinue
- [ "$?" -ne 0 ] && isContinue="Y"
- copy oakmgr_install into new iso directory
- rsync -a /root/oakmgr_install /ISO/
- generate packages metadata
- createrepo -v -g /mnt/cdrom/repodata/*-minimal-x86_64.xml ./
- declare -x discinfo=`head -1 .discinfo`
- createrepo -u "media://$discinfo" -g repodata/*-minimal-x86_64.xml .
- generate iso, and setup md5sum
- mkisofs -o CentOS-6.9_64.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /ISO/
- /usr/bin/implantisomd5 /ISO/CentOS-6.4_64.iso
- test it with vmware
Installation Udisk
- make partition on udisk
- cfdisk /dev/sdb
- ext2 100M for boot
- ext2 others for store iso and oakmgr_install
- generate bootable udisk based on minimal ISO
- mkdir /mnt/{cdrom,boot,data}
- mount /dev/cdrom /mnt/cdrom
- mount /dev/sdb1 /mnt/boot
- mount /dev/sdb2 /mnt/data
-
- cp -a /dev/cdrom/isolinux /mnt/boot/syslinux
- cd /mnt/boot/syslinux && mv isolinux.cfg syslinux.cfg
- cp CentOS6-minimal-x86_64.iso /mnt/data
- cp ~/oakmgr_install /mnt/data/
- add kickstart script
- vi /mnt/boot/syslinux/ks.cfg
/mnt/boot/syslinux/ks.cfg
- # Kickstart file automatically generated by anaconda.
-
- #version=DEVEL
- install
- text
- harddrive --partition=sda2 --dir=
- lang en_US.UTF-8
- keyboard us
- network --onboot yes --device eth0 --bootproto dhcp --noipv6
- rootpw --iscrypted $6$3o1deF8J0xweYap4$2vG3kVQfJxhYBb.v/qGaHeJApOcwK16fOrfkwu6kYjTBYnrKyaPTHGshgVIg3YQf/ZPS8u/Biq2gxse.weYOp.
- firewall --service=ssh
- authconfig --enableshadow --passalgo=sha512
- selinux --enforcing
- firstboot --disable
- timezone --utc Asia/Shanghai
- bootloader --location=mbr --driveorder=sdb,sda --append="nousbstorage 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 --all --initlabel --drives=sdb
- ignoredisk --only-use=sdb
- part /boot --fstype=ext4 --size=500
- part pv.008002 --grow --size=1
-
- volgroup vg_oakmgr --pesize=4096 pv.008002
- logvol / --fstype=ext4 --name=lv_root --vgname=vg_oakmgr --grow --size=1024 --maxsize=51200
- logvol swap --name=lv_swap --vgname=vg_oakmgr --grow --size=2048 --maxsize=2048
-
- reboot --eject
-
- %packages --nobase
- @core
-
- %post --nochroot --log=/mnt/sysimage/root/post_cp.log
- umount /dev/sda2
-
- %post --log=/root/post_install.log
- mkdir /mnt/source
- mount /dev/sda2 /mnt/source
- cd /mnt/source/oakmgr_install
- ./setup.sh
-
-
- %end
-
- add ks.cfg into syslinux.cfg
- kernel vmlinuz
- append ks=hd:sda2:/ks.cfg initrd=initrd.img
- install syslinux
- cp /usr/lib/syslinux/bios/*.c32 /mnt/boot/syslinux/
- extlinux --install /mnt/boot/syslinux
- dd bs=440 count=1 if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sdb
- cp /mnt/cdrom/images /mnt/data
- modify oakmgr_install/installer/installer.sh
- read -t3 -n 1 PRODUCT_TYPE
- [ "$?" -ne 0 ] && PRODUCT_TYPE="4"
- read -t 3 -n 1 isContinue
- [ "$?" -ne 0 ] && isContinue="Y"
- test with vmware
- add new harddisk with(SICS:0:0) into vmware with udisk
2017-4-30 nicephil@gmail.com