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

相关推荐
GetcharZp2 小时前
比 Zap 还要快?Go 社区高性能日志神器 Zerolog 落地实践指南
后端
anzhxu2 小时前
Go基础之环境搭建
开发语言·后端·golang
刀法如飞3 小时前
一款Python语言Django框架DDD脚手架,适合中大型项目
后端·python·领域驱动设计
zb200641203 小时前
SpringBoot详解
java·spring boot·后端
AI人工智能+电脑小能手3 小时前
【大白话说Java面试题】【Java基础篇】第7题:HashMap的get流程是什么
java·后端·面试·哈希算法·散列表·hash-index·hash
霸道流氓气质4 小时前
SpringBoot+LangChain4j+Ollama+RAG(检索增强生成)实现私有文档向量化检索回答
java·spring boot·后端
MiNG MENS5 小时前
基于SpringBoot和Leaflet的行政区划地图掩膜效果实战
java·spring boot·后端
IT_陈寒5 小时前
Vite静态资源加载把我坑惨了
前端·人工智能·后端
2601_949814695 小时前
Spring Boot中的404错误:原因、影响及处理策略
java·spring boot·后端
RDCJM5 小时前
Spring Boot spring.factories文件详细说明
spring boot·后端·spring