anaconda详解

本文详细介绍了anaconda的基础知识,包括安装系统选项,重点讲解了kickstart文件的格式、创建方法以及文件解释,旨在帮助用户全面理解anaconda的自动化安装过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

anaconda基础知识

anaconda: 系统安装程序
gui:图形窗口
tui: 基于图形库curses的文本窗口
安装程序启动过程:
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
启动安装过程一般应位于引导设备;后续的anaconda及其安装用到的程序包等可来自下面几种方式:
本地光盘
本地硬盘
NFS
URL:
ftp server: yum repository
http server: yum repostory
如果想手动指定安装源:
boot: linux askmethod
anaconda的配置方式:
(1) 交互式配置方式:需要安装system-config-kickstart软件包
(2) 通过读取事先给定的配置文件自动完成配置按特定语法给出的配置文件 kickstart

anaconda安装系统选项

安装boot引导选项: boot:
text: 文本安装方式
askmethod: 手动指定使用的安装方法
与网络相关的引导选项:
ip=IPADDR
netmask=MASK
gateway=GW
dns=DNS_SERVER_IP
ifname=NAME:MAC_ADDR
指明kickstart文件的位置: ks=
DVD drive: ks=cdrom:/PATH/TO/KICKSTART_FILE
Hard drive: ks=hd:device:/directory/KICKSTART_FILE
HTTP server: ks= http://host:port/path/to/KICKSTART_FILE
FTP server: ks= ftp://host:port/path/to/KICKSTART_FILE
HTTPS server: ks= https://host:port/path/to/KICKSTART_FILE
NFS server:ks=nfs:host:/path/to/KICKSTART_FILE

kickstart文件格式

命令段:指明各种安装前配置,如键盘类型、时区等 程序包段:指明要安装的程序包组或程序包,不安装的程序包等
%packages
@group_name
package
-package
%end
脚本段:
%pre: 安装前脚本
运行环境:运行于安装介质上的微型Linux环境
%post: 安装后脚本
运行环境:安装完成的系统
命令段中的必需命令:
authconfig: 认证方式配置
authconfig –useshadow –passalgo=sha512
bootloader: bootloader的安装位置及相关配置
bootloader –location=mbr –driveorder=sda –
append=”crashkernel=auto rhgb quiet”
keyboard: 设定键盘类型
lang: 语言类型
part: 创建分区
rootpw: 指明root的密码
timezone: 时区
命令段中的可选命令:
install OR upgrade
text: 文本安装界面
network
firewall
selinux
halt
poweroff
reboot
repo
user:安装完成后为系统创建新用户
url: 指明安装源
key –skip 跳过安装号码,适用于rhel版本

kickstart文件创建

创建kickstart文件的方式
直接手动编辑
依据某模板修改
可使用创建工具: system-config-kickstart
依据某模板修改并生成新配置
/root/anaconda-ks.cfg
检查ks文件的语法错误: ksvalidator
ksvalidator /PATH/TO/KICKSTART_FILE
依赖pykickstart软件包,没有可用yum安装

kickstart文件解释

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512 #系统认证
# Use CDROM installation media
cdrom #此处指定yum源,可用http,ftp例如:url --url=http://192.168.6.6/centos
# Use graphical install
graphical #可以指定文本安装text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
selinux --disabled #禁用selinux
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --activate
network  --hostname=centos7.3

# Root password
rootpw --iscrypted $6$4H7lm/X8Ku/nsNTw$.5llTHSpqn3igZ9Mub.uq/W4LN3Lx/5q76cpc/jjK7s0LEIFC/agBmwabsTzlumlLAfrXVEBwUbM25Avsokru.
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai ntpservers=0.centos.pool.ntp.org,1.centos.pool.ntp.org,2.centos.pool.ntp.org,3.centos.pool.ntp.org
user --name=zhang --password=$6$idwFYWsqAMxGAQS3$FQLI.nfmXufCsyjqxCOvyfzRotbf3oU2Y2sGY1AZwnzVbb2lx5skFIzzAZPUj0x.bW3MOVjULqcO81EvmLeNu0 --iscrypted
# X Window System configuration information
xconfig  --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm #lvm自动分区
# Partition clearing information
zerombr #清空主引导分区记录MBR
clearpart --all #清空所有分区
reboot

%packages
@^graphical-server-environment
@base
@core
kexec-tools
%end

#以下可以写安装后的脚本
%post
useradd test  #添加测试用户
%end

%addon com_redhat_kdump --enable --reserve-mb='auto'
%end

%anaconda
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty
%end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值