在Ubuntu中,Kickstart文件用于自動化安裝過程
首先,創(chuàng)建一個名為ks.cfg
的文件。你可以將其放在/etc/anaconda/
目錄下,或者根據(jù)你的需求將其放在其他位置。
使用文本編輯器打開ks.cfg
文件,并添加以下內(nèi)容:
#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
請根據(jù)你的需求修改上述內(nèi)容。例如,你可以更改語言、鍵盤布局、時區(qū)、網(wǎng)絡(luò)設(shè)置、用戶密碼等。
保存并關(guān)閉文件。
在啟動安裝程序時,使用--append
選項指定Kickstart文件的路徑。例如:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg --append="ks=file:/path/to/ks.cfg"
確保將/path/to/ks.cfg
替換為實際的Kickstart文件路徑。
現(xiàn)在,當(dāng)你使用Kickstart文件進(jìn)行Ubuntu安裝時,它將根據(jù)你在文件中指定的設(shè)置進(jìn)行自動化配置。