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

相关推荐
普通网友1 小时前
PHP语言的正则表达式
开发语言·后端·golang
葵续浅笑3 小时前
从Spring拦截器到Filter过滤器:一次报文修改加解密的填坑经验
java·后端·spring
snakeshe10103 小时前
Java集合框架深度解析:核心类库与实战应用
后端
大鹏19883 小时前
告别 XML 与字符串拼接:dbVisitor 如何以“多范式融合”重塑 Java DAL 层
后端
你有医保你先上3 小时前
go-es:一个优雅的 Elasticsearch Go 客户端
后端·elasticsearch
柠檬味的Cat4 小时前
零基础搭建WordPress网站完整流程
后端·php
代龙涛4 小时前
wordpress块主题
开发语言·后端·php
禾味4 小时前
过程即奖励|前端转后端经验分享
前端·后端·面试
jipeng59945 小时前
(在项目中学习技术)完成使用swoole完成App二维码扫码登录网页端的操作
后端·php
掘金者阿豪5 小时前
Maven打包血泪史:当你的IDEA路径里藏了个空格,整个宇宙都与你为敌
后端