使用iPXE自动化安装ubuntu22.04
通过查阅资料发现,网上的ubuntu自动化安装教程,多以pxe的方式安装,现分享一种基于iPXE的安装教程,欢迎交流!
1.新建VM虚拟机
首先新建一台VMware,我使用的是centos7.9的操作系统,并配置能连接外网。这一步具体操作请自行查询资料。
2.配置虚拟机为IPXE服务器
2.1安装必要的服务
[root@localhost ~]# yum install tftp-server xinetd dhcp httpd dnsmasq -y
2.2 配置http服务
2.2.1 上传ubuntu22.04的iso镜像
将ubuntu22.04的iso镜像传到虚拟机中(使用xftp、共享文件都行,看你喜欢)。这里先暂时放在root目录(ps:放在哪里都可以)。
2.2.2 在http目录下创建iso目录, 并将iso拷贝至iso目录
cd /var/www/html/
mkdir iso
cp /root/ubuntu-22.04-live-server-amd64.iso /var/www/html/iso # 此处最好是cp,因为等会还需要再次使用该iso镜像
2.2.3挂载iso, 提取initrd和 vmlinuz
mkdir /opt/disk mount -o loop /root/ubuntu-22.04-live-server-amd64.iso /opt/disk/
将initrd和 vmlinuz拷贝至 刚才创建的iso目录
cp /opt/disk/casper/initrd /var/www/html/iso
cp /opt/disk/casper/vmlinuz /var/www/html/iso
2.2.4 创建 user-data和meta-data
mkdir -p /var/www/html/ks/ubuntu
touch meta-data #meta-data 是空文件,但是必须要有
创建一个user-data,文件内容如下:
ps: 也可以参照https://ubuntu.com/server/docs/install/autoinstall-reference自行创建,最方便的方式是先通过图形化界面安装一次系统,然后系统中/var/log/install/auto-user-data 拷贝出来使用。注意在修改时严格遵守yaml语法。
#cloud-config
autoinstall:drivers:install: falseidentity:hostname: ZHHpassword: $6$5.4Db4xd76bu0i3v$ujjOoIhX2cs.TBA8XFi/TZ/mrNaNA9CdClWpVpOUeFhqIINuq8w4cpp9BUDAVIN88h7oPoYDCofRt9zs0zPWo1realname: ZHHusername: zhhkeyboard:layout: ustoggle: nullvariant: ''locale: en_US.UTF-8ssh:allow-pw: trueauthorized-keys: []install-server: truestorage:config:- ptable: gptwipe: superblock-recursivepreserve: falsename: ''grub_device: truetype: diskid: disk-sdamatch: size: largest- device: disk-sdasize: 1048576flag: bios_grubnumber: 1preserve: falsegrub_device: falsetype: partitionid: partition-0- device: disk-sdasize: 8589934592wipe: superblockflag: swapnumber: 2preserve: falsegrub_device: falsetype: partitionid: partition-1- fstype: swapvolume: partition-1preserve: falsetype: formatid: format-0- path: ''device: format-0type: mountid: mount-0- device: disk-sdasize: 1073741824wipe: superblockflag: ''number: 3preserve: falsegrub_device: falsetype: partitionid: partition-2- fstype: xfsvolume: partition-2preserve: falsetype: formatid: format-1- device: disk-sdasize: 8589934592wipe: superblockflag: ''number: 4preserve: falsegrub_device: falsetype: partitionid: partition-3- fstype: xfsvolume: partition-3preserve: falsetype: formatid: format-2- device: disk-sdasize: 21474836480wipe: superblockflag: ''number: 5preserve: falsegrub_device: falsetype: partitionid: partition-4- fstype: xfsvolume: partition-4preserve: falsetype: formatid: format-3- path: /device: format-3type: mountid: mount-3- device: disk-sdasize: -1wipe: superblockflag: ''number: 6preserve: falsegrub_device: falsetype: partitionid: partition-5- fstype: xfsvolume: partition-5preserve: falsetype: formatid: format-4- path: /datadevice: format-4type: mountid: mount-4- path: /bootdevice: format-1type: mountid: mount-1- path: /vardevice: format-2type: mountid: mount-2swap:swap: 0updates: securityversion: 1
2.3 配置tftp服务
2.3.1下载并编译ipxe固件
ps: 编译所需的依赖请自行安装
[root@localhost ~]# cd /root
[root@localhost ~]# yum install -y xz-devel
[root@localhost ~]# git clone https://github.com/ipxe/ipxe.git
[root@localhost ~]# cd /root/ipxe/src
[root@localhost src]# make bin/undionly.kpxe
[root@localhost src]# make bin-x86_64-efi/ipxe.efi
执行完之后,在bin中会有一个undionly.kpxe文件,在bin-x86_64-efi会有ipxe.efi,之后会用到这两个文件。
2.3.2 修改 tftp配置
[root@localhost ~]# vim /etc/xinetd.d/tftp
2.3.3复制ipxe固件至tftp根目录
[root@localhost ~]# cp /root/ipxe/src/bin/undionly.kpxe /var/lib/tftpboot/
[root@localhost ~]# cp /root/ipxe/src/bin-x86_64-efi/ipxe.efi /var/lib/tftpboot/
2.3.4 配置启动脚本
vi /var/lib/tftpboot/ubuntu2204.cfg
内容如下:
#!ipxe
set product-name ubuntu2204
set os-name ubuntu2204set menu-timeout 10000
set submenu-timeout ${menu-timeout}
set menu-default exit:start
menu boot from iPXE server
item --gap -- --------------------------------------------
item --gap -- serial:${serial}
item --gap -- mac:${mac}
item --gap -- ip:${ip}
item --gap -- netmask:${netmask}
item --gap -- gateway:${gateway}
item --gap -- dns:${dns}
item
item --gap -- --------------------------------------------
item install-os ${product-name}
choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel
goto ${selected}:install-os
set server http://ipxe.server/
initrd ${server}iso/initrd
kernel ${server}iso/vmlinuz initrd=initrd ip=dhcp url=${server}iso/ubuntu-22.04.1-live-server-amd64.iso autoinstall ds=nocloud-net;s=${server}/ks/ubuntu/ root=/dev/ram0 cloud-config-url=/dev/null console=ttyS0,115200n8
boot
如果没有串口,就将’console=ttyS0,115200n8 ‘删除
2.4 配置DNS服务
[root@localhost ~]# vim /etc/dnsmasq.conf
2.5 配置dhcp服务
创建dhcp配置文件
[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
编辑如下内容
# This is a very basic subnet declaration.
option client-architecture code 93 = unsigned integer 16;
subnet 10.10.0.0 netmask 255.255.255.224 {range 10.10.0.10 10.10.0.20;next-server 10.10.0.2;if exists user-class and option user-class = "iPXE" {filename "ubuntu2204.cfg";} elsif option client-architecture = 00:00 {filename "undionly.kpxe";} else {filename "ipxe.efi";}
}
并在dhcp配置文件中,指定DNS服务器
2.6 修改虚拟机ip
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# systemctl restart netowrk
2.7 修改虚拟机为桥接模式,配置物理网卡
选择虚拟机为桥接模式:
打开虚拟网络编辑器:
点击更改设置:
修改桥接的网口:
2.8 关闭防火墙,重复服务
关闭防火墙 和 强访
[root@localhost ~]# systemctl stop firewalld &&systemctl disable firewalld
[root@localhost ~]# systemctl stop getenforce &&systemctl disable getenforce
开启dhcp,http,dns,tftp 服务
[root@localhost ~]# systemctl start dhcpd tftp httpd dnsmasq
至此ipxe服务器已经搭建完成了。
附上所有的参考资料:
https://ubuntu.com/server/docs/install/autoinstall-reference
https://forum.level1techs.com/t/linux-installation-using-i-pxe/186721
https://ipxe.org/docs
https://blog.csdn.net/supahero/article/details/115829836
https://blog.csdn.net/weixin_46243964/article/details/119650128?
spm=1001.2101.3001.6650.8&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-8-119650128-blog-117298899.pc_relevant_3mothn_strategy_and_data_recovery&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-8-119650128-blog-117298899.pc_relevant_3mothn_strategy_and_data_recovery&utm_relevant_index=12
https://github.com/ipxe/ipxe/discussions/709
https://curtin.readthedocs.io/en/latest/topics/storage.html
https://www.molnar-peter.hu/en/ubuntu-jammy-netinstall-pxe.html
linux就该这么学 第19章
使用iPXE自动化安装ubuntu22.04相关推荐
- 从零开始安装ubuntu22.04并搭建远程深度学习环境
文章目录 一.安装ubuntu22.04 1.制作ubuntu的启动U盘 2.安装ubuntu 3.更新并安装一些基本包 4.中文输入法 二.配置相关环境 1. 安装Nvidia驱动 2.安装anac ...
- Win10安装Ubuntu22.04后,The Windows Subsystem for Linux optional component is not enabled. Please enable
Win10在应用商店安装Ubuntu22.04无法运行 显示 The Windows Subsystem for Linux optional component is not enabled. Pl ...
- 虚拟机安装Ubuntu22.04 以及个人相关配置记录
安装Ubuntu22.04遇到的问题 Q1:虚拟机无法全屏自适应客户端的屏幕 解决方案:重新安装VMware Tool 虚拟机设置:CD/DVD2和软盘设成"自动检测": 虚拟机- ...
- amd6800h安装ubuntu22.04 笔记本休眠花屏解决办法
amd6800h是22年的zen3+ apu,而ubuntu22.04内核是5.15,驱动不兼容造成花屏现象是可以理解的 内核5.18更新了图形驱动,那么接下来就升级到5.18预计可以解决花瓶问题 网 ...
- VMware虚拟机安装Ubuntu22.04并配置网络
一 Ubuntu22.04下载 地址:https://ubuntu.com Ubuntu Desktop:包含图形用户界面 Ubuntu Server:不包含图形用户界面 二 VMware安装Ubun ...
- vmware安装ubuntu22.04,界面太小
平台信息: ubuntu22.04 .vmware虚拟机 作者:庄泽彬(未经允许,请勿转载) 说明:使用vmware安装ubuntu22.04之后,ubuntu的界面太小没有适应vmware界面,上网 ...
- 安装ubuntu22.04 解决wifi6驱动问题 + 没有Realtek rtl8852be 驱动(本人电脑:Redimbook R7 5800H)
Ubuntu 没有wifi图标,没有Realtek rtl8852be 驱动 问题原因: 由于该系列无线网卡属于"螃蟹网卡",inter12代 内核版本 > 5.18,Ubu ...
- thinkbook14+16+ 安装ubuntu22.04 解决wifi6驱动问题 + 加装完善让笔记本化身完全体,一劳永逸思路
安装ubuntu22.04 解决wifi6驱动问题[thinkbook14+/16+] Ubuntu 没有wifi图标,没有Realtek rtl8852be 驱动 问题原因: 由于该系列无线网卡属于 ...
- 在 Windows10 系统下安装 Ubuntu22.04 系统
在 Windows10 系统下安装 Ubuntu22.04 系统 本文根据本人成功安装为背景,进行详细地讲解在 Windows10 系统下安装 Ubuntu22.04 系统.本人的成功安装也是根据前辈 ...
最新文章
- 用access做考场桌贴_利用Word、Excel、Access进行考务安排及学生成绩分析的有效途径-教育文档...
- Sql Server查询语句的一些小技巧
- 大智慧数据文件python_马克的Python学习笔记#模块和包 3
- pg 递归算法_PostgreSQL递归查询_20191212
- 初级程序员需要接触好的架构代码
- db2 9.7 64位_2020年使用2016年的第一代9.7英寸 Ipad pro?
- C++基础知识(五)C++的一些特性
- 人脸方向学习(十一):Face Landmark Detection-PFLD解读
- 《报错与问题解决方案》总结v1.0版本
- colspan会影响内部单元格宽度失效_冷轧轧辊失效原因分析及改进措施
- 运放放大倍数计算公式_运放选型速记指南
- AT91SAM9260开发板
- canvas画圆形图片
- 银行计算机岗位招聘简历,这才是HR筛选银行简历的正确打开方式!
- 基于html评定奖学金页面代码,学校助学奖学金申请表页面模板
- 为什么电脑无限重启,难道是我的电脑装了无限宝石?
- SQL字符串转化数字
- 虚幻引擎学习笔记——Month1 Week1
- iOS 下载量、注册量追踪统计
- WPF 制作高性能的透明背景异形窗口(使用 WindowChrome 而不要使用 AllowsTransparency=True)
热门文章
- 为什么薄膜干涉的厚度要很小_薄膜厚度对薄膜干涉现象的影响及其物理意义
- matlab物理计算与可视化,清华大学出版社-图书详情-《MATLAB物理计算与可视化》...
- 悬剑武器库团队内部日刊
- 锂云母提锂浸取液除铝
- 2022.05.04 HTML学习第三天
- 2021年全球CT和PET扫描仪收入大约7229.4百万美元,预计2028年达到7883百万美元
- 深入理解计算机系统——第六章 The Memory Hierarchy
- 低学历转Java能找到工作吗?
- 作文提升~写景常用的拟人句,很经典
- 中指无名指收起 其他3个手指伸出来 这种手势是什么意思?