diff --git a/docs/tech/Commands-for-Server-Operation-and-Maintenance.md b/docs/tech/Commands-for-Server-Operation-and-Maintenance.md index 8bea4da..76c59ad 100644 --- a/docs/tech/Commands-for-Server-Operation-and-Maintenance.md +++ b/docs/tech/Commands-for-Server-Operation-and-Maintenance.md @@ -1,5 +1,9 @@ # 服务器运行与维护常用命令 +## 创建虚拟机 + +[创建基于定制 Debian 13 镜像的虚拟机](https://blog.cattom.site/tech/Customize-Debian-13-Image) + ## 初始化 ### Maria @@ -110,15 +114,6 @@ sudo nano /etc/ssh/sshd_config 重启 SSH 服务以刷新配置: `sudo systemctl restart ssh` -## 恢复备份文件/目录 (可选) - -``` bash -cd /root || exit -wget -c https://cattom.oss-cn-shenzhen.aliyuncs.com/[server_name]/backup/[file_name].tar.gz -tar -zxvf [file_name].tar.gz -sudo rm [file_name].tar.gz -``` - ## 安装业务程序 (按需安装) **首先,通过Maria管理工具安装需要的业务工具: `maria` - ++2++** diff --git a/docs/tech/Customize-Debian-13-Image.md b/docs/tech/Customize-Debian-13-Image.md new file mode 100644 index 0000000..7c832a2 --- /dev/null +++ b/docs/tech/Customize-Debian-13-Image.md @@ -0,0 +1,68 @@ +# 定制 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) \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 6abd9e1..27c3437 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -97,6 +97,7 @@ nav: - "小米 CR6608": tech/CR6608.md - "Mi 8 UD (equuleus)": tech/Mi8UD(equuleus).md - "Redmi 4X (santoni)": tech/Redmi4X(santoni).md + - "定制 Debian 13 镜像": tech/Customize-Debian-13-Image.md - "PicoKeys: YubiKey 的开源平替": tech/Picokeys.md - "手把手教你备份和还原 Docker 卷": tech/Backup-and-Restore-of-Docker-Volumes-A-Step-by-Step-Guide.md - "在 Ubuntu 24.04 上添加交换空间": tech/How-to-Add-Swap-Space-on-Ubuntu-2404.md