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. 登录

相关推荐
掘金码甲哥8 分钟前
🚀糟糕,我实现的k8s informer好像是依托答辩
后端
GoGeekBaird19 分钟前
Andrej Karpathy:2025年大模型发展总结
后端·github
uzong34 分钟前
听一听技术面试官的心路历程:他们也会有瓶颈,也会表现不如人意
后端
Jimmy34 分钟前
年终总结 - 2025 故事集
前端·后端·程序员
吴佳浩 Alben2 小时前
Python入门指南(四)
开发语言·后端·python
倚栏听风雨2 小时前
lombook java: 找不到符号
后端
码财小子3 小时前
记一次服务器大并发下高延迟问题的定位
后端
我是小妖怪,潇洒又自在3 小时前
springcloud alibaba(九)Nacos Config服务配置
后端·spring·spring cloud
Victor3563 小时前
Netty(26)如何实现基于Netty的RPC框架?
后端