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

相关推荐
用户479492835691520 小时前
同事一个比喻,让我搞懂了Docker和k8s的核心概念
前端·后端
li.wz1 天前
Spring Bean 生命周期解析
java·后端·spring
sanggou1 天前
【实战总结】Spring Boot 后端接口防抖详解与实现方案(含注解 + Redis)
spring boot·后端
Victor3561 天前
Hibernate(26)什么是Hibernate的透明持久化?
后端
盖世英雄酱581361 天前
不是所有的this调用会导致事务失效
java·后端
Victor3561 天前
Hibernate(25)Hibernate的批量操作是什么?
后端
Thetimezipsby1 天前
Go(GoLang)语言基础、知识速查
开发语言·后端·golang
为自己_带盐1 天前
从零开始玩转 Microsoft Agent Framework:我的 MAF 实践之旅-第二篇
后端·microsoft·ai·.net
乌日尼乐1 天前
【Java基础整理】java数组详解
java·后端
想用offer打牌1 天前
一站式讲清IO多路复用(轻松愉悦版)
后端·面试·操作系统