CentOS / sig-cloud-instance-build

CentOS Cloud Instance SIG: Metadata to build & release instances
362 stars 168 forks source link

VirtualBox Guest Additions in Vagrant image #27

Open makeamark1 opened 8 years ago

makeamark1 commented 8 years ago

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 commented 8 years ago

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

dhampik commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 https://github.com/dotless-de/vagrant-vbguest/issues/167

Of cause the official CentOS box would be much better.

makeamark1 commented 8 years ago

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

mmckinst commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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

nzhuk98 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

Unfortunately I get into another troubles which are described here: https://github.com/dotless-de/vagrant-vbguest/issues/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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

dhampik commented 8 years ago

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 commented 8 years ago

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

tallandtree commented 8 years ago

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 commented 8 years ago

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

kbsingh commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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

kbsingh commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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:

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

darkn3rd commented 8 years ago

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

jonvel commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

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

ghost commented 7 years ago

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:inconnect' 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:ineach' 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:intcp' 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:inacquire_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:inblock 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:inwith_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:inexecute' 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:incli' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.7/bin/vagrant:138:in `

'

ghost commented 7 years ago

please help me to solve this problem

xmj commented 7 years ago

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

kbsingh commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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.