Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VirtualBox Guest Additions in Vagrant image #27

Open
makeamark1 opened this issue Sep 29, 2015 · 46 comments
Open

VirtualBox Guest Additions in Vagrant image #27

makeamark1 opened this issue Sep 29, 2015 · 46 comments

Comments

@makeamark1
Copy link

It seems that the CentOS Cloud image for Vagrant (using the VirtualBox provider) does not include the VirtualBox Guest Additions:

$ vagrant init centos/7
$ vagrant up
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.

As mentioned in the log output above, the VirtualBox Guest Additions are useful for many purposes in day-to-day work with virtual machines. Would you please consider including them by default in the CentOS Cloud image for Vagrant (for the VirtualBox provider)?

@kbsingh
Copy link
Collaborator

kbsingh commented Oct 1, 2015

hi @Vsipuli if you were able to help package up these additions, we can get them included in.

@dhampik
Copy link

dhampik commented Oct 6, 2015

That is true, guest additions are needed a lot. Unfortunately I don't know how to package them up, coz I'm not very familiar with CentOS, but I need it for my current project... That is an unpleasant surprise that they are not present by default.

@dhampik
Copy link

dhampik commented Oct 6, 2015

And due to the lack of Guest Additions, that vagrant box uses rsync to share a folder with host system. And that is bad, because it is one-ways synchronization.

@kbsingh
Copy link
Collaborator

kbsingh commented Oct 6, 2015

you should be able to turn off the rsync feature in your Vagrantfile locally.

w.r.t the guest additions, the blocker is basically having them packaged up somewhere.

@dhampik
Copy link

dhampik commented Oct 6, 2015

That is not a problem to disable rsync, the problem is to enable default sync folder type which is 'VirtualBox', because it is not available when Virtualbox Guest Additions are not installed.

If it'll be helpful to anyone, for now I decided to use this image https://atlas.hashicorp.com/avinashkolluru/boxes/centos7-1508.01-bzip2 with vagrant-vbguest plugin to vagrant, according to that issue dotless-de/vagrant-vbguest#167

Of cause the official CentOS box would be much better.

@makeamark1
Copy link
Author

@kbsingh Good to hear that you are ready to accept contributions. If I find some time I might look into this.

mmckinst added a commit to mmckinst/sig-cloud-instance-build that referenced this issue Oct 7, 2015
@mmckinst
Copy link
Contributor

mmckinst commented Oct 7, 2015

pull request #28 will allow the vagrant-vbguest plugin to work until dotless releases a new version

I can make a pull request that includes the VirtualBox Guest Additions as part of the base image but is there any way for me to run that koji command myself or is that 'cbs' some internal centos build server? I've got a Fedora account if that matters.

@kbsingh
Copy link
Collaborator

kbsingh commented Oct 7, 2015

@mmckinst cheers, merged in the req for bzip2; Unfortunately, the images for 2015-Sept update were built last week, so this change wont be included in the images released today - however it will make it into the next build for CentOS-7, 2015-Oct, due on the 28th/Oct.

Ideally, we should get the additions packaged up ( from the gpl souces ) into rpms and have them built at cbs ( http://cbs.centos.org ), and then reference them in the kickstarts. We dont interface with the Fedora Koji, but run our own accounting setup.

@dhampik
Copy link

dhampik commented Oct 10, 2015

you should be able to turn off the rsync feature in your Vagrantfile locally.

It took me some time to understand how do that.
I was trying to disable it with the following:

config.vm.synced_folder '.', '/vagrant', disabled: true

But the thing is that this image does not use the standard path (which I saw in many other images).
So, to disable rsync you should do the following instead:

config.vm.synced_folder ".", "/home/vagrant/sync", disabled: true

Hopefully it will save time for others who wants to do that.

@kbsingh
Copy link
Collaborator

kbsingh commented Nov 23, 2015

thanks for the note, I've added it to the README.md file

@nzhuk98
Copy link

nzhuk98 commented Dec 9, 2015

Added a note on setting up VirtualBox shared folders with a standard /vagrant path based on this discussion to README.md in pull request #33.

@tomor
Copy link

tomor commented Dec 14, 2015

Am I right when I expect that vagrant box "centos/7" created by this build script should be available at https://atlas.hashicorp.com/centos/boxes/7 ?
I can see that currently it's 2 months old and when I use it (config.vm.box = "centos/7") the bzip2 is still not there and guest additions installation fails. (... bzip2: command not found)

As fallback I started to use https://atlas.hashicorp.com/avinashkolluru/boxes/centos7-1508.01-bzip2 , but the official one would be better.

Thanks for the info.

@dhampik
Copy link

dhampik commented Dec 14, 2015

We are using config.vm.box = "centos/7" with vagrant 1.7.3 and latest vitualbox and vagrant-vbguest plugin. It works for us (at least worked about a month ago when I re-created the box the last time)

@mmckinst
Copy link
Contributor

@tomor You might have an old version of the box downloaded. If the output of vagrant box outdated --global says its outdated, try using vagrant box update --box centos/7 to bring it up to date.

@tomor
Copy link

tomor commented Dec 14, 2015

The problem was in the old version/or not installed vbguest plugin.
After installing it via "vagrant plugin install vagrant-vbguest" it works without troubles.
Thank you guys for your quick responses.

@tomor
Copy link

tomor commented Dec 15, 2015

Unfortunately I get into another troubles which are described here: dotless-de/vagrant-vbguest#170 . It looks like it's a problem of vagrant-vbguest plugin, not centos box, but as it's connected with guest additions I'm posting it here as it might be helpful for others.

@jronallo
Copy link

I had problems with the centos/7 Vagrant box and guest additions. In order to get guest additions to install correctly I had to do the following:

vagrant up
vagrant ssh
sudo yum -y install kernel kernel-devel
exit
vagrant reload

At this point the guest additions install correctly and virtualbox file syncing works. I had previously installed the vbguest plugin which may have also factored in here.

@dhampik
Copy link

dhampik commented Dec 25, 2015

I have the same error as @jronallo.

cat /var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

and

vagrant box list
centos/7        (virtualbox, 1509.01)

which seems to be latest.

Worth mentioning that couple of months ago everything worked well. So, I believe a release of newer version of box is required.

@dhampik
Copy link

dhampik commented Dec 25, 2015

Basically I just can't load CentOS VM via vagrant after doing sudo yum -y install kernel kernel-devel
It just hangs :(

@dhampik
Copy link

dhampik commented Dec 28, 2015

For anyone having the same issues, the only working box is https://vagrantcloud.com/boxcutter/boxes/centos72
boxcutter boxes are community-driven templates and tools for creating cloud, virtual machines, containers and metal operating system environments.

it works with vagrant 1.8.1, virtualbox 5.0.12 and vagrant-vbguest 0.11.0 plugin

I spend about a couple of days to figure that out, sad that official images are not supported that well.

@mmckinst
Copy link
Contributor

@kbsingh Would you be open to just running the virtualbox guest additition install script in the kickstart?

@tallandtree
Copy link

it seems an issue with the exact kernel version of the CentOs/7 official box . If I 'manually' upgrade (yum upgrade) and reboot, then the kernel version matches with what is installed by "yum install -y kernel-devel": 3.10.0.327. After this, I can succesfully run the VBox additions. But before "yum upgrade":
rpm -qa kernel*:
kernel-3.10.0-229.14.1.el7.x86_64
kernel-devel-3.10.0-327.4.4.el7.x86_64
kernel-headers-3.10.0-327.4.4.el7.x86_64
kernel-tools-3.10.0-327.4.4.el7.x86_64
kernel-tools-libs-3.10.0-327.4.4.el7.x86_64
It seems not possible to install the exact same version of the kernel-headers/kernel-devel.
Too bad I cannot do it from one VagrantFile. Maybe I just take the boxcutter box.

@kbsingh
Copy link
Collaborator

kbsingh commented Jan 25, 2016

@tallandtree what happens if you run : yum install kernel-devel-uname -r

@kbsingh
Copy link
Collaborator

kbsingh commented Jan 25, 2016

I hope to have a new vagrant box's set online on the 2nd or 3rd of Feb ( early next week ), that should have all updates rolled in already.

@kbsingh
Copy link
Collaborator

kbsingh commented Jan 25, 2016

@mmckinst the build time instances dont have internet access, so they wont be able to grab external bits. Also, I have been trying to work the route to get closure on licensing and packaging for the extensions, and so far have not been able to get resolution there. That would be the best way to resolve this issue, if we are able to just bundle them in, packaged properly and tracking the kernel-abi in a way that every kernel or system update does not completely destroy the box.

@tallandtree
Copy link

config.vm.box = "centos/7"
config.vm.provision "shell", inline: <<-SHELL
sudo yum update
sudo yum install -y gcc
sudo yum install -y kernel-devel-$(uname -r)
sudo yum install -y bzip2
sudo yum install -y net-tools # a.o. ifconfig
sudo yum install -y bind-utils # a.o. nslookup
sudo mkdir -p /media/cdrom
sudo mount /dev/cdrom /media/cdrom
sudo sh /media/cdrom/VBoxLinuxAdditions.run
SHELL

Vagrant up says:

==> default: No package kernel-devel-3.10.0-229.14.1.el7.x86_64 available.
==> default: Error: Nothing to do

And the guest additions fails accordingly.

@mmckinst
Copy link
Contributor

@kbsingh the new one will have kernel-devel installed by default?

@kbsingh
Copy link
Collaborator

kbsingh commented Jan 25, 2016

@mmckinst I wasent planning on putting in kernel-devel, its going to have a significant impact on size of download. I want to still try and see if we can just ship a pre-setup vbox components.

@hamish
Copy link

hamish commented Feb 23, 2016

How about adding kernel-devel, adding the vbox components and then removing kernel-devel? It's not pretty, but it may get the extensions there without too much impact on the size of the download...

@rshmelev
Copy link

Hi everyone, so is there any solution to this issue? Is there any possibility to make usual dir sync work for centos/7 image? E.g. some bootstrap script or whatever.

@vinceskahan
Copy link

By my measure a fully patched up centos7 vagrant box takes about 42MB of disk to have working VB Guest Additions when you get it all done. Getting there is painful starting with a 1602.02 image, which has lots of released updates now a month+ later.

The 1602.02 image as of today is updated just enough to really mess up the guest additions process. You can't --disablerepo=updates --enablerepo=base because you're not starting with a unpatched image. Installing gcc updates kernel-headers beyond the rev level of the running kernel which to me is a rpm dependency bug. Only way out of it is to do the yum update of everything to absolutely current and take the reboot to re-baseline its brain before you try to build+install guest additions.

I followed the usual procedure for installing guest additions. After the 'yum update' reboot, I did a 'yum install -y gcc kernel-devel' which installed 35 rpms, and at that point the guest box additions (without X11) built ok from the command line. I then had to install yum-utils (which brought in two more rpms) to run "package-cleanup --oldkernels --keep=1" to clean up the old kernel, then I deleted all 38 rpms the guest additions building requires. I then did a 'yum erase' to clean up metadata. Whew.

Bottom line, you're talking 500MB in size increase to be able to rebuild the guest additions. The additions themselves are only 42MB in size if you update=>add=>build=>cleanup the box leaving just the guest additions there (on top of where you started).

@kbsingh
Copy link
Collaborator

kbsingh commented Apr 4, 2016

If at all possible, a spec file that builds the guest additions from the GPL source tarball would be the way to go. That would allow us to preinstall it into the machine, and also manage its own updates etc using rpms. If someone's got a few minutes, would appreciate a stab at that.

@vinceskahan
Copy link

Is there really a general solution ? I thought the version of guest additions had to match the version of VirtualBox you are running (I'm not positive there, but every other virtualization product has that linkage)

@tjanez
Copy link
Contributor

tjanez commented Apr 5, 2016

@kbsingh, regarding having a SPEC file for VirtualBox (guest additions), I would like to bring RPM Fusion's packaging effort to attention.

Their SPEC file is battle tested for the duration of several Fedora releases (git history), so I think it should be quite solid. Unfortunately, RPM Fusion won't build RPMs for CentOS/RHEL 7 until they sort of their infrastructure issues.

Could CentOS use their SPEC/SRPM and rebuild it?
Afterwards, we would just need to install VirtualBox-guest sub-package, which provides Guest Additions, and its dependencies into the Vagrant image.

One issue to consider is that VirtualBox-guest sub-package requires xorg-x11-server-Xorg and xorg-x11-xinit, which is probably unnecessary for a headless Vagrant box?

The second issue is what @vinceskahan mentioned, how well will a particular version of VirtualBox Guest Additions shipped with CentOS' Vagrant image work with different VirtualBox versions installed on the host?

@vinceskahan
Copy link

I'm increasingly convinced there's not a general solution here. Oracle's site here has all kinds of version-matters type wording on it and the actual downloads page here has links that aren't stable nor predictable to me. Doubt we're going to get there as-is.

FWIW, I have my buildup to a x11-enabled centos7 VM down to just a few steps, so I'm calling it good enough for me:

  • vagrant up grabs the latest centos/7 base box, runs an 'updates' provisioner script which takes the reboot since we (currently) have a kernel update in there

    vagrant up
    
  • the updates provisioner echos the instructions for the second step to do to stdout, current choices are to install just the guest box additions or install a Graphical Desktop plus additions. Unfortunately there is one manual step in there, which is mounting the iso image to the cd/dvd device via the virtualbox console window for the vm as it starts booting up.

     vagrant provision --provision-with additions          # console only
     vagrant provision --provision-with x11,additions      # xwindows only
    

I can make the Vagrantfile and provisioner scripts available if anybody cares....

@darkn3rd
Copy link

darkn3rd commented Aug 9, 2016

I am using geerlingguy/centos7, as he builds in guest editions. I cannot believe i wasted a day on centos/7. Angry panda.

@jonvel
Copy link

jonvel commented Sep 28, 2016

Anyone use the bento/centos7.x flavors? I think they were originally the chef maintained "official" (as far as chef maintains any kind of official centos image, at least) boxes on hashicorp. Those have a particular guest additions version (5.0.x) built in, but they seem to work "fine" on my virtualbox 4.3.x host version, though I do get a warning on "vagrant up" that they don't match. However, the only thing that I actually care about is the mapping of "." to "/vagrant". I don't high need performance on that connection, so that doesn't matter to me.

@mmckinst
Copy link
Contributor

@jonvel the bento boxes are my go to box for all OSs, they very high quality and have the bare minimum that I want to start from.

@datamike
Copy link

datamike commented Nov 9, 2016

@tomor - I'm working on something completely different, but your tip "vagrant plugin install vagrant-vbguest" was exactly what I needed. Thanks! Michael

@ghost
Copy link

ghost commented Aug 13, 2017

can any one help me?
when i run
#vagrant ssh
then it works fine
but when i run
#vagrant share --ssh
then it will give
vagrant share --ssh
Vagrant Share now defaults to using the ngrok driver.
The classic driver has been deprecated.

For more information about the ngrok driver, please
refer to the documentation:

https://www.vagrantup.com/docs/share/
==> default: Detecting network information for machine...
default: Local machine address: 127.0.0.1
default:
default: Note: With the local address (127.0.0.1), Vagrant Share can only
default: share any ports you have forwarded. Assign an IP or address to your
default: machine to expose all TCP ports. Consult the documentation
default: for your provider ('virtualbox') for more information.
default:
==> default: Generating new SSH key...
default: Please enter a password to encrypt the key:
default: Repeat the password to confirm:
default: Repeat the password to confirm:
default: Inserting generated SSH key into machine...
default: Local HTTP port: 4567
default: Local HTTPS port: disabled
default: SSH Port: 2222
default: Port: 2222
default: Port: 4567
==> default: Creating Vagrant Share session...
C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.3.0/socket.rb:61:in connect_internal': A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - user specified timeout (Errno::ETIMEDOUT) from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.3.0/socket.rb:139:in connect'
from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.3.0/socket.rb:636:in block in tcp' from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.3.0/socket.rb:231:in each'
from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.3.0/socket.rb:231:in foreach' from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.3.0/socket.rb:626:in tcp'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:304:in acquire_port' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:312:in acquire_port'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:2360:in block in start_share' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.7/lib/vagrant/plugin/v2/command.rb:235:in block in with_target_vms'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.7/lib/vagrant/plugin/v2/command.rb:229:in each' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.7/lib/vagrant/plugin/v2/command.rb:229:in with_target_vms'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:2273:in start_share' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:2967:in execute'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.7/lib/vagrant/cli.rb:42:in execute' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.7/lib/vagrant/environment.rb:308:in cli'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.7/bin/vagrant:138:in `

'

@ghost
Copy link

ghost commented Aug 13, 2017

please help me to solve this problem

@xmj
Copy link

xmj commented Sep 22, 2017

Still an issue.
How can we help getting this addressed?

@kbsingh
Copy link
Collaborator

kbsingh commented Sep 22, 2017

@xmj i am not sure how useful this issue is at this point - there are quite a few different pieces raised. if the baseline is that we should include the vbox additions, someone needs to step up and package it, work through the license and get the rpms in cbs.centos.org.

@xmj
Copy link

xmj commented Sep 22, 2017

Excellent, does the following sound about right?

  1. Include VBox guest additions dependencies in centos7.ks
  2. Package VBox Guest additions as RPM, not entirely unlike the way FreeBSD does (http://www.freshports.org/emulators/virtualbox-ose-additions) but different ;-)
  3. Get that RPM hosted on the community build service
  4. Include it in centos7.ks

@xmj
Copy link

xmj commented Sep 22, 2017

I hope licensing won't be a problem as the Opensource edition falls under GPLv2, and we'll not be using the parts that fall under the PUEL.

@kbsingh
Copy link
Collaborator

kbsingh commented Sep 22, 2017

I would request you to open new issue with literally just this scope @xmj : 'get vbox additions pre-installed' and setup exactly this list as a set of pre-conditions.

w.r.t licensing. gplv2 is perfect, as long as all the content we consume falls under it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests