qemu 启动 debian 虚拟机

qemu 启动 debian 虚拟机

debian linux env:

  • insatll qemu: apt install qemu-utils qemu-system-x86
  • install cloud-image-utils apt-get install cloud-image-utils
  • doload debian qcow2: wiki.debian.org/DebianStabl...

1. 创建 秘钥对

bash 复制代码
ssh-keygen -t rsa -b 4096 -f id_rsa -C test1 -N "" -q

2. 创建 cloud config 种子镜像

bash 复制代码
▶ cat cloud_init.cfg                                                                                                                                                                           #cloud-config
hostname: test1
fqdn: test1.example.com
manage_etc_hosts: true
users:
  - name: debian
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups: users, admin
    home: /home/debian
    shell: /bin/bash
    lock_passwd: false

ssh_pwauth: false
disable_root: false
chpasswd:
  list: |
     debian:linux
  expire: False
chpasswd:
  list: |
     root:root
  expire: False
packages:
  - qemu-guest-agent
# written to /var/log/cloud-init-output.log
final_message: "The system is finally up, after $UPTIME seconds"

生成 cloud config 镜像

bash 复制代码
cloud-localds -v cloud-cfg.img cloud_init.cfg

3. 启动 vm

bash 复制代码
qemu-system-x86_64 \
  -name test1 \
  -m 2048 \
  -smp 2 \
  -boot menu=on \
  -drive file=debian.qcow2,format=qcow2,if=virtio \
  -drive file=cloud-cfg.img,format=raw,if=virtio,media=cdrom \
  -nographic \
  -vnc :0 \
  -netdev user,id=tap0 \
  -device virtio-net-pci,netdev=tap0 

4. 登录

相关推荐
凤山老林16 小时前
轻量级规则引擎落地:Spring Boot 集成 LiteFlow 实现动态业务编排与热更新
java·spring boot·后端·规则引擎·liteflow
IT_陈寒17 小时前
Python装饰器把我坑惨了,原来这样用才不掉链子
前端·人工智能·后端
程序员爱钓鱼17 小时前
Rust Associated Type关联类型详解:为Trait定义内部类型
前端·后端·rust
程序员爱钓鱼17 小时前
Go 编程实战:匿名函数 Anonymous Function——没有名字的函数与灵活回调
后端·面试·go
卷无止境18 小时前
FastAPI 后台任务的边界,以及 Celery、Redis 与自建调度系统的选择
后端·python
卷无止境18 小时前
Linux + Docker + FastAPI 工程化实践指南
后端·python·fastapi
AI绘画哇哒哒1 天前
【建议收藏!】35岁后端血泪忠告,这3类人别硬转Agent(过来人亲述)
java·人工智能·后端·ai·程序员·大模型·agent
唐青枫1 天前
一个值多种形态:Zig union、Tagged Union 与内存布局实战
后端
卷无止境1 天前
Windows 上丝滑开发 Python,并稳定构建 Docker 镜像
后端·python·docker
Nturmoils1 天前
备份完不算完,先还原到临时库验一遍
后端