在Vagrant中设置VM存储大小时出错

时间:2015-11-11 01:25:43

标签: vagrant vagrantfile vagrant-provision

我正在关注此链接https://github.com/acfreitas/oraclebox

我尝试在我的Vagrant中包含用于设置VM存储大小的代码。 但我得到的错误如下。

==> vagrant: Running provisioner: shell...
    vagrant: Running: C:/Users/skywork/AppData/Local/Temp/vagrant-shell20151111-11660-1l3hhe.sh
==> vagrant: ++ '[' grep -ic 64GB /sizeDisk ']'
==> vagrant: /tmp/vagrant-shell: line 4: [: too many arguments
==> vagrant: ++ sudo fdisk -u /dev/sdb
==> vagrant: Welcome to fdisk (util-linux 2.23.2).
==> vagrant:
==> vagrant: Changes will remain in memory only, until you decide to write them.
==> vagrant: Be careful before using the write command.
==> vagrant:
==> vagrant:
==> vagrant: Command (m for help): Partition type:
==> vagrant:    p   primary (0 primary, 0 extended, 4 free)
==> vagrant:    e   extended
==> vagrant: Select (default p): Partition number (1-4, default 1): First sector (2048-31457279, default 2048): Using default value 2048
==> vagrant: Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279): Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279): Value out of range.
==> vagrant: Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279): Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279):
==> vagrant: Device does not contain a recognized partition table
==> vagrant: Building a new DOS disklabel with disk identifier 0x38d6fb65.
==> vagrant: Do you really want to quit?
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

这是我的Vagrant文​​件代码:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION_NO = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION_NO) do |config|

    config.vm.define "vagrant" do |oracle|
        oracle.vm.box = "CentOS7"
        oracle.vm.boot_timeout = 5000
        oracle.vm.box_url = "http://zzz.zzz.zzz/CentOS7.1.1503x86_64.box"

        oracle.ssh.username = "root"
        oracle.ssh.password = "vagrant"
        config.vbguest.auto_update = false
        oracle.vm.synced_folder "./share", "/root/share", :create => true, type: "nfs"


        oracle.vm.provider :virtualbox do |vb|
            vb.gui = true
            vb.name = "CentOS7"
            vb.customize ["modifyvm", :id, "--memory", "2048", "--cpus", "1", "--nicpromisc2", "allow-all"]
            vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
            vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]

            vb.customize ["modifyvm", :id, "--name", "CentOS7"]
            if !File.exist?("disk/oracle.vdi")
               vb.customize [
                    'createhd', 
                    '--filename', 'disk/oracle', 
                    '--format', 'VDI', 
                    '--size', 15360
                    ] 
               vb.customize [
                    'storageattach', :id, 
                    '--storagectl', "SATA", 
                    '--port', 1, '--device', 0, 
                    '--type', 'hdd', '--medium', 'disk/oracle.vdi'
                    ]
             end    
        end

        oracle.vm.provision "shell", path: "bash_files/add-oracle-disk.sh"
        oracle.vm.provision "shell", :inline => "localectl set-locale LANG=en_US.UTF-8"

        oracle.vm.provision :chef_solo do |chef|            
            chef.custom_config_path = "Vagrantfile.chef"
            chef.add_recipe "base"
        end   
    end
end

Vagrant::Config.run do |config|
    config.vm.network :bridged, auto_config: false
end

这是我的VM默认磁盘大小:

enter image description here

我需要在VagrantFile和add-oracle-disk.sh上添加磁盘空间(例如10GB)的价值和价值。

请帮忙。

0 个答案:

没有答案