Centos封装镜像
> Linux Centos ISO镜像自定义制作
Ubuntu20.04封装镜像
> Ubuntu 20.04 镜像自定义制作
1、下载镜像
系统环境:ubuntu 22.04
镜像地址:https://mirrors.aliyun.com/ubuntu-releases
root@ubuntu:~# apt install -y p7zip xorriso
root@ubuntu:~# mkdir ubuntu && cd ubuntu
root@ubuntu:~/ubuntu# mkdir source-files
root@ubuntu:~/ubuntu# ls ubuntu-22.04.4-live-server-amd64.iso # 放入下载镜像
ubuntu-22.04.4-live-server-amd64.iso
2、解压镜像
root@ubuntu:~/ubuntu# 7z -y x ubuntu-22.04.4-live-server-amd64.iso -osource-files
root@ubuntu:~/ubuntu# mv source-files/'[BOOT]' BOOT
3、配置grub.cfg
root@ubuntu:~/ubuntu# vim source-files/boot/grub/grub.cfg
menuentry "AutoInstall Ubuntu Server" {
set gfxpayload=keep
linux /casper/vmlinuz quiet autoinstall ds=nocloud\;s=/cdrom/nocloud/ ---
initrd /casper/initrd
}
4、配置meta-data和user-data
storage:layout-name:direct(or lvm)
(1)创建目录与文件
root@ubuntu:~/ubuntu# mkdir source-files/nocloud
root@ubuntu:~/ubuntu# touch source-files/nocloud/meta-data
(2)配置user-data
root@ubuntu:~/ubuntu# vim source-files/nocloud/user-data
#cloud-config
autoinstall:
codecs:
install: false
drivers:
install: false
identity:
hostname: ubuntu
password: $6$I2W1KKabAWXxZNrn$C0spr.EGn7.Rb0MewVU5vSXdugx9m0cH/bdnsDUs/kbXZ6JhhNA6UJj4Rgjhr7u3ky8WNNIBJCOOI.tO9Xeti/
realname: wielun
username: wielun
kernel:
package: linux-generic
keyboard:
layout: us
toggle: null
variant: ''
locale: en_US.UTF-8
timezone: Asia/Shanghai
network:
version: 2
ethernets:
en:
match:
name: "en*"
dhcp4: false
dhcp6: false
addresses:
- 192.168.168.168/24
nameservers:
addresses: []
source:
id: ubuntu-server
search_drivers: false
ssh:
allow-pw: true
authorized-keys: []
install-server: true
storage:
layout:
name: direct
updates: security
version: 1
5、生成镜像
(1)查看基础镜像信息
root@ubuntu:~/ubuntu# xorriso -indev ubuntu-22.04.4-live-server-amd64.iso -report_el_torito as_mkisofs
xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.
xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE : 820 nodes read in 1 seconds
libisofs: NOTE : Found hidden El-Torito image for EFI.
libisofs: NOTE : EFI image start and size: 1024860 * 2048 , 10068 * 512
xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded
Drive current: -indev 'ubuntu-22.04.4-live-server-amd64.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record : El Torito , MBR protective-msdos-label grub2-mbr cyl-align-off GPT
Media summary: 1 session, 1027543 data blocks, 2007m data, 319g free
Volume id : 'Ubuntu-Server 22.04.4 LTS amd64'
-V 'Ubuntu-Server 22.04.4 LTS amd64'
--modification-date='2024021623523000'
--grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:'ubuntu-22.04.4-live-server-amd64.iso'
--protective-msdos-label
-partition_cyl_align off
-partition_offset 16
--mbr-force-bootable
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b --interval:local_fs:4099440d-4109507d::'ubuntu-22.04.4-live-server-amd64.iso'
-appended_part_as_gpt
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7
-c '/boot.catalog'
-b '/boot/grub/i386-pc/eltorito.img'
-no-emul-boot
-boot-load-size 4
-boot-info-table
--grub2-boot-info
-eltorito-alt-boot
-e '--interval:appended_partition_2_start_1024860s_size_10068d:all::'
-no-emul-boot
-boot-load-size 10068
(2)生成镜像
root@ubuntu:~/ubuntu# cd source-files/
root@ubuntu:~/ubuntu/source-files# xorriso -as mkisofs -r \
-V 'Ubuntu 22.04 LTS AUTO (EFIBIOS)' \
-o ~/ubuntu-22.04-server-autoinstall.iso \
--grub2-mbr ../BOOT/1-Boot-NoEmul.img \
-partition_cyl_align off \
-partition_offset 16 \
--mbr-force-bootable \
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b ../BOOT/2-Boot-NoEmul.img \
-appended_part_as_gpt \
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
-c '/boot.catalog' \
-b '/boot/grub/i386-pc/eltorito.img' \
-no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \
-eltorito-alt-boot \
-e '--interval:appended_partition_2:::' \
-no-emul-boot \
.