温馨提示×

ubuntu kickstart如何配置

小樊
81
2024-09-21 09:35:04
栏目: 智能运维

在Ubuntu中,Kickstart文件用于自动化安装过程

  1. 创建Kickstart文件:

首先,创建一个名为ks.cfg的文件。你可以将其放在/etc/anaconda/目录下,或者根据你的需求将其放在其他位置。

  1. 编辑Kickstart文件:

使用文本编辑器打开ks.cfg文件,并添加以下内容:

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512

# Use network installation
url --url="http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/"

# Run the Setup Agent on first boot
firstboot --enable

# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'

# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=link --ipv6=auto --activate
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6$rhel7$YOUR_ENCRYPTED_PASSWORD_HERE

# System services
services --enabled="chronyd"

# Partition clearing information
clearpart --none --initlabel

# Disk partitioning information
part /boot --fstype="ext4" --ondisk=sda --size=500
part pv.01 --fstype="lvmpv" --ondisk=sda --size=1 --grow
volgroup centos --pesize=4096 pv.01
logvol /  --fstype="xfs" --size=1 --grow --name=root --vgname=centos
logvol swap  --fstype="swap" --size=2048 --name=swap --vgname=centos

%packages
@^minimal
chrony
kexec-tools

%end

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

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges
%end

请根据你的需求修改上述内容。例如,你可以更改语言、键盘布局、时区、网络设置、用户密码等。

  1. 保存并关闭文件。

  2. 在启动安装程序时,使用--append选项指定Kickstart文件的路径。例如:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg --append="ks=file:/path/to/ks.cfg"

确保将/path/to/ks.cfg替换为实际的Kickstart文件路径。

现在,当你使用Kickstart文件进行Ubuntu安装时,它将根据你在文件中指定的设置进行自动化配置。

0