Files
blog/docs/tech/Customize-Debian-13-Image.md
Cat Tom f383758f16
All checks were successful
Deploy / deploy (push) Successful in 1m45s
Add Customize-Debian-13-Image.md
2026-03-17 21:22:36 +08:00

68 lines
2.0 KiB
Markdown

# 定制 Debian 13 镜像
通过 CircleCI 自动构建与定制 Debian 13 镜像。
基础镜像: [Debian 13(trixie)](https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.qcow2)
软件源: [清华大学开源软件镜像站](https://mirrors.tuna.tsinghua.edu.cn/help/debian/) {==生产环境中慎重使用高校镜像站==}
项目: [cattomgithub/debian-cloud-image](https://github.com/cattomgithub/debian-cloud-image)
## 创建 Proxmox 模板
``` bash
# 创建空白虚拟机
qm create 9000 \
--machine q35 \
--cpu cputype=host \
--name "debian-13-template" \
--scsi2 "local:cloudinit" \
--serial0 socket \
--vga none \
--scsihw virtio-scsi-single \
--net0 virtio,bridge=vmbr0 \
--agent 1 \
--ostype l26 \
--memory 1024
# 导入镜像
qm importdisk 9000 "/path/to/image.qcow2" local-lvm -format qcow2
qm set 9000 --scsi0 "local:9000/vm-9000-disk-0.qcow2,discard=on,ssd=1"
qm set 9000 --boot order=scsi0
# 将虚拟机转为模板
qm template 9000
```
## 使用模板创建虚拟机
创建虚拟机可以在 Web 管理面板上进行,也可依照以下 shell 执行。
创建虚拟机时,选择刚创建的模板,**完整克隆**虚拟机。
创建虚拟机后,启动虚拟机前,用 Cloud-init 配置用户、密码和 SSH Key 等内容。
``` bash
# 创建虚拟机
qm clone 9000 100 \
--name "debian-13-vm" \
--full 1 \
--pool "local-lvm" \
--storage "local-lvm" \
--format qcow2
# Cloud-init 配置
qm set 100 --ciuser cattom
qm set 100 --cipassword "1145141919810"
qm set 100 --sshkey /path/to/your-public-key.pub
qm set 100 --ipconfig0 ip=dhcp ## DHCP 获取
qm set 100 --ipconfig0 ip=192.168.1.100/24,gw=192.168.1.1 ## 手动指定
```
## 参考
[为 Proxmox VE 定制 Debian Cloud 系统镜像与创建虚拟机模板 | Sukka's Blog](https://blog.skk.moe/post/proxmox-ve-customize-debian-cloud-image/)
[Cloud-Init Support - Proxmox VE](https://pve.proxmox.com/wiki/Cloud-Init_Support)
[qm(1)](https://pve.proxmox.com/pve-docs/qm.1.html)