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

在Vagrant中设置VM存储大小时出错,vagrant,vagrantfile,vagrant-provision,Vagrant,Vagrantfile,Vagrant Provision,我正在跟踪这个链接 我试图在我的Vagrant上包含设置VM存储大小的代码。 但我得到的错误如下 ==> vagrant: Running provisioner: shell... vagrant: Running: C:/Users/skywork/AppData/Local/Temp/vagrant-shell20151111-11660-1l3hhe.sh ==> vagrant: ++ '[' grep -ic 64GB /sizeDisk ']' ==> v

我正在跟踪这个链接

我试图在我的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.
这是我的流浪汉文件代码:

# -*- 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
以下是我的虚拟机默认磁盘大小:

我需要在我的文件和add-oracle-disk.sh上添加什么样的值以及如何添加磁盘空间(例如10GB)


请提供帮助。

您遇到“值超出范围”错误,示例是针对64GB磁盘大小进行的,如果您选择15GBHi@FrédéricHenri,您需要进行调整,这是什么意思?对不起,我是新来的流浪汉。请提供一些示例代码。非常感谢。@aldrien.h,您需要编辑
bash\u文件/add oracle disk.sh
以适应15GB。这是一个64GB的文件,您尝试扩展到15GB。您好,@FrédéricHenri如果我要更新文件[bash_files/add oracle disk.sh],我如何知道要放置的正确磁盘空间量?请帮助我理解,您如何得出以下值,首先是在Vagrant file
'--size',60200
,其次,在add-oracle-disk.sh
grep-ic“64GB”/sizeDisk
sudo lvextend-L64GB/dev/VolGroup/lv_root
中。在我的例子中,我不确定正确地输入什么值,所以我得到了超出范围的错误。