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

相关推荐
弹简特7 分钟前
【JavaEE16-后端部分】SpringBoot日志的介绍
java·spring boot·后端
泯仲10 分钟前
RabbitMQ的延迟消息在项目中的运用及实现剖析
开发语言·后端·rabbitmq
*.✧屠苏隐遥(ノ◕ヮ◕)ノ*.✧17 分钟前
Day01 Junit 单元测试 & 反射
java·后端·junit·单元测试
loading小马31 分钟前
解决idea2024版本Services栏没有显示Springboot窗口问题
java·spring boot·后端
好学且牛逼的马31 分钟前
Spring Boot 3 核心实战指南
java·spring boot·后端
却道天凉_好个秋35 分钟前
WebRTC(十五):NAT穿透机制深度解析
后端·webrtc·stun·turn·ice·net网络穿透
uzong38 分钟前
职场上要懂的思维模型系列(第一章)
后端
代码探秘者43 分钟前
【Redis】双写一致性:延迟双删 / 读写锁 / 异步通知 / Canal,一文全解
java·数据库·redis·后端·算法·缓存
IT枫斗者1 小时前
CentOS 7 一键部署 K8s 1.23 + Rancher 2.7 完整指南
java·linux·spring boot·后端·kubernetes·centos·rancher
ding_zhikai1 小时前
【Web应用开发笔记】Django笔记8:用户账户相关功能
笔记·后端·python·django