定制启动光盘实现Linux半自动化安装

admin 2022年12月11日 440次浏览

1、准备启动文件

[root@test-host ~]# mkdir /myiso
[root@test-host ~]# cp -r /mnt/isolinux/ /myiso/
[root@test-host ~]# tree /myiso/
/myiso/
└── isolinux
    ├── boot.cat
    ├── boot.msg
    ├── grub.conf
    ├── initrd.img
    ├── isolinux.bin
    ├── isolinux.cfg
    ├── memtest
    ├── splash.png
    ├── TRANS.TBL
    ├── vesamenu.c32
    └── vmlinuz

1 directory, 11 files

2、准备安装文件

[root@test-host ~]# mkdir /var/www/html/centos7/
[root@test-host ~]# mount /dev/cdrom /var/www/html/centos7/

3、准备kickstart文件

kickstart 相关信息请参考:使用应答文件自动安装linux系统

[root@test-host ~]# mkdir /var/www/html/ks_file
[root@test-host ~]# vim /var/www/html/ks_file/centos7.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext 123456
# System language
lang zh_CN
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx


# Firewall configuration
firewall --disabled
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url="http://192.168.137.100/centos7"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=1024
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1

%post --interpreter=/usr/bin/bash
useradd user
echo 123456 | passwd --stdin user
sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
%end

%packages
@^infrastructure-server-environment
@base
@core

%end

[root@test-host ~]# chmod 644 /var/www/html/ks_file/centos7.cfg

4、制作启动文件

[root@test-host ~]# vim /myiso/isolinux/isolinux.cfg
label linux
  menu label ^Auto Install CentOS 7
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.137.100/ks_file/centos7.cfg quiet

label rescue
  menu indent count 5
  menu label ^Rescue a CentOS system
  kernel vmlinuz
  append initrd=initrd.img inst.repo=http://192.168.137.100/centos7 rescue quiet

label local
  menu default
  menu label Boot from ^local drive
  localboot 0xffff
menu end

5、制作ISO文件

[root@test-host ~]# yum install mkisofs -y
[root@test-host ~]# mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "centos7 x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/my_centos7_boot.iso /myiso/