Liunx之Centos系统无人值守全自动化安装
作者:邓聪聪
定制centos6.8自动安装ISO光盘
- 安装系统为centos6.8 (base server),安装方式为全新安装
- 使用ext4分区格式
- 安装前可以交互输入root密码,主机名,分区大小,然后安装过程自动化
- 关闭防火墙,selinux
- 网络为dhcp方式获取
- 时区为Asia/Shanghai
- 分区表类型为mbr
- 默认设置三个分区,boot分区200M,swap分区200M,其余为根分区
安装步骤
安装制作系统镜像所需要的工具
yum -y install mkisofs createrepo
创建光盘挂载目录、资源重构目录、自定义数据库目录
mkdir /mnt/iso (挂载光盘)
mkdir /data/iso (ISO目录)
挂载CentOS系统光盘,并复制光盘目录下的内容到其他路径下,由于光盘内容权限为“只读”,可赋予权限直接修改或者cp新文件给权限修改。
mount -o loop /data/iso/CentOS-6.8-x86_64-minimal.iso /mnt/iso
创建自响应文件 ks.cfg ,把此文件放在/data/iso/isolinux/ks.cfg
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
#interactive
# Root password
rootpw --plaintext
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
#text
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
network --onboot=yes --device=eth0 --bootproto=dhcp --noipv6
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# 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=
part swap --fstype="swap" --size=
part / --fstype="ext4" --grow --size=1 repo --name="CactiEZ" --baseurl=file:///mnt/source --cost=100
%packages --nobase
@core
%post --nochroot
mkdir -p /mnt/sysimage/tmp/cactiez >> /tmp/ins.log 2>&1
cp /mnt/source/Packages/cactiez-x86_64.tgz /mnt/sysimage/tmp/cactiez >> /tmp/ins.log 2>&1
%post
cd /tmp/cactiez >> /tmp/ins.log 2>&1
tar zxvf cactiez-x86_64.tgz >> /tmp/ins.log 2>&1
cp -rf /tmp/cactiez/var/www/html/* /var/www/html >> /tmp/ins.log 2>&1
cp -rf /tmp/cactiez/usr/* /usr >> /tmp/ins.log 2>&1
cp -rf /tmp/cactiez/etc/* /etc >> /tmp/ins.log 2>&1
sed -i "s/GSSAPIAuthentication no/GSSAPIAuthentication yes/g" /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/g" /etc/ssh/sshd_config
echo "nameserver 219.141.140.10" >> /etc/resolv.conf
/sbin/chkconfig iptables off
%end
修改启动安装导向文件/data/iso/isolinux/isolinux.cfg,下面为修改后内容
default vesamenu.c32
#prompt
timeout
menu background splash.jpg
menu title Welcome to use CentOS 6.8!
menu color border #ffffffff #
menu color sel #ffffffff #ff000000
menu color title #ffffffff #
menu color tabmsg #ffffffff #
menu color unsel #ffffffff #
menu color hotsel #ff000000 #ffffffff
menu color hotkey #ffffffff #ff000000
menu color scrollbar #ffffffff #
label linux
menu label ^Install PowerSoft OS
menu default
kernel vmlinuz
append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
定制ISO光盘所需的数据
.discinfo文件 一定要复制过来,建议复制完之后检查该文件是否存在!!!
rm -fr /data/iso/repodata
declare -x discinfo=$(head -1 .discinfo)
cp /mnt/iso/repodata/*-c6-minimal-x86_64.xml ./c6-minimal-x86_64.xml
cd ..
createrepo -g repodata/c6-x86_64-comps.xml ./
重构系统,生成ISO镜像 --用于CentOS6.此步骤需要在iso的配置文件主目录中我这里是(/data/iso/)
mkisofs -o CentOS-.5_64.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size -boot-info-table -R -J -v -T /data/iso/
重构系统,生成ISO镜像 --用于CentOS 7
genisoimage -v -cache-inodes -joliet-long -R -J -T -V CENTOS7 -o /root/centos7.iso -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size -boot-info-table -eltorito-alt-boot -b images/efiboot.img -no-emul-boot .
在CentOS7 中无法使用%post的参数ks.cfg配置文件如下:
#version=DEVEL
install
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
#graphical
text
# Run the Setup Agent on first boot
firstboot --disabled
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --onboot=yes --ipv6=auto --no-activate
network --hostname=begon
# Root password
rootpw 12345678
firewall --disabled
selinux --disabled
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
#autopart --encrypted --type=lvm
bootloader location=mbr
clearpart --all --initlabel
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=300
part / --fstype xfs --size=1 --grow
#Reboot after installation
reboot --eject
%packages
@^minimal
@core
kexec-tools
%end
%post
systemctl stop firewalld
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
在CentOS7 中isolinux.cfg配置文件如下:
[root@bogon isolinux]# cat isolinux.cfg
default vesamenu.c32
timeout display boot.msg # Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title CentOS
menu vshift
menu rows
menu margin
#menu hidden
menu helpmsgrow
menu tabmsgrow # Border Area
menu color border * # # none # Selected item
menu color sel #ffffffff # none # Title bar
menu color title #ff7ba3d0 # none # Press [Tab] message
menu color tabmsg #ff3a6496 # none # Unselected menu item
menu color unsel #84b8ffff # none # Selected hotkey
menu color hotsel #84b8ffff # none # Unselected hotkey
menu color hotkey #ffffffff # none # Help text
menu color help #ffffffff # none # A scrollbar of some type? Not sure.
menu color scrollbar #ffffffff #ff355594 none # Timeout msg
menu color timeout #ffffffff # none
menu color timeout_msg #ffffffff # none # Command prompt text
menu color cmdmark #84b8ffff # none
menu color cmdline #ffffffff # none # Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message. menu tabmsg Press Tab for full configuration options on menu items. menu separator # insert an empty line
menu separator # insert an empty line label linux
menu label ^Install CentOS
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet label check
menu label Test this ^media & install CentOS
menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet label linux
menu label ^Install CentOS7 CentOS7.
menu default
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg menu separator # insert an empty line # utilities submenu
menu begin ^Troubleshooting
menu title Troubleshooting label vesa
menu indent count
menu label Install CentOS in ^basic graphics mode
text help
Try this option out if you're having trouble installing
CentOS .
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet label rescue
menu indent count
menu label ^Rescue a CentOS system
text help
If the system will not boot, this lets you access files
and edit config files to try to get it booting again.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet label memtest
menu label Run a ^memory test
text help
If your system is having issues, a problem with your
system's memory may be the cause. Use this utility to
see if the memory is working correctly.
endtext
kernel memtest menu separator # insert an empty line label local
menu label Boot from ^local drive
localboot 0xffff menu separator # insert an empty line
menu separator # insert an empty line label returntomain
menu label Return to ^main menu
menu exit menu end
Liunx之Centos系统无人值守全自动化安装的更多相关文章
- Centos系统下Docker的安装
一.检查内核版本 安装Docker,需要linux内核大于3.10 使用uname -r 来检查 二. Centos系统下Docker的安装 1. 安装需要的软件包 yum install -y yu ...
- kickstart半自动安装centos系统与pxe自动安装centos系统
一.kickstart半自动安装centos系统 关闭防火墙,关闭selinux,使用system-config-kickstart生成kickstart配置文件,启动xmanger-Passive ...
- CentOS 系统下使用 yum 安装 Redis
本文主要介绍在 CentOS 7 系统下使用 yum 安装 Redis 的过程. 更改 yum 源 将 Centos 的 yum 源更换为国内的阿里云源. 首先备份你的原镜像文件,保证出错后可以恢复: ...
- Centos系统下卸载、安装MySQL及用户的创建、授权和使用(详细。。。。)
由于经常使用linux系统,并且大数据环境搭建中经常会使用到mysql,不像windows系统下的安装,今天有点空写一篇,下面我给大家演示一遍. 主要有三部分内容: 1.MySQL的卸载 2.MySQ ...
- Linux系统实现ansible自动化安装配置httpd
1.使用ansible的playbook实现自动化安装httpd 1)首先配置好ansible的hosts文件,让其对应主机能够受ansible控制 提示:我们在主机清单上配置了所管控的主机地址,但是 ...
- CentOS系统下docker的安装与卸载
Docker简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化.容器是完全使用沙箱机制, ...
- CentOS 6.4一键自动化安装ISO镜像光盘
下载CentOS-6.4-x86_64-minimal.iso 1 http://mirrors.163.com/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-mi ...
- 【新技术】CentOS系统下docker的安装配置及使用详解
1 docker简介 Docker 提供了一个可以运行你的应用程序的封套(envelope),或者说容器.它原本是dotCloud 启动的一个业余项目,并在前些时候开源了.它吸引了大量的关注和讨 ...
- CentOS系统rsync文件同步 安装配置
rsync是类unix系统下的数据镜像备份工具,从软件的命名上就可以看出来了——remote sync 它的特性如下: 可以镜像保存整个目录树和文件系统. 可以很容易做到保持原来文件的权限.时间.软硬 ...
随机推荐
- 《Go并发编程实战》读书笔记-初识Go语言
<Go并发编程实战>读书笔记-初识Go语言 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在讲解怎样用Go语言之前,我们先介绍Go语言的特性,基础概念和标准命令. 一. ...
- Linux安装npm并打包前端代码
查看node版本$ node -v查看npm版本$ npm -v如果没有安装node及npm,需要先安装node及npm#yum install node# yum install npm安装cnpm ...
- Java插件之Jrebel
Jrebel是干嘛的?当你在Java Web的项目中修改一些代码的时候(成员代码),想要生效必须重启服务器.但是每次修改代码都得重启服务器?重启着时间很长的,太麻烦了. Jrebel隆重出场,它可以使 ...
- 16、JDBC-DBUtils封装
使用DBUtils写个通用CURD小工具 依赖配置 pom.xml <?xml version="1.0" encoding="UTF-8"?> & ...
- 设计模式---数据结构模式之组合模式(Composite)
前提:数据结构模式 常常有一些组建在内部具有特定的数据结构,如果让客户程序依赖这些特定的数据结构,将极大的破坏组件的复用.这时候,将这些数据结构封装在内部,在外部提供统一的接口,来实现与特定数据结构无 ...
- hdu 6418(石头剪刀布 **)
题意是说双方各有剪刀,石头和布的卡片各 a,b,c,a‘,b',c' 张,对方是随机选择,问我方的最大预期得分. 这道题目一开始看到的时候感觉没有头绪,再次读题,发现题目说结果可能是分数,如果是分数的 ...
- JavaScript 从入门到放弃(二)模块化工具requirejs
入门教程: 1.JS模块化工具requirejs教程(一):初识requirejs 2.JS模块化工具requirejs教程(二):基本知识 描述 这几天在使用github最活跃的基于bootstra ...
- HashMap 集合的遍历
HashMap 集合的遍历: 两种方式遍历HashMap: //集合hashMap的遍历: //方式一: @Test public void testMethod1(){ HashMap<Str ...
- linux修改主机名,关闭图形化界面,绑定ip地址,修改ip地址
1关闭图形化界面 vi /etc/inittab 改成id:3:initdefault: 注意:不要选0或6 2.修改主机名 vi /etc/sysconfig/network 修改即可 3,修改ip ...
- GCC编译器原理(三)------编译原理三:编译过程(2-2)---编译之语法分析
2.2 语法分析 语法分析器(Grammar Parser)将对由扫描器产生的记号进行语法分析,从而产生语法树(Syntax Tree).整个分析过程采用了上下文无关语法(Context-free G ...