cobbler3使用总结

按照如下步骤进行安装配置,实现PXE+BIOS安装Centos和Ubuntu,UEFI+iPXE安装Windows2019

若想实现UEFI+iPXE安装Centos和Ubuntu,可以参考附录《更全的ipxe/default.ipxe》配置default.ipxe即可

rocky91安装配置cobbler3.3.3

准备工作

rocky91的IP地址是192.168.1.177

yum -y install vim wget epel-release

systemctl disable --now firewalld

systemctl disable --now dnf-makecache.timer

setenforce 0

sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

安装软件包

yum -y install rsync rsync-daemon httpd dnsmasq tftp tftp-server cobbler pykickstart ipxe-bootimgs-x86

yum -y install samba ipxe-roms-qemu.noarch # Windows需要使用

启动服务

systemctl enable --now httpd cobblerd rsyncd tftp

修改cobbler配置

sed -i ‘s/manage_dhcp: false/manage_dhcp: true/’ /etc/cobbler/settings.yaml

sed -i ‘s/manage_dhcp_v4: false/manage_dhcp_v4: true/’ /etc/cobbler/settings.yaml

sed -i ‘s/next_server_v4: 127.0.0.1/next_server_v4: 192.168.1.177/’ /etc/cobbler/settings.yaml

sed -i ‘s/redhat_management_permissive: false/redhat_management_permissive: true/’ /etc/cobbler/settings.yaml

sed -i ‘s/server: 127.0.0.1/server: 192.168.1.177/’ /etc/cobbler/settings.yaml

修复一些配置

cobbler check
yum -y install yum-utils
yum -y install syslinux*
cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
cp /usr/share/syslinux/ldlinux.c32 /var/lib/cobbler/loaders/
cp /usr/share/syslinux/libutil.c32 /var/lib/cobbler/loaders/
systemctl restart cobblerd
cobbler sync

修改一些代码

根据 https://github.com/cobbler/cobbler/issues/3473

[root@localhost modules]# grep -nr wlsd sync_post_wingen_ankele.py -C2
81-    b = h.node_add_child(objs, "{65c31250-afa2-11df-8045-000c29f37d88}")
82-    d = h.node_add_child(b, "Description")
83:    # wlsd mod 2
84-    #h.node_set_value(d, {"key": "Type", "t": REG_DWORD, "value": b"\x03\x00\x20\x13"})
85-    h.node_set_value(d, {"key": "Type", "t": REG_DWORD, "value": b"\x03\x00\x20\x10"})
86-    e = h.node_add_child(b, "Elements")
87:    # wlsd add 2
88-    e1 = h.node_add_child(e, "12000002")
89-    h.node_set_value(e1, {"key": "Element", "t": REG_SZ, "value": "\\windows\\system32\\winload.exe\0".encode(encoding="utf-16le"), }, )
--
178-
179-        if is_wimboot:
180:            # wlsd del 2
181-            #distro_path = os.path.join(settings.webdir, "distro_mirror", distro.name)
182-            #kernel_path = os.path.join(distro_path, "boot")
--
303-
304-            if is_wimboot:
305:                # wlsd mod 2
306-                #wim_file_name = '\\Boot\\' + wim_file_name
307-                wim_file_name = '\\Boot\\' + "winpe.wim"

为Windows修改ipxe.template

sed -i ‘s/kernel $kernel_path $kernel_options initrd=initrd.magic/kernel $kernel_path $kernel_options/’ /etc/cobbler/boot_loader_conf/ipxe.template

为Windows配置ipxe

dnsmasq里边应该是指定的ipxe-x86_64.efi这个文件,所以

cp /usr/share/ipxe/ipxe-x86_64.efi /var/lib/tftpboot/ipxe-x86_64.efi

安装wim工具

不然cobbler import时会报错 no /usr/bin/wiminfo found, please install wimlib-utils 以及 No signature matched in /var/www/cobbler/distro_mirror/win2019

yum -y install wimlib-utils

开启Windows

sed -i ‘s/windows_enabled: false/windows_enabled: true/’ /etc/cobbler/settings.d/windows.settings

开启dnsmasq

而不使用dhcp-server,原因是Windows得使用dnsmasq方便指定ipxe

sed -i ‘s/module = managers.isc/module = managers.dnsmasq/’ /etc/cobbler/modules.conf

cat /etc/cobbler/dnsmasq.template

# Cobbler generated configuration file for dnsmasq
# $date
## resolve.conf .. ?
#no-poll
#enable-dbus
read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hostsdhcp-range=192.168.66.100,192.168.66.200
dhcp-option=66,$next_server_v4
dhcp-lease-max=1000
dhcp-authoritative
#dhcp-boot=pxelinux.0
#dhcp-boot=net:normalarch,pxelinux.0
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-boot=tag:efi-x86_64,ipxe-x86_64.efi
dhcp-match=set:ipxe,175
dhcp-boot=tag:ipxe,/ipxe/default.ipxe
dhcp-match=set:bios,option:client-arch,0
dhcp-boot=tag:bios,pxelinux.0$insert_cobbler_system_definitions

systemctl enable --now dnsmasq

cobbler sync

cobbler3.3.3安装Windows2019

配置samba

cat >> /etc/samba/smb.conf << EOF

[DISTRO]
comment = Windows distributions
path = /var/www/cobbler/distro_mirror
guest ok = yes
browseable = yes
public = yes
writeable = no
printable = no
locking = no
EOF

systemctl enable --now smb

导入ISO镜像

scp cn_windows_server_2019_x64_dvd_4de40f33.iso 到/root下
mkdir -p /iso/win2019
mount -o ro,loop cn_windows_server_2019_x64_dvd_4de40f33.iso /iso/win2019
cobbler import --path=/iso/win2019 --name=win2019

指定应答文件

cobbler profile edit --name=win2019-x86_64 --autoinstall-meta=“kernel=http://@@http_server@@/cobbler/images/@@distro_name@@/wimboot bootmgr=bootmgr.exe bcd=bcd winpe=winpe.wim answerfile=autounattended.xml”
ln -s /var/www/cobbler/distro_mirror/win2019 /var/www/cobbler/distro_mirror/win2019-x86_64
cobbler sync

替换cobbler sync生成的winpe.wim,然后给wimpe.wim注入命令

cp /root/winpe.wim /var/www/cobbler/images/win2019-x86_64/
/usr/bin/wimupdate /var/www/cobbler/images/win2019-x86_64/winpe.wim --command=“add /root/winpe_inject /Windows/System32/startnet.cmd”

[root@localhost win2019-x86_64]# cat /root/winpe_inject
wpeinitping 127.0.0.1 -n 10 >nul
net use z: \\192.168.1.177\DISTRO\win2019-x86_64
set exit_code=%ERRORLEVEL%
IF %exit_code% EQU 0 GOTO INSTALL
echo "Can't mount network drive"
pause
goto EXIT:INSTALLz:\sources\setup.exe /unattend:Z:\autounattended.xml
:EXIT
exit# 解释
# net use z: \\192.168.1.177\DISTRO\win2019-x86_64 表示使用smb协议挂载192.168.1.177的共享目录,可修改此IP

覆盖
cd /var/www/cobbler/images/win2019-x86_64/
cp winpe.wim /var/www/cobbler/distro_mirror/win2019-x86_64/boot/winpe.wim
cp winpe.wim /var/lib/tftpboot/images/win2019-x86_64/

下载wimboot

根据https://github.com/cobbler/cobbler/issues/3473

https://github.com/ipxe/wimboot/releases/latest/download/wimboot,
并copy到几个地方
/var/lib/tftpboot
/var/lib/tftpboot/images/win2019-x86_64
/var/www/cobbler/images/win2019-x86_64/

/var/www/cobbler/images/win2019-x86_64/下边共有这几个文件
autounattended.xml bcd boot.sdi bootmgr.exe pxeboot.n12 wimboot winpe.wim

准备好 autounattended.xml,见附件

/var/lib/tftpboot/images/win2019-x86_64/autounattended.xml
/var/www/cobbler/distro_mirror/win2019/autounattended.xml
/var/www/cobbler/images/win2019-x86_64/autounattended.xml

默认从windows启动

vim /var/lib/tftpboot/ipxe/default.ipxe

...
set menu-timeout 2000
isset ${menu-default} || set menu-default win2019-x86_64
...

systemctl restart cobblerd

安装Ubuntu20.04.6-live-server

mkdir /iso/ubuntu20046
mount -o loop,ro ubuntu-20.04.6-live-server-amd64.iso /iso/ubuntu20046
cobbler import --path=/iso/ubuntu20046 --name=ubuntu20046
之后/var/lib/tftpboot/pxelinux.cfg/default中便有了ubuntu20046

修改default,添加参数

LABEL ubuntu20046-casper-x86_64MENU LABEL ubuntu20046-casper-x86_64kernel /images/ubuntu20046-casper-x86_64/vmlinuzappend initrd=/images/ubuntu20046-casper-x86_64/initrd  hostname=ubuntu20046-casper-x8664 domain=local.lan suite=focalipappend 2改为LABEL ubuntu20046-casper-x86_64MENU LABEL ubuntu20046-casper-x86_64kernel /images/ubuntu20046-casper-x86_64/vmlinuzinitrd /images/ubuntu20046-casper-x86_64/initrdappend biosdevname=0 net.ifnames=0 netcfg/choose_interface=auto ip=dhcp autoinstall ds='nocloud-net;s=http://192.168.1.177:3003/' cloud-config-url=http://192.168.1.177:3003/user-data url=http://192.168.1.177/cobbler/isos/ubuntu-20.04.6-live-server-amd64.isoipappend 2
# 其中biosdevname=0 net.ifnames=0 在live阶段起作用。欲修改安装后系统的网卡名称,cloud-init的user-data中使用shell命令来配置内核参数
# netcfg/choose_interface=auto ip=dhcp 表示任意选中一张网卡,通过DHCP获取IP,用以与我们的server通信
# autoinstall 指定自动安装
# ds='nocloud-net;s=http://192.168.1.177:3003/' 指定安装方式是nocloud-net,并给出包含user-data和meta-data的http静态路径
# cloud-config-url=http://192.168.1.177:3003/user-data 给出user-data具体路径,方便获取cloud-init指令
# url=http://192.168.1.177/cobbler/isos/ubuntu-20.04.6-live-server-amd64.iso 指定网络安装时局域网内的ISO文件路径

添加user-data

mkdir /root/http_server
touch /root/http_server/user-data
touch /root/http_server/meta-data

cat /root/http_server/meta-data#cloud-config
autoinstall:version: 1apt:geoip: truepreserve_sources_list: falseprimary:- arches: [amd64, i386]uri: http://us.archive.ubuntu.com/ubuntu- arches: [default]uri: http://ports.ubuntu.com/ubuntu-portsidentity:hostname: ubuntu-serverpassword: $6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0username: ubuntukeyboard: {layout: us, toggle: null, variant: ''}locale: en_USnetwork:version: 2ethernets:eth0:dhcp4: truenameservers:addresses: [8.8.8.8]ssh:allow-pw: trueauthorized-keys: []install-server: true#### POST Install commandslate-commands:- sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /target/etc/ssh/sshd_config- sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /target/etc/ssh/sshd_config# - echo "root:root" | chpasswd# - sed -i '/^GRUB_CMDLINE_LINUX=/s@"$@ net.ifnames=0 biosdevname=0"@' /target/etc/default/grub && update-grub  # there is no grub2-common- sed -i '/^GRUB_CMDLINE_LINUX=/s@"$@ net.ifnames=0 biosdevname=0"@' /target/etc/default/grub# - apt -y install grub2-common# - grub-mkconfig -o /target/boot/grub/grub.cfg- echo '#!/bin/bash' > /target/etc/rc.local- echo 'echo root:root | chpasswd' >> /target/etc/rc.local- echo 'update-grub' >> /target/etc/rc.local- echo 'touch /root/haha' >> /target/etc/rc.local- echo 'rm -- "$0"' >> /target/etc/rc.local- echo 'reboot' >> /target/etc/rc.local- chmod a+x /target/etc/rc.local

然后进入到/root/http_server

python -m http.server 3003

安装CentOS

CentOS-7-x86_64-Everything-2009.iso
mkdir /iso/centos7
mount -o loop,ro CentOS-7-x86_64-Everything-2009.iso /iso/centos7/
cobbler import --path=/iso/centos7 --name=centos7
准备好centos7.ks,修改里边的IP
cobbler profile edit --name centos7-x86_64 --autoinstall centos7.ks

附录

autounattended.xml

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend"><servicing><package action="configure"><assemblyIdentity name="Microsoft-Windows-Foundation-Package" version="10.0.17763.1" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" /><selection name="RemoteAccess" state="true" /><selection name="Remote-Desktop-Services" state="true" /></package><package action="configure" permanence="permanent"><assemblyIdentity name="Microsoft-Windows-InternetExplorer-Optional-Package" version="11.0.17763.1" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" /></package><package action="configure" permanence="permanent"><assemblyIdentity name="OpenSSH-Client-Package" version="10.0.17763.1" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" /></package></servicing><settings pass="windowsPE"><component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SetupUILanguage><UILanguage>en-US</UILanguage></SetupUILanguage><InputLocale>0c09:00000409</InputLocale><SystemLocale>zh-CN</SystemLocale><UILanguage>zh-CN</UILanguage><UILanguageFallback>zh-CN</UILanguageFallback><UserLocale>zh-CN</UserLocale></component><component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><DiskConfiguration><Disk wcm:action="add"><CreatePartitions><CreatePartition wcm:action="add"><Order>1</Order><Size>485</Size><Type>Primary</Type></CreatePartition><CreatePartition wcm:action="add"><Order>2</Order><Size>100</Size><Type>EFI</Type></CreatePartition><CreatePartition wcm:action="add"><Order>3</Order><Size>128</Size><Type>MSR</Type></CreatePartition><CreatePartition wcm:action="add"><Order>4</Order><Type>Primary</Type><Extend>true</Extend></CreatePartition></CreatePartitions><ModifyPartitions><ModifyPartition wcm:action="add"><Format>NTFS</Format><Label>WINRE</Label><Order>1</Order><PartitionID>1</PartitionID></ModifyPartition><ModifyPartition wcm:action="add"><Order>2</Order><Format>FAT32</Format><Label>System</Label><PartitionID>2</PartitionID></ModifyPartition><ModifyPartition wcm:action="add"><Order>3</Order><PartitionID>3</PartitionID></ModifyPartition><ModifyPartition wcm:action="add"><Letter>C</Letter><Order>4</Order><PartitionID>4</PartitionID><Label>Windows</Label><Format>NTFS</Format></ModifyPartition></ModifyPartitions><DiskID>0</DiskID><WillWipeDisk>true</WillWipeDisk></Disk></DiskConfiguration><ImageInstall><OSImage><InstallFrom><MetaData wcm:action="add"><Key>/IMAGE/NAME</Key><Value>Windows Server 2019 SERVERSTANDARD</Value></MetaData></InstallFrom><InstallTo><DiskID>0</DiskID><PartitionID>4</PartitionID></InstallTo></OSImage></ImageInstall><UserData><ProductKey><Key>N69G4-B89J2-4G8F4-WWYCC-J464C</Key></ProductKey><AcceptEula>true</AcceptEula><FullName>ankele</FullName><Organization>ankele</Organization></UserData><DynamicUpdate><Enable>false</Enable></DynamicUpdate></component></settings><settings pass="offlineServicing"><component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><EnableLUA>false</EnableLUA></component></settings><settings pass="generalize"><component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64"publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SkipRearm>1</SkipRearm></component></settings><settings pass="specialize"><component name="Microsoft-Windows-International-Core" processorArchitecture="amd64"publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><InputLocale>0c09:00000409</InputLocale><SystemLocale>zh-CN</SystemLocale><UILanguage>zh-CN</UILanguage><UILanguageFallback>zh-CN</UILanguageFallback><UserLocale>zh-CN</UserLocale></component><component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64"publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SkipAutoActivation>true</SkipAutoActivation></component><component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64"publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><CEIPEnabled>0</CEIPEnabled></component><component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64"publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ComputerName>-PC-ankele</ComputerName><ProductKey>N69G4-B89J2-4G8F4-WWYCC-J464C</ProductKey></component><component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall><PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall></component></settings><settings pass="oobeSystem"><component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><AutoLogon><Password><Value>aQBuAHMAdABhAGMAawBQAGEAcwBzAHcAbwByAGQA</Value><PlainText>false</PlainText></Password><Enabled>true</Enabled><Username>ankele</Username></AutoLogon><DesktopOptimization><GoToDesktopOnSignIn>true</GoToDesktopOnSignIn><ShowWindowsStoreAppsOnTaskbar>false</ShowWindowsStoreAppsOnTaskbar></DesktopOptimization><FirstLogonCommands><SynchronousCommand wcm:action="add"><CommandLine>reg add &quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server&quot; /v fDenyTSConnections /t REG_DWORD /d 0 /f</CommandLine><Order>1</Order><RequiresUserInput>false</RequiresUserInput></SynchronousCommand></FirstLogonCommands><OOBE><VMModeOptimizations><SkipAdministratorProfileRemoval>true</SkipAdministratorProfileRemoval><SkipNotifyUILanguageChange>true</SkipNotifyUILanguageChange><SkipWinREInitialization>true</SkipWinREInitialization></VMModeOptimizations></OOBE><UserAccounts><AdministratorPassword><Value>aQBuAHMAdABhAGMAawBBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=</Value><PlainText>false</PlainText></AdministratorPassword><LocalAccounts><LocalAccount wcm:action="add"><Password><Value>aQBuAHMAdABhAGMAawBQAGEAcwBzAHcAbwByAGQA</Value><PlainText>false</PlainText></Password><Description>pc of ankele</Description><DisplayName>ankele</DisplayName><Group>Administrators</Group><Name>ankele</Name></LocalAccount></LocalAccounts></UserAccounts><BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled><ConvertibleSlateModePromptPreference>0</ConvertibleSlateModePromptPreference><DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet><DoNotCleanTaskBar>true</DoNotCleanTaskBar><EnableStartMenu>true</EnableStartMenu><RegisteredOrganization>ankele</RegisteredOrganization><RegisteredOwner>ankele</RegisteredOwner><ShowPowerButtonOnStartScreen>true</ShowPowerButtonOnStartScreen><SignInMode>0</SignInMode><TimeZone>Asia/Shanghai</TimeZone></component></settings><cpi:offlineImage cpi:source="wim:c:/users/86153/desktop/install.wim#Windows Server 2019 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

centos7.ks

cat centos7.ks
# Sample kickstart file for current EL, Fedora based distributions.#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
# wlsd mod 2
#url --url=$tree
url --url=http://192.168.1.177/cblr/links/centos7-x86_64/
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://192.168.1.177/cobbler/distro_mirror/centos7# Network information
network --bootproto=dhcp --device=eth0 --onboot=on# Reboot after installation
reboot#Root password
rootpw --iscrypted $1$wHSPTJgs$o8vHsC2Krje.9QMb8slNe/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
# wlsd, install has been removed
#install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart%preset -x -v
exec 1>/tmp/ks-pre.log 2>&1# Once root's homedir is there, copy over the log.
while : ; dosleep 10if [ -d /mnt/sysimage/root ]; thencp /tmp/ks-pre.log /mnt/sysimage/root/logger "Copied %pre section log to system"breakfi
done &curl "http://192.168.1.177/cblr/svc/op/trig/mode/pre/profile/centos7-x86_64" -o /dev/null# Enable installation monitoring
#ip -o -4 a | awk '!/^[0-9]*: ?lo/ {print $2, $4}' > /tmp/ip
#curl "http://192.168.1.177:5000/c?ip=$IP"
%end%packages
@core
%end%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1%end%post
set -x -v
exec 1>/root/ks-post.log 2>&1# Start yum configuration
# wlsd mod 2
#curl "http://192.168.1.177/cblr/svc/op/yum/profile/centos7-x86_64" --output /etc/yum.repos.d/cobbler-config.repo
curl "http://192.168.1.177/cblr/distro_mirror/config/centos7-x86_64-0.repo" --output /etc/yum.repos.d/cobbler-config.repo# End yum configuration# Start post_install_network_config generated code
# End post_install_network_config generated code# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)# Start koan environment setup
echo "export COBBLER_SERVER=192.168.1.177" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.1.177" > /etc/profile.d/cobbler.csh
# End koan environment setup# begin Red Hat management server registration
# not configured to register to any Red Hat management server (ok)
# end Red Hat management server registration# Begin cobbler registration
# cobbler registration is disabled in /etc/cobbler/settings.yaml
# End cobbler registration# Enable post-install boot notification# Start final stepscurl "http://192.168.1.177/cblr/svc/op/autoinstall/profile/centos7-x86_64" -o /root/cobbler.ks
curl "http://192.168.1.177/cblr/svc/op/trig/mode/post/profile/centos7-x86_64" -o /dev/null
# End final steps
%end

inspect.ks

inspect的作用是在安装操作系统之前获取物理机的MAC地址,这里我在192.168.1.177上搞了一个restful接口,用于接收来自inspect的主机的MAC地址信息,然后便可以实现通过system来固定裸机要安装什么操作系统以及要给裸机什么IP了(指定IP目前仅支持Centos),这里可以跳过不看

# Sample kickstart file for current EL, Fedora based distributions.# platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
# wlsd mod 2
# url --url=$tree
url --url=http://192.168.1.177/cblr/links/centos7-x86_64/
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://192.168.1.177/cobbler/distro_mirror/centos7# Network information
network --bootproto=dhcp --device=eth0 --onboot=on# wlsd
# Reboot after installation
interactive
# reboot
# poweroff#Root password
rootpw --iscrypted $1$wHSPTJgs$o8vHsC2Krje.9QMb8slNe/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
# wlsd, install has been removed
# install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart%pre
# wlsd
# ip -o -4 a | awk 'BEGIN{OFS="-"} !/^[0-9]*: ?lo/ {print $2,$4}'
# ip -o -4 a | awk '!/^[0-9]*: ?lo/ {print $2}' > /tmp/ifname
# ip -o -4 a | awk '!/^[0-9]*: ?lo/ {print $4}' > /tmp/ipaddr# ip -o -4 a | awk '!/^[0-9]*: ?lo/ {if (!done) {print $2; done=1}}' > /tmp/ifname
# ip -o -4 a | awk '!/^[0-9]*: ?lo/ {if (!done) {print $4; done=1}}' > /tmp/ipaddr
# ip -o link show | awk '$2 !~ /lo:/ {print $17; exit}'> /tmp/macaddr
# dmidecode -t baseboard > /tmp/baseboard
# ifname=$(cat /tmp/ifname)
# ipaddr=$(cat /tmp/ipaddr)
# macaddr=$(cat /tmp/macaddr)
# echo $ifname > /etc/ifname
# echo $ipaddr > /etc/ipaddr
# echo $macaddr > /etc/macaddr
# curl "http://192.168.1.177:5000/report_if?ifname=$ifname&ipaddr=$ipaddr&macaddr=$macaddr"ip a > /tmp/ip
dmidecode -t baseboard > /tmp/inspect_info
curl -X POST -F "file=@/tmp/ip" "http://192.168.1.177:5000/inspect_info"
curl -X POST -F "file=@/tmp/inspect_info" "http://192.168.1.177:5000/inspect_info"set -x -v
exec 1>/tmp/ks-pre.log 2>&1# Once root's homedir is there, copy over the log.
while : ; dosleep 10if [ -d /mnt/sysimage/root ]; thencp /tmp/ks-pre.log /mnt/sysimage/root/logger "Copied %pre section log to system"breakfi
done &curl "http://192.168.1.177/cblr/svc/op/trig/mode/pre/profile/centos7-x86_64" -o /dev/null# Enable installation monitoring
# ip -o -4 a | awk '!/^[0-9]*: ?lo/ {print $2, $4}' > /tmp/ip
# curl "http://192.168.1.177:5000/c?ip=$IP"
%end%packages
@core
%end%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1%end%post
set -x -v
exec 1>/root/ks-post.log 2>&1# Start yum configuration
# wlsd mod 2
# curl "http://192.168.1.177/cblr/svc/op/yum/profile/centos7-x86_64" --output /etc/yum.repos.d/cobbler-config.repo
curl "http://192.168.1.177/cblr/distro_mirror/config/centos7-x86_64-0.repo" --output /etc/yum.repos.d/cobbler-config.repo# End yum configuration# Start post_install_network_config generated code
# End post_install_network_config generated code# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)# Start koan environment setup
echo "export COBBLER_SERVER=192.168.1.177" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.1.177" > /etc/profile.d/cobbler.csh
# End koan environment setup# begin Red Hat management server registration
# not configured to register to any Red Hat management server (ok)
# end Red Hat management server registration# Begin cobbler registration
# cobbler registration is disabled in /etc/cobbler/settings.yaml
# End cobbler registration# Enable post-install boot notification# Start final stepscurl "http://192.168.1.177/cblr/svc/op/autoinstall/profile/centos7-x86_64" -o /root/cobbler.ks
curl "http://192.168.1.177/cblr/svc/op/trig/mode/post/profile/centos7-x86_64" -o /dev/null
# End final steps
%end

pxelinux.cfg

从BIOS引导centos7和Ubuntu

[root@localhost tftpboot]# cat pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | https://cobbler.github.io
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT localLABEL localMENU LABEL (local)MENU DEFAULTLOCALBOOT -1LABEL centos7-x86_64MENU LABEL centos7-x86_64kernel /images/centos7-x86_64/vmlinuzappend initrd=/images/centos7-x86_64/initrd.img  kssendmac inst.ks=http://192.168.1.177/cblr/svc/op/autoinstall/profile/centos7-x86_64ipappend 2LABEL inspect-x86_64MENU LABEL inspect-x86_64kernel /images/inspect-x86_64/vmlinuzappend initrd=/images/inspect-x86_64/initrd.img  kssendmac inst.ks=http://192.168.1.177/cblr/svc/op/autoinstall/profile/inspect-x86_64ipappend 2LABEL ubuntu20046-casper-x86_64MENU LABEL ubuntu20046-casper-x86_64kernel /images/ubuntu20046-casper-x86_64/vmlinuzinitrd /images/ubuntu20046-casper-x86_64/initrdappend biosdevname=0 net.ifnames=0 netcfg/choose_interface=auto ip=dhcp autoinstall ds='nocloud-net;s=http://192.168.1.177:3003/' cloud-config-url=http://192.168.1.177:3003/user-data url=http://192.168.1.177/cobbler/isos/ubuntu-20.04.6-live-server-amd64.isoipappend 2MENU end

ipxe/default.ipxe

从ipxe引导Windows2019

#!ipxeset menu-timeout 20000
set submenu-timeout ${menu-timeout}# Set Menu Default to Exit after timeout
isset ${menu-default} || set menu-default local:Cobbler
menu Cobbler | https://cobbler.github.io
item local (local)
item win2019-x86_64 win2019-x86_64
choose --default ${menu-default} --timeout ${menu-timeout} target && goto ${target}:win2019-x86_64
kernel http://192.168.1.177/cobbler/images/win2019-x86_64/wimboot
initrd --name boot.sdi http://192.168.1.177/cobbler/images/win2019-x86_64/boot.sdi boot.sdi
initrd --name bootmgr.exe http://192.168.1.177/cobbler/images/win2019-x86_64/bootmgr.exe bootmgr.exe
initrd --name bcd http://192.168.1.177/cobbler/images/win2019-x86_64/bcd bcd
initrd --name winpe.wim http://192.168.1.177/cobbler/images/win2019-x86_64/winpe.wim winpe.wim
boot:local
iseq ${smbios/manufacturer} HP && exit ||
sanboot --no-describe --drive 0x80

更全的ipxe/default.ipxe

UEFI+ipxe引导Windows,centos,Ubuntu

 cat ipxe/default.ipxe
#!ipxeset menu-timeout 20000
set submenu-timeout ${menu-timeout}# Set Menu Default to Exit after timeout
isset ${menu-default} || set menu-default local:Cobbler
menu Cobbler | https://cobbler.github.io
item local (local)
item centos7-x86_64 centos7-x86_64
item inspect-x86_64 inspect-x86_64
item ubuntu20046-casper-x86_64 ubuntu20046-casper-x86_64
item win2019-x86_64 win2019-x86_64
choose --default ${menu-default} --timeout ${menu-timeout} target && goto ${target}:centos7-x86_64
kernel http://192.168.1.177/cobbler/images/centos7-x86_64/vmlinuz
initrd http://192.168.1.177/cobbler/images/centos7-x86_64/initrd.img
imgargs vmlinuz initrd=initrd.img inst.ks=http://192.168.1.177/cblr/svc/op/autoinstall/profile/centos7-x86_64
boot:inspect-x86_64
kernel http://192.168.1.177/cobbler/images/inspect-x86_64/vmlinuz
initrd http://192.168.1.177/cobbler/images/inspect-x86_64/initrd.img
imgargs vmlinuz initrd=initrd.img inst.ks=http://192.168.1.177/cblr/svc/op/autoinstall/profile/inspect-x86_64
boot:ubuntu20046-casper-x86_64
kernel http://192.168.1.177/cobbler/images/ubuntu20046-casper-x86_64/vmlinuz
initrd http://192.168.1.177/cobbler/images/ubuntu20046-casper-x86_64/initrd
imgargs vmlinuz initrd=initrd biosdevname=0 net.ifnames=0 netcfg/choose_interface=auto ip=dhcp autoinstall ds='nocloud-net;s=http://192.168.1.177:3003/' cloud-config-url=http://192.168.1.177:3003/user-data url=http://192.168.1.177/cobbler/isos/ubuntu-20.04.6-live-server-amd64.iso
boot:win2019-x86_64
kernel http://192.168.1.177/cobbler/images/win2019-x86_64/wimboot
initrd --name boot.sdi http://192.168.1.177/cobbler/images/win2019-x86_64/boot.sdi boot.sdi
initrd --name bootmgr.exe http://192.168.1.177/cobbler/images/win2019-x86_64/bootmgr.exe bootmgr.exe
initrd --name bcd http://192.168.1.177/cobbler/images/win2019-x86_64/bcd bcd
initrd --name winpe.wim http://192.168.1.177/cobbler/images/win2019-x86_64/winpe.wim winpe.wim
boot:local
iseq ${smbios/manufacturer} HP && exit ||
sanboot --no-describe --drive 0x80

注意

错误

局域网中有路由器,路由器开启了dhcp,虽然第一次获取IP地址时,需要tftp,而必须走我们的dnsmasq,但后续dhcp ack时,有可能因为路由器给了一个IP地址,用此IP作为dhcp ack会报错,然后被dnsmasq拒绝掉
dnsmasq报错:DHCPNAK(ens3) 192.168.1.106 f0:1f:af:f0:da:6a wrong server-ID
所以,还是直接关掉路由器dhcp,保证局域网中只有一个dhcp服务器

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/103255.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux 回顾总结

学习前提&#xff08;环境搭建&#xff09;&#xff1a;RHCSA Linux环境搭建-CSDN博客 目录 一、shell 二、文件 三、用户和组管理 四、权限 五、软件 六、网络 七、磁盘 一、shell Linux的操作界面常称为Shell&#xff0c;Shell是操作系统提供给用户使用的界面&#xf…

KWin、libdrm、DRM从上到下全过程 —— drmModeAddFBxxx(7)

接前一篇文章:KWin、libdrm、DRM从上到下全过程 —— drmModeAddFBxxx(6) 上一回讲到了drm_internal_framebuffer_create函数中的framebuffer_check函数。讲解了该函数的参数检查部分中的第二部分,本回对于该函数余下部分进行解析。 为了便于理解,再次贴出framebuffer_ch…

如何避免nodejs express应用中出现太多的http连接

现象 正常情况下&#xff0c;基于nodejs的http通信应用&#xff0c;在发送http.request时不管你是否使用agent和timeout/keepAlive&#xff0c;客户端和服务器之间的连接数不会太多。但下面情况下&#xff0c;在请求频繁时连接数可能会快速增长并且不会释放&#xff1a; 客户端…

mac jdk的环境变量路径,到底在哪里?

在mac 电脑中&#xff0c;直接执行 java -version 显示Jdk的版本为1.8 然后打印Java环境变量 在终端中执行 echo $JAVA_HOME 1、情况一&#xff1a;发现环境变量是空的 我草&#xff0c;没配置环境变量怎么能使用Java &#xff0c;和查看jdk版本 2、情况二&#xff1a;环…

土壤水分烘干法流程

土壤水分烘干法流程 叠小盒子装土 对折 得到一个正方形&#xff0c;裁掉多余的。然后将正方形按如下形式折 再次对折 然后再展开&#xff0c;对着折痕&#xff0c;竖立起盒子边缘 把上面的尖角翻下来 最后将多余的长条裁出一个盒子底部大小的小方块&#xff0c;放入盒子…

Ubuntu 22.04上安装Anaconda,及 conda 的基础使用

1. 安装软件依赖包&#xff1a; apt install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 2. 下载Anaconda安装包 使用 wget下载您从Anaconda网站复制的链接。您将把它输出到一个名为anaconda.sh的文…

几种常见算法模式与场景应用

在计算机科学中&#xff0c;算法是解决问题的步骤和策略的集合。许多问题都可以通过使用算法解决&#xff0c;这些算法在解决问题的过程中会展现出一些共性和模式。以下是几种常见的算法模式以及它们在场景中的应用&#xff1a; 分治法 (Divide and Conquer) 分治法是一种将问题…

在Vue+Ts+Vite项目中如何配置别名指向不同的目录并引用

在VueTsVite项目中如何配置别名指向不同的目录并引用 vite.config.ts配置如下&#xff1a;tsconfig.json中需要配置baseUrl和paths,如下所示&#xff1a;项目中直接引入案例&#xff1a; vite.config.ts配置如下&#xff1a; import { defineConfig, AliasOptions } from vite…

绘制X-Bar-S和X-Bar-R图,监测过程,计算CPK过程能力指数

X-Bar-S图和X-Bar-R图是统计质量控制中常用的两种控制图&#xff0c;用于监测过程的稳定性和一致性。它们的主要区别在于如何计算和呈现数据的变化以及所关注的问题类型。 X-Bar-S图&#xff08;平均值与标准偏差图&#xff09;&#xff1a; X-Bar代表样本均值&#xff0c;S代表…

网络授时服务器(NTP授时系统)售后与安装步骤

网络授时服务器&#xff08;NTP授时系统&#xff09;售后与安装步骤 网络授时服务器&#xff08;NTP授时系统&#xff09;售后与安装步骤 天线安装 使用GPS/北斗卫星信号接收天线为一体式接收天线&#xff0c;即使用一个天线接收器&#xff08;头&#xff09;&#xff0c;长度…

路由高级特性

项目拓扑与项目需求 项目需求 某企业网络使用ospf和isis作为IGP协议实现内部网络的互联互通&#xff0c;区域规划和IP规划如图所示&#xff0c;现在要求实现如下需求&#xff1a; LSW1和AR1使用vlan10互联&#xff0c;与AR2使用vlan20互联&#xff0c;LSW1与LSW2、3、4之间使…

spring boot RabbitMq基础教程

RabbitMq 由于RabbitMQ采用了AMQP协议&#xff0c;因此它具备跨语言的特性。任何语言只要遵循AMQP协议收发消息&#xff0c;都可以与RabbitMQ交互。并且RabbitMQ官方也提供了各种不同语言的客户端。 但是&#xff0c;RabbitMQ官方提供的Java客户端编码相对复杂&#xff0c;一般…

将vue项目打包成安卓app

目标&#xff1a;将vue项目打包成安卓app 工具&#xff1a;HbuilderX 1.在HbuilderX中创建一个 5App 项目 创建好的app项目目录 2.将vue项目打包 2.1 在 vue.config.js 中添加公共路径&#xff08;解决打包后的app图片不显示问题&#xff09; module.exports defineConfig(…

深入了解线程:并发编程的核心要点和应用

什么是线程&#xff1f; 线程&#xff08;Thread&#xff09;是计算机科学中的一个基本概念&#xff0c;它是进程内的执行单元。线程是操作系统或进程内部的轻量级执行流&#xff0c;具有独立的程序计数器&#xff08;PC&#xff09;和栈&#xff0c;但共享相同进程的资源&…

Python高效实现网站数据挖掘

在当今互联网时代&#xff0c;SEO对于网站的成功至关重要。而Python爬虫作为一种强大的工具&#xff0c;为网站SEO带来了革命性的改变。通过利用Python爬虫&#xff0c;我们可以高效地实现网站数据挖掘和关键词分析&#xff0c;从而优化网站的SEO策略。本文将为您详细介绍如何利…

【Java】instanceof 关键字

instanceof 通过返回一个布尔值来指出&#xff0c;某个对象是否是某个特定类或者是该特定类的子类的一个实例。 如果 object 是class 的一个实例&#xff0c;则 instanceof 运算符返回 true&#xff0c;如果 object 不是指定类的一个实例&#xff0c;或者object 是null, 则返回…

新风机缺点有哪些?

虽然新风机在提供新鲜空气和改善室内空气质量方面有很多优点&#xff0c;但它也存在一些缺点。下面列举几个常见的新风机缺点&#xff1a; 安装成本较高&#xff1a;新风机需要通过管道连接室内和室外&#xff0c;需要对房屋进行改造和安装。这可能会增加一些额外的安装成本&am…

代码随想录算法训练营第六十二、六十三天 | 单调栈 part 2 | 503.下一个更大元素II 、42. 接雨水、84.柱状图中最大的矩形

目录 503.下一个更大元素II思路代码 42. 接雨水思路一 双指针思路二 单调栈代码 84.柱状图中最大的矩形思路一 双指针思路二 单调栈代码 503.下一个更大元素II Leetcode 思路 将数组乘2来遍历即可&#xff0c;就是加长版的每日温度。 但是处理起来会有细节&#xff0c;如果…

Hive+Flume+Kafka章节测试六错题总结

题目2&#xff1a; EXTERNAL关键字的作用&#xff1f;[多选] A、EXTERNAL关键字可以让用户创建一个外部表 B、创建外部表时&#xff0c;可以不加EXTERNAL关键字 C、通过EXTERNAL创建的外部表只删除元数据&#xff0c;不删除数据 D、不加EXTERNAL的时候&#xff0c;默认创建内…

JAVA学习第一天,java的运行方式

对未来很迷茫&#xff0c;不知道以后能出去干什么&#xff0c;好像掌握的东西很少&#xff0c;从今天开始学习学习java吧&#xff0c;让自己充实起来&#xff0c;记录一下。 jav…