【问题标题】:Unable to add Raspbian image to Vagrant-libvirt Virtual machine无法将 Raspbian 映像添加到 Vagrant-libvirt 虚拟机
【发布时间】:2017-09-23 14:34:48
【问题描述】:

我正在尝试使用 Vagrant-libvirt 插件为 Raspbian 创建一个虚拟机。但是我未能找到如何添加“2017-09-07-raspbian-stretch-lite.img”图像。

能够使用 qemu 启动映像。

qemu-system-arm -kernel kernel-qemu-4.4.34-jessie -cpu arm1176 -m 256 -machine versatilepb -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw vga=normal console=ttyAMA0" -drive "file=./2017-09-07-raspbian-stretch-lite.img,index=0,media=disk,format=raw" -no-reboot -serial stdio -curses

这是我不完整的 Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
Vagrant.configure("2") do |config|
  config.vm.box_url = File.join(Dir.pwd, "2017-09-07-raspbian-stretch-lite.img")
  config.vm.box = "Raspbian"
  config.vm.provider :libvirt do |libvirt|
    libvirt.driver = "qemu"
    #config.vm.box = "arm"
    # vagrant issues #1673..fixes hang with configure_networks
    config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
    libvirt.uri = 'qemu+unix:///system'
    libvirt.host = 'virtualized'
    libvirt.kernel = File.join(Dir.pwd, "OS/kernel-qemu-4.4.34-jessie")
    #libvirt.kernel = File.join(Dir.pwd, "Ovmlinuz")
    #libvirt.initrd = File.join(Dir.pwd, "initrd")
    #libvirt.storage :file, :size => '20G', :path => "./OS/2017-09-07-raspbian-stretch-lite.img", :allow_existing => true, :shareable => true, :type => 'raw'
    libvirt.emulator_path = '/usr/bin/qemu-system-arm'
    libvirt.cmd_line = 'root=/dev/mmcblk0p2 devtmpfs.mount=0 rw'
    libvirt.memory = 256
    libvirt.cpu_model = 'arm1176'
    libvirt.cpu_fallback = 'allow'
    libvirt.graphics_type = 'none'
  end

end

【问题讨论】:

    标签: vagrant raspbian qemu libvirt vagrant-plugin


    【解决方案1】:

    为此,我已承诺支持 vagrant-libvirt。这是一个有效的配置:

    config.vm.define "rpi" do |rpi|
       # Create rpi.vm
       rpi.vm.hostname = "rpi"
       rpi.vm.box = "raspbian-jessie-lite-2016-02-26"
       rpi.vm.provider :libvirt do |v|
             v.driver = 'qemu'
             v.random_hostname = true
             v.connect_via_ssh = false
             v.memory = 1024
             v.cpus = 1
             v.volume_cache = 'none'
             v.storage_pool_name = "vagrant"
             v.kernel = File.join(Dir.pwd, "kernel")
             v.initrd = File.join(Dir.pwd, "initrd")
             v.machine_type = 'virt'
             v.machine_arch = 'armv7l'
             v.cpu_mode = 'custom'
             v.cpu_model = 'cortex-a15'
             v.cpu_fallback = 'allow'
             v.cmd_line = 'rw earlyprintk loglevel=8 console=ttyAMA0,115200n8 rootwait root=/dev/vda2'
             v.graphics_type = 'none'
             v.disk_bus = 'virtio'
             v.nic_model_type = 'virtio'
             v.features = ["apic","gic version='2'"]
       end
    

    但是,您需要找到或构建支持virt 机器类型的内核和随附的initrd。您可以查看here 了解这方面的一些背景信息。

    【讨论】:

    • 感谢您的帮助!非常感谢。
    猜你喜欢
    • 2013-09-26
    • 1970-01-01
    • 2019-09-17
    • 2014-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-06
    • 2015-10-11
    相关资源
    最近更新 更多