rhel7红帽7制作全自动安装光盘-实战

一、配置本地yum源

1 将光驱挂载在/mnt下
mount    /dev/cdrom  /mnt
2  设置本地源安装
 把/etc/yum.repos.d/这个目录下的repo文件备份然后删除
3.修改源
vi /etc/yum.repos.d/rhel-source.repo
[media]
name=Server
baseurl=file:///mnt
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

二、复制光盘文件

1、首先创建编辑目录:
mkdir /root/rhel7_iso

复制光盘文件:
cp -rf /mnt* /root/rhel7_iso

diskinfo文件需求单独拷贝下:
cp /root/rhel7_iso/.discinfo /root/iso

三、安装启动kickstart软件

先安装kickstart,再启动kickstart,然后点鼠标配置,配置完了点击文件->保存->保存到哪 就是生成一个ks.cfg的文件,里面的配置就是你刚才点鼠标配置的。
yum -y install system-config-kickstart
system-config-kickstart

2 编辑ks.cfg文件

系统安装的时候,按照ks.cfg文件的内容进行安装,我们把ks.cfg文件放到isolinux目录下:

cd /root/centos7_iso/isolinux

vim ks.cfg
我的ks.cfg文件内容如下:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# System language
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8
# Root password
rootpw --iscrypted $1$iy8XLJQ7$8ZaGl1J/6SAoAwe.Tw.D2.
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled

# Firewall configuration
firewall --disabled
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# X Window System configuration information
xconfig  --startxonboot
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /boot         --fstype=xfs     --size=500         --ondisk=sda
part /boot/efi    --fstype=xfs   --size=500  --ondisk=sda
part pv.01                              --size=133120      --ondisk=sda
part pv.02            --grow            --size=200         --ondisk=sda       
volgroup rootvg    --pesize=16384 pv.01
logvol swap                          --name=lv_swap     --vgname=rootvg --size=16384
logvol /           --fstype=xfs     --name=lv_root     --vgname=rootvg --size=102400
logvol /nmon       --fstype=xfs     --name=lv_nmon     --vgname=rootvg --size=5120

%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11

%end

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end
注意:

1)因为rhel7系统网卡规则更复杂,为了ks.cfg更通用,最好ks.cfg不用制定网卡配置。

2)为了兼容mbr方式和EFI方式,同时创建了/boot和/boot/efi分区。

3配置mbr引导方式

编辑isoliuux目录下的isolinux.cfg文件,添加自己的内容,在isolinux.cfg文件中label linux下面添加自己的label:

label linux
  menu label ^Install Red Hat Enterprise Linux 7.5
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.5\x20Server.x86_64 quiet

label custom
  menu label ^Custom Red Hat Enterprise Linux 7.5
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg
注意点:

1)memu label 后面的内容是在光盘引导起来菜单的内容,^后面的字母是菜单的快捷键;

2)通过inst.ks关键字指明ks.cfg文件位置;

3)inst.stages2标识的是系统按照介质位置,这里使用hd:LABEL表明寻找的是label为CENTOS7的安装介质,使用LABEL关键字的好处是可以精确指定安装介质,为什么label是CENTOS7,是因为我在制作光盘镜像的时候指定的,方法在后面有介绍。


四、配置EFI引导方式

进入光盘目录EFI/BOOT/,编辑grub.cfg文件,添加自己的菜单:

menuentry 'Install Red Hat Enterprise Linux 7.5' --class fedora --class gnu-linux --class gnu --class os {
        linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-7.5\x20Server.x86_64 quiet
        initrdefi /images/pxeboot/initrd.img
}

menuentry 'Costomer Red Hat Enterprise Linux 7.5' --class fedora --class gnu-linux --class gnu --class os {
        linuxefi /images/pxeboot/vmlinuz ks=cdrom:/isolinux/ks.cfg   quiet
        initrdefi /images/pxeboot/initrd.img
}
和mbr方式类似,指明ks.cfg文件位置和安装源位置。

五、生成iso镜像

生成镜像,并且能在EFI和mbr环境安装的镜像生成命令如下:
cd /root/rhel7_iso
mkisofs -v -cache-inodes -joliet-long -R -J -T -V RHEL75 -o /root/rhel7.iso    \
-c isolinux/boot.cat    -b isolinux/isolinux.bin      \
-no-emul-boot -boot-load-size 4 -boot-info-table    \
-eltorito-alt-boot     -b images/efiboot.img       -no-emul-boot .

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

力哥讲技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值