You are here: Home Tech Add VirtualBox Guest Additions to Centos, RHEL

Add VirtualBox Guest Additions to Centos, RHEL

by Chris Shenton last modified Sep 09, 2010 01:27 PM
To add the additions it needs the ability to compile kernel modules. On RHEL, if you don't have RHN license, you can install from a repo on the DVD. Once the Guest Additions are in, you get access to the Virtual Shared directory which is very useful to exchange files without network acces.

Got RHEL? Got no RHN?

If you have a RHEL box but no access to the RedHat Network for yum updates, you should be able to get them from the DVD ISO that you installed from.  Add a new dvd.repoe to /etc/yum.repos.d/. Per RedHat the mediaid= value comes from the .discinfo file located in the root of the DVD. The baseurl path needs 3 slashes, and spaces in the real path replaced by their URL-safe counterpart "%20".

[dvd]
mediaid=1269263646.691048
name=DVD for RHEL5
baseurl=file:///media/RHEL_5.5%20x86_64%20DVD/Server
enabled=1
gpgcheck=0

Mount the RHEL ISO DVD in VirtualBox with the CD graphic icon on the bottom and it should show up in a GUI UI.  If you're using a text UI, you may have to mount it yourself, perhaps something like

mount -t iso9660 /dev/dvd /mnt

If you do this you'll have to change the path above to match '/mnt/Server' instead of the auto-generated path above.

Install kernel dev tools

The OS needs to be able to compile kernel modules for the Vbox guest additions, so it needs a compiler and kernel development libraries. Install it from the yum repo defined above:

yum install kernel-devel gcc

Now mount the image of the VirtualBox Guest additions, using the VBox icon, and mount it on the OS using its built-in automatic thing or manually with the "mount" command. Once mounted, do something like:

sh /media/VBOXADDITIONS_3.2.0_61806/VboxLinuxAdditions-amd64.run

And if everything works out you should now have the additions. 

Virtual Shared Disk

One of the reasons to go through the above is to access a native directory as a virtual shared disk.
You first provide the VM with this in the Vbox admin GUI settings: select a directory like ~/Projects/VirtualShared and provide it to the VM.
Create a mount point to mount it on; I use /VirtualShared.
Then you can edit /etc/fstab to know about it:
VirtualShared /VirtualShared vboxsf rw 0 0
 
Then mount it:
# mount /VirtualShared
 

If you don't want to create the fstab entry, you could do it manually:

# mount -t vboxsf VirtualShared /VirtualShared

 

Share this: