系统自动化安装

天涯浪子 提交于 2020-01-07 01:46:47

【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>

系统自动化安装

启动菜单介绍

Install or upgrade an existing system   安装或升级

Install system with basic video driver 在安装过程中发现显卡驱动不支持,造成屏幕无法显示,这时选择第二项,加载最基本的显卡驱动,这样让界面能够显示出来

Rescue installed system  救援模式

Boot from local drive     从本地硬盘启动

Memory test     内存的检查

这几项的区别就在于加的参数不同

选择一项,按 tab 键就可进入编辑模式

按 esc 键 ,在这个画面可以直接输入指令,指令为光盘文件的 isolinux/isolinux.cfg的 label 名

五个标签对应光盘开始菜单的五项

系统安装

询问系统安装源

安装程序启动过程

MBR:isolinux/boot.cat

stage2: isolinux/isolinux.bin

配置文件:isolinux/isolinux.cfg

    每个对应的菜单选项:

        加载内核:isolinuz/vmlinuz

        向内核传递参数:append initrd=initrd.img ...

装载根文件系统,并启动anaconda

    默认启动GUI接口

    若是显式指定使用TUI接口:向内核传递text参数即可

    (1)按tab键,在后面增加text

    (2)按ESC键:boot: linux text

ks.cfg 文件的生成

system-config-kickstart

 

 

 

 

 

 

 

 

 ksvalidator ks.cfg  //检测语法

Centos7的ks.cfg 

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext centos
# Use network installation
url --url="http://192.168.209.29/centos/7/os/x86_64/"
# System language
lang en_US
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --append="net.ifnames=0" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=500
part / --fstype="xfs" --size=20000
part swap --fstype="swap" --size=4000
part /data --fstype="xfs" --size=10000

%packages
@^minimal
autofs
vim-enhanced
yum-utils
bash-completion
net-tools
%end

%post
mkdir /root/.ssh
chmod 700 /root/.ssh
cat > /root/.ssh/authorized_keys <<EOF
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwpualz/J4IPBCNKKQR4HGa+Ag/dmxCqvouR9skVNUuX4yEoFDBW1gGog4s+a6Yit2XJvKU1jclNDll1VLHOXt2oTD1cUazS8D7lboOZ5gI/LDJ8DswS3VWMBPieejCoR8YsONAxI5/Z7Gyk/lOq53W6n4exr8Xq+H3SJNPRHERFrJknPhGJY2wDkPBCN1+sgcVg20ltQgd8zw1ICb0S6dyafZCjnsHJ4kYj7DXMYyl2wa6idWMWR2/XH+L9ktLgyTjm8FiJvtmcRg0olLIhy44M/D7NdVnsouTNxvTiSPZiBWQMwuOlU7LndQtWxadnEHimva8aJuIkKOIN/E+DNdw== root@centos6.9.localdomain
EOF
chmod 600 /root/.ssh/authorized_keys

mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

cat > /etc/yum.repos.d/base.repo <<EOF
[base]
baseurl=httpd://192.168.209.29/centos/7/os/x86_64/
gpgcheck=0
EOF
%end

Centos6的ks.cfg

# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
text
reboot
#cdrom
url --url="http://192.168.209.29/centos/6/os/x86_64/"
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$F8VLJCWJurIM9Bph$frrIk5HRMIhdye/0gk4EPAIApMXBjWtH.meW6oFk9/x8xzmYkks1eRrwyrT6IbiZHNsG3VjMjhDWi9fZKpETt/
#firewall --service=ssh
firewall --disabled
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
clearpart --all
zerombr

part /boot --fstype=ext4 --size=500
part / --fstype=ext4 --size=20000
part /data --fstype=ext4 --size=10000

part swap --size=8000


# repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100

%packages
@core
@server-policy
@workstation-policy
%end

安装 httpd 服务

yum install httpd -y
cd /var/www/html/
mkdir centos/{6,7}/os/x86_64 -pv
mount /dev/sr0 centos/7/os/x86_64/

mkdir /var/www/html/ksdir
mv ks.cfg /var/www/html/ksdir

新建 虚拟机,用光盘引导,自动安装操作系统

如果没有 dhcp 服务,可以临时指定一个ip

linux ip=IPADDR ks=http://

但是这样,还需要用光盘引导,还要敲一条命令才能完成系统的安装,还需要大力改善

 

总结:

    在服务器上安装 httpd 服务,将 2 张 光盘设备挂载到 hsttpd 网站的根目录下

    在服务器上生成 ks.cfg 应答文件,将应答文件 ks.cfg 放到 网站的根目录下

    客户端(需要ip)从光盘引导,输入相应的应答文件路径的指令,就可以自动安装系统了

    

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!