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

相关推荐
ServBay10 小时前
打通 AI 编程本地运维边界,利用 MCP 协议简化环境与服务管理
后端·ai编程·mcp
程序员cxuan10 小时前
DeepSeek 杀入多模态,识图功能正式上线!
人工智能·后端·程序员
IT_陈寒12 小时前
SpringBoot这个自动配置坑我跳了三次
前端·人工智能·后端
用户3952409988013 小时前
排坑日记:ASP.NET Core 中 "Required field is not provided" 验证错误全记录
后端
用户83562907805114 小时前
使用 Python 自动化 PowerPoint 形状布局与格式设置
后端·python
Oneslide14 小时前
sudo免密权限配置不生效
后端
站大爷IP15 小时前
为什么Python不用var或let声明变量?
后端
赴星半途15 小时前
NestJS实战-创建AuthService
后端
北冥有鱼15 小时前
mqtt 测试
前端·后端