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

相关推荐
学长毕设几秒前
基于SpringBoot非遗文化展示与传播平台设计与实现-附源码
java·spring boot·后端
杨凯凡1 小时前
Spring Boot SSE 上线后不实时、频繁断线?Nginx 缓冲、心跳与连接回收实战
spring boot·后端·nginx
锋行天下1 小时前
langgraph 全栈项目(三)
前端·人工智能·后端
金銀銅鐵2 小时前
用 Swing 重做操作数栈演示
java·jvm·后端
锋行天下2 小时前
langgraph 全栈项目(二)
前端·人工智能·后端
锋行天下3 小时前
langgraph全栈项目(一)
前端·人工智能·后端
学长毕设3 小时前
基于SpringBoot的游戏攻略社区交流系统-附源码
spring boot·后端·游戏
程序员cxuan3 小时前
不得了,Google 造反了,Opus 5.5 又被干了
人工智能·后端·程序员
Csvn4 小时前
Nginx 缓存体系:三层 key、七态 X-Cache-Status 与锁/stale 策略
后端·nginx
时间海8715 小时前
前端表单如何防止重复提交
后端