Error setting VM Storage size in Vagrant
Asked Answered
I

0

2

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.

Impression answered 11/11, 2015 at 1:25 Comment(7)
you're getting `Value out of range' error, the example was done for 64GB disk size, you'd need to adapt if you make for 15GBPycno
Hi @FrédéricHenri , what do you mean? Sorry, I'm new to Vagrant. Please provide some sample code. Thank you very much.Impression
@aldrien.h, you need edit your bash_files/add-oracle-disk.sh for adapt to 15GB. The add-oracle-disk.sh was do with 64GB and you tried extend to 15GB.Myrnamyrobalan
Good day, @FrédéricHenri If I'm going to update the file [bash_files/add-oracle-disk.sh], how will I know the correct amount of disk space to put?Impression
Please help me to understand, How would you come up with the following value, first in Vagrant File '--size', 60200 , secondly in add-oracle-disk.sh grep -ic "64GB" /sizeDisk & sudo lvextend -L64GB /dev/VolGroup/lv_root. In my case, I'm not sure what value to put correctly, so I got out of range error.Impression
This is up to you to decide what space you need/want for the additional disk - you create the disk from vagrant file with createhd blabla --size 15360 so in your case roughly 15 GB, then you need to say to the script that you did allocate a disk of 15GB (not 64)Pycno
Good day @FrédéricHenri I tried to put 15GB to bash_files/add-oracle-disk.sh and also tried lower size like 10GB, but I got the same error above. :(Impression

© 2022 - 2024 — McMap. All rights reserved.