Installing virtualbox guest additions on Centos 7 minimal image

I've just spent some time setting up a bare Centos 7 image to support development stripping out as much as possible. While CoreOS is probably a better choice, we run redhat in production at this point and centos is a better fit for the time being. The problem I've found is that many of the instructions available via google were written against prerelease versions or espouse manually installing random rpms instead of just using yum. While I get this "works", I'm not a huge fan of this approach and would rather do everything with the package manager. After a LOT of scouring and trial and error, I finally found the "magic" combination.

The winner is courtesy of http://www.pc-freak.net/. I've taken these instructions and tweaked them slightly for my purposes.

The original poster did this on a more "full fledged" version of centos with a windows host and my instructions are for a minimal install using and OSX host (though I'm certain the OP's instructions will work too. First, mount the guest additions cd from the virtualbox gui (original link has a photo, but it's under devices->Insert Guest Additions CD Image. Then log into the console as root. Once you've done this, enter the following commands:

yum -y update kernel*
reboot -r now

After this step, you'll have to log in again. Then run the following:

yum install -y gcc kernel-devel kernel-headers dkms make bzip2 perl
export KERN_DIR=/usr/src/kernels/`uname -r`
mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
cd /media/cdrom
./VBoxLinuxAdditions.run

Additionally, there are some instructions that I believe will work, but installed more than I really wanted to or I didn't discover until after. Additionally (pun intended) a key point I missed originally is that the minimal iso is missing default packages (perl I think was the culprit) that you need to properly build the guest additions so instructions for the "full blown" image will fail for mysterious reasons (i.e. the "build" symlink is broken)

  • This seems like it would work too, but installs more than I really wanted to over my cell phone connection
  • I found this after I wrote my post and it is virtually (pun intended) identical to my instructions.

Examples I tried that did NOT work or were too convoluted:

  • centos.org forum had all sorts of crazy "wget" hackery suggested...While it may work, I like the epel approach better
  • this version on stackexchange CAN get you there, but you have to read all the comments to figure out what is really required for a minimal install

I realize my post is a bit of a duplicate, but as there's no good way to get rid of historical anachronisms on the internet, this is an attempt to boost the ranking of the better approaches

Comments

Anonymous said…
Thanks much. Had been digging around on this myself just yesterday. Exactly what I needed.
Anonymous said…
Again thanks! I spent a day trying to figure this out on my own before stumbling onto your instructions. Worked like a charm!
Ed said…
I'm using the Centos7 image from osboxes.org and this worked perfectly. Thanks.
Anonymous said…
Thank you very much.
I followed your instruction and installed it but still my screen is not full size
Any recommendation?
Anonymous said…
Alright, just to get this out there:
If you have just a CLI(Command Line Interface), WITHOUT a GUI, installing VBOX Guest Additions will NOT make it so you have a fullscreen resolution.
There is no way around it other than ssh-ing into it with PuTTY or something alike. Only then you will be able to emulate a fullscreen.

IF you still want to just install VBOX Guest Additions anyway, you can do so by: ./VBoxLinuxAdditions.run --nox11, EVEN THOUGH THIS WILL NOT SOLVE YOUR PROBLEM.

Go the ssh route with a program like PuTTY and forward a port like 3021 on host port and port 22 on guest port.
Anonymous said…
Thanks. This was dead on and a great post!!
Unknown said…
thanks for this! only comment is my KERN_DIR required a / at the end else it told me it wasn't pointing to a directory in the log when it failed to install.
Anonymous said…
Works like a charms... and a great time saver

Popular posts from this blog

Push versus pull deployment models

the myth of asynchronous JDBC

MACH TEN Addendum: for companies wanting to use MACH platforms