Linux初学者学习笔记

20170915 运维自动化之系统安装(一)

2017-09-18  本文已影响30人  哈喽别样
  • 安装程序启动过程
  • anaconda工作过程
  • 制作引导U盘
  • 制作全功能安装U盘

一、安装程序启动过程

实验:进入rescue模式的三种方法
第1种:直接选择rescue模式,回车进入
第2种:选择第1个选项,Tab进入编辑页面,添加rescue后进入

第3种:按住Esc键,输入rescue或者linux rescue

二、anaconda工作过程

(一)anaconda安装系统的三个阶段:

安装前配置阶段、安装阶段、图形模式首次启动配置

(二)anaconda安装包来源:

在启动时按Esc键,输入linux askmethod 指定安装时询问安装包来源

提示选择安装源,选择URL


选择网址配置方式,选择默认DHCP方式,也可以自己配置静态地址

配置网络安装源地址

(三)anaconda配置方式:

(1)kickstart文件格式:按次序为命令段、程序包端、脚本段
(2)创建kickstart文件

安装源可以自定义,这里选择网络安装源

boot loader选项设置

分区设置,简易清除MBR(防止硬盘旧信息影响安装),设置好磁盘分区信息

网络配置,可以选择DHCP自动获取ip,也可以手动设置静态地址

认证原乡,选择密码加密方式等

建议关闭SELinux和防火墙

选择是否安装图形环境,视需求而定

选择要安装的包

编写安装前脚本,这里没有设置

编写安装后脚本,这里写了一个yum源配置的脚本

设置好后,将导出文件(如ks.cfg)保存。

思路:只需在安装程序启动时,在安装菜单项界面,按Esc键输入kickstart文件路径,系统就可以按照kiskstart文件的要求安装

光盘用于启动,当进入安装菜单项,按Esc键,输入linux ks=http://172.18.250.79/ks.cfg(将ks.cfg放在httpd服务器上)回车,系统会自动按照ks.cfg文件的说明自动安装

查看http://172.18.250.79/ks.cfg,确认能够正常访问

正常开始安装过程

三、制作引导U盘

(1)系统光盘中的isolinux目录

(2)制作引导U盘:

四、制作全功能安装U盘

(1)准备相关文件,配置yum源

(2)配置kickstart文件:

可以参考/root/anaconda-ks.cfg文件作适当的修改,将修改后的文件保存至/app/fulliso目录下,例如以下kickstart文件ks6.cfg以及ks6-mini.cfg分别定义了桌面安装和最小化安装的两套自动化安装方案

vim /app/fulliso/ks6.cfg

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --enabled --service=ssh
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Root password
rootpw --iscrypted $1$Z3Phclpd$eSd3ZHMEa0ohzi7KKxM8Y1     //使用openssl passwd -1命令生成加密密码
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text     //文本模式安装
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled     //关闭selinux
# Installation logging level
logging --level=info
# Reboot after installation
reboot     //安装后重启
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=yes
# System bootloader configuration
bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"
# Clear the Master Boot Record
zerombr     //安装前先清除MBR
# Partition clearing information
clearpart --all     //安装前先清除所有分区信息
# Disk partitioning information
part /boot --fstype="ext4" --size=1000
part / --fstype="ext4" --size=50000
part /app --fstype="ext4" --size=40000
part swap --size=2048

%post
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<eof
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
eof
%end

%packages
@base
@basic-desktop
@core
@debugging
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@workstation-policy
@x11
abrt-gui
certmonger
device-mapper-persistent-data
genisoimage
krb5-workstation
libXmu
mtools
oddjob
pam_krb5
pax
python-dmidecode
samba-winbind
sgpio
wodim
%end
vim /app/fulliso/ks6-mini.cfg

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --enabled --service=ssh
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Root password
rootpw --iscrypted $1$GjUVnxcA$Q1BQF.c0fS/9RERcqz3hQ.     //使用openssl passwd -1命令生成加密密码
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text     //文本模式安装
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled     //关闭selinux
# Installation logging level
logging --level=info
# Reboot after installation
reboot     //安装后重启
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=yes
# System bootloader configuration
bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"
# Clear the Master Boot Record
zerombr     //安装前先清除MBR
# Partition clearing information
clearpart --all     //安装前先清除所有分区信息
# Disk partitioning information
part /boot --fstype="ext4" --size=1000
part / --fstype="ext4" --size=50000
part /app --fstype="ext4" --size=40000
part swap --size=2048

%post
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<eof
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
eof
%end

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

(3)定制启动菜单:

定制启动菜单,菜单1执行安装带桌面的系统,菜单2执行安装mini系统,菜单3执行手动安装,菜单4执行从本地硬盘启动,编辑/app/fulliso/isolinux/isolinux.cfg文件如下:

vim /app/fulliso/isolinux/isolinux.cfg

default vesamenu.c32
#prompt 1
timeout 600 

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.9!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label linux-desktop      //菜单1:桌面安装
  menu label Install a ^desktop system
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/ks6.cfg
label linux-mini        //菜单2:最小化安装
  menu label Install a m^ini system
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/ks6-mini.cfg
label manual            //菜单3:手动安装
  menu label Install a system ^manually
  kernel vmlinuz
  append initrd=initrd.img 
label local            //菜单4:默认从硬盘启动
  menu default
  menu label Boot from ^local drive
  localboot 0xffff

(4)制作ISO文件:

执行mkisofs命令,将生成的iso文件保存至/root目录下,名称为centos6.iso
mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 6.9 x86_64 autoinstall" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/centos6.iso /app/fulliso

(5)制作启动U盘

dd if=/root/centos6.iso of=/dev/sdb

(6)总结

通过比较制作启动U盘和制作全功能安装U盘的区别我们可以看到两者的步骤是很相似的,制作全功能安装U盘只是在制作启动U盘的基础上做了一些调整。

上一篇 下一篇

猜你喜欢

热点阅读