Centos封装镜像
> Linux Centos ISO镜像自定义制作
Ubuntu22.04封装镜像
> Ubuntu 22.04 镜像自定义制作
1、简介
本机环境
:ubuntu 20.04.6
目前,Ubuntu20.04已经默认使用subiquity作为安装工具了 ,debian-installer逐渐被废弃(使用preseed机制进行自动安装),subiquity使用cloud-init进行自动安装.
2、挂载iso
root@ubuntu:~# mount ubuntu-20.04.6-live-server-amd64.iso /media/
root@ubuntu:~# mkdir ubuntu
root@ubuntu:~# cp -r /media/* /media/.disk/ ubuntu
3、修改txt.cfg
添加autoinstall ds=nocloud;s=/cdrom/
root@ubuntu:~# cd ubuntu
root@ubuntu:~/ubuntu# cat isolinux/txt.cfg
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
4、创建sofeware目录与文件
(1)docker下载地址
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/containerd.io_1.5.10-1_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.14~3-0~ubuntu-focal_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce_20.10.14~3-0~ubuntu-focal_amd64.deb
(2)放入对应位置
root@ubuntu:~/ubuntu# tree software/
software/
├── docker
│ ├── compose
│ │ └── docker-compose
│ └── install
│ ├── containerd.io_1.5.10-1_amd64.deb
│ ├── docker-ce-cli_20.10.14~3-0~ubuntu-focal_amd64.deb
│ └── docker-ce_20.10.14~3-0~ubuntu-focal_amd64.deb
└── install.sh
(3)配置install.sh
root@ubuntu:~/ubuntu# cat software/install.sh
#!/bin/bash
cp /cdrom/software/docker/compose/docker-compose /target/usr/local/bin/
5、创建文件user-data
密码默认为:1
可以参考本地文件:/var/log/installer/autoinstall-user-data
root@ubuntu:~/ubuntu# cat user-data
#cloud-config
autoinstall:
version: 1
identity:
hostname: ubuntu
password: $6$I2W1KKabAWXxZNrn$C0spr.EGn7.Rb0MewVU5vSXdugx9m0cH/bdnsDUs/kbXZ6JhhNA6UJj4Rgjhr7u3ky8WNNIBJCOOI.tO9Xeti/
username: wielun
late-commands:
- bash /cdrom/software/install.sh
- cp -r /cdrom/software/ /target/opt/
- curtin in-target --target=/target -- dpkg -i /opt/software/docker/install/containerd.io_1.5.10-1_amd64.deb
- curtin in-target --target=/target -- dpkg -i /opt/software/docker/install/docker-ce-cli_20.10.14~3-0~ubuntu-focal_amd64.deb
- curtin in-target --target=/target -- dpkg -i /opt/software/docker/install/docker-ce_20.10.14~3-0~ubuntu-focal_amd64.deb
6、创建meta-data
root@ubuntu:~/ubuntu# cat meta-data
instance-id: focal-autoinstall
7、生成镜像
root@ubuntu:~/ubuntu# mkisofs -R -J -T -v -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat -o custom.iso .