一、环境准备

1.下载ubuntu 桌面版系统

地址:

https://releases.ubuntu.com/24.04.4/ubuntu-24.04.4-desktop-amd64.iso
https://mirrors.aliyun.com/ubuntu-releases/24.04.4/ubuntu-24.04.4-desktop-amd64.iso

2.安装ubuntu桌面版并上传iso文件到指定目录

image

 

二、使用 Cubic 构建 ISO

1. 安装 Cubic(Ubuntu 24.04)

sudo add-apt-repository ppa:cubic-wizard/release
sudo apt update
sudo apt install cubic

 

2. 启动 Cubic

cubic

3. 选择工作目录(如 /data/test

image

 

4. 选择官方 ISO

image

 

image

 

5. 进入 chroot 环境后,执行以下操作:

a.将你的文件放入 ISO指定目录

image

image

 

b.更新软件源
# 备份原 sources.list
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 替换为清华源(Ubuntu 22.04 jammy)
cat > /etc/apt/sources.list <<EOF
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
EOF

apt update

 

 
c.预安装ssh及需要的服务

image

 

 

d.制作第一次开机自动执行脚本
root@edhr-server:/home/ubuntu# cat /etc/cloud/cloud.cfg.d/99-edhr.cfg 
#cloud-config

# 使用安装时创建的默认用户
users:
  - default

# 关键:将该用户加入 docker 组(避免 sudogroups:
  - docker
system_info:
  default_user:
    groups: [docker, sudo]

# 首次启动时执行命令
runcmd:
  # 1. 确保 Docker 服务正在运行(安全起见)
  - [ systemctl, start, docker ]
  - [ systemctl, enable, docker ]
  - [ systemctl, start, ssh ]
  - [ systemctl, enable, ssh ]

  # 3. 赋予脚本执行权限
  - [ chmod, -R, +x, /opt/edhr/scripts ]

  # 4. 执行安装脚本(记录日志)
  - [ sh, -c, 'cd /opt/edhr/scripts && ./install.sh >> /var/log/edhr-install.log 2>&1' ]

  # 5. (可选)设置开机自启你的服务
  - [ sh, -c, 'echo "@reboot cd /opt/edhr/scripts && ./start.sh" | crontab -u $USER -' ]

# 可选:设置主机名
hostname: edhr-server
View Code

 

 e.清理缓存
apt clean
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/*
history -c

 

F.直接next

image