ubuntu20.04打包iso镜像自动安装
2021/6/30 7:20:38
本文主要是介绍ubuntu20.04打包iso镜像自动安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
系统环境:ubuntu20.04
下载ubuntu-20.04.2-live-server-amd64.iso
wget https://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso
挂载系统到/mnt下
sudo mount /home/www/ubuntu-20.04.2-live-server-amd64.iso /mnt
拷贝目录&文件
拷贝/mnt目录中的所有内容到/home/www/ubuntu/目录下
mkdir -p /home/www/ubuntu/ cp -rf /mnt/* /mnt/.disk/ /home/www/ubuntu/
所需自动部署文件
资料:
- https://ubuntu.com/server/docs/install/autoinstall
- https://ubuntu.com/server/docs/install/autoinstall
user-data文件:
相关参数参考:
- https://ubuntu.com/server/docs/install/autoinstall-reference
- 可以手动安装一个系统来获取user-data文件
手动安装好系统后,这个文件就是/var/log/installer/autoinstall-user-data,user-data文件
#查看 cat /var/log/installer/autoinstall-user-data
适当进行修改如对磁盘分区大小修改
原完整文件:
#cloud-config autoinstall: apt: geoip: true preserve_sources_list: false primary: - arches: [amd64, i386] uri: http://cn.archive.ubuntu.com/ubuntu - arches: [default] uri: http://ports.ubuntu.com/ubuntu-ports identity: {hostname: www, password: $6$FqFvANIIt7lD3d4V$j06NXAbMpjJqdxR/l9jcDXjJl/bULXT9W8EMneB4djvZt3TF5hOr399AThq/3T6efVttZKfz8r2Tp2cqF1xDt0, realname: www, username: www} keyboard: {layout: us, toggle: null, variant: ''} locale: en_US network: ethernets: enp0s3: {dhcp4: true} enp0s8: {dhcp4: true} version: 2 ssh: allow-pw: true authorized-keys: [] install-server: true storage: config: - {ptable: gpt, serial: VBOX_HARDDISK_VB8c6ac1fe-c81d121d, path: /dev/sda, wipe: superblock-recursive, preserve: false, name: '', grub_device: true, type: disk, id: disk-sda} - {device: disk-sda, size: 1048576, flag: bios_grub, number: 1, preserve: false, grub_device: false, type: partition, id: partition-0} - {device: disk-sda, size: 107371036672, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-1} - {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0} - {device: format-0, path: /, type: mount, id: mount-0} version: 1
对存储部分进行了修改
#删除了磁盘序列号参数 serial: VBOX_HARDDISK_VB8c6ac1fe-c81d121d, #修改磁盘容量(大小为byte),避免出现磁盘总容量不一样导致的自动安装错误 {device: disk-sda, size: 53687091200, wipe: superblock, flag: '', number: 2,
修改后完整文件
#cloud-config autoinstall: apt: geoip: true preserve_sources_list: false primary: - arches: [amd64, i386] uri: http://cn.archive.ubuntu.com/ubuntu - arches: [default] uri: http://ports.ubuntu.com/ubuntu-ports identity: {hostname: www, password: $6$FqFvANIIt7lD3d4V$j06NXAbMpjJqdxR/l9jcDXjJl/bULXT9W8EMneB4djvZt3TF5hOr399AThq/3T6efVttZKfz8r2Tp2cqF1xDt0, realname: www, username: www} keyboard: {layout: us, toggle: null, variant: ''} locale: en_US network: ethernets: enp0s3: {dhcp4: true} enp0s8: {dhcp4: true} version: 2 ssh: allow-pw: true authorized-keys: [] install-server: true storage: config: - {ptable: gpt, path: /dev/sda, wipe: superblock-recursive, preserve: false, name: '', grub_device: true, type: disk, id: disk-sda} - {device: disk-sda, size: 1048576, flag: bios_grub, number: 1, preserve: false, grub_device: false, type: partition, id: partition-0} - {device: disk-sda, size: 53687091200, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-1} - {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0} - {device: format-0, path: /, type: mount, id: mount-0} version: 1
meta-data文件:
cat > meta-data << EOF instance-id: focal-autoinstall EOF
文件拷贝
将meta-data 、user-data文件拷贝到/home/www/ubuntu/目录下
修改引导配置文件
文件路径:
/home/www/ubuntu/isolinux/txt.cfg
原文件:
default live label live menu label ^Install Ubuntu Server kernel /casper/vmlinuz append initrd=/casper/initrd quiet --- label hwe-live menu label ^Install Ubuntu Server with the HWE kernel kernel /casper/hwe-vmlinuz append initrd=/casper/hwe-initrd quiet --- label memtest menu label Test ^memory kernel /install/mt86plus label hd menu label ^Boot from first hard disk localboot 0x80
修改后文件:
default live label live menu label ^Install Ubuntu Server kernel /casper/vmlinuz append initrd=/casper/initrd quiet autoinstall ds=nocloud;s=/cdrom/ --- label hwe-live menu label ^Install Ubuntu Server with the HWE kernel kernel /casper/hwe-vmlinuz append initrd=/casper/hwe-initrd quiet --- label memtest menu label Test ^memory kernel /install/mt86plus label hd menu label ^Boot from first hard disk localboot 0x80
配置完成。
打包成iso镜像文件
进入/home/www/目录执行如下命令对ubuntu/目录进行打包
#安装mkisofs sudo apt install mkisofs -y sudo mkisofs -R -J -T -v -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat -o auto-ubuntu-20.04.4-server-amd64.iso ubuntu/
- 会在/home/www/目录下生成auto-ubuntu-20.04.4-server-amd64.iso文件
- 就可以使用该镜像文件进行自动安装了
测试通过环境:
- virtualbox
- 打包环境系统:ubuntu20.04
- 软件:mkisofs
这篇关于ubuntu20.04打包iso镜像自动安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南