Error setting VM Storage size in Vagrant

2019-07-14 07:39发布

I'm following this link https://github.com/acfreitas/oraclebox

I tried to include the code for setting up VM storage size on my Vagrant. But i'm getting error like below.

==> 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.

Here is my Vagrant file codes:

# -*- 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

Here is my VM default disk size:

enter image description here

How and what value I need to put on my VagrantFile and add-oracle-disk.sh to be able to add disk space (10GB for example).

Please help.

0条回答
登录 后发表回答