How To Install Virtualbox Guest Additions On CentOS via Command Line only

  • Reading the Virtualbox user manual, I finally got [here], which explains how to install Virtualbox Guest Additions on a Linux guest via Command Line.

    But it's not clear enough for me (I just started learning some commands). Can someone put down the exact commands you would use to install Virtualbox Guest Additions via CLI? (which includes finding where virtualbox guest additions has been mounted etc.)

  • its_me

    its_me Correct answer

    9 years ago

    ... finally this worked for me, should also work for anybody else trying to install VirtualBox Guest Additions on a CentOS (x86_64) virtual server in command line mode.

    # yum update
    # yum install dkms gcc make kernel-devel bzip2 binutils patch libgomp glibc-headers glibc-devel kernel-headers
    # mkdir -p /media/cdrom
    # mount /dev/scd0 /media/cdrom
    # sh /media/cdrom/VBoxLinuxAdditions.run
    

    When the process is complete, reboot the system. That's all.

    I do not think there is a need for the reboot here. Just check the vbox* modules are installed under /lib and then run modprobe for each vbox module; make sure the vbox startup scripts at /etc/init.d/vbox* are all (re)started. To just check whether the VBoxAdditions are working, I would start with testing the copy-paste between the source and vmguest. Run VBoxClient-all command and see if it returns anything. If nothing is returned VBox is setup fine. Also, check chkconfig to make sure the vbox startup scripts are properly defined to start at required runlevels.

    You need to `yum install make` as well

    I try to do the line mount /dev/scd0 /media/cdrom and I get: mount point /media/cdrom does not exist. Is there something I am missing?

    Please also note that you must add your username to the groups: vboxsf, vboxusers (first create this one).

    @theJerm Check this one: http://www.jacklmoore.com/notes/development (under section: **VirtualBox Guest Additions**)

    @theJerm I hope you already figured this out, but for the record: create the mountpoint (just a directory) with `sudo mkdir /media/cdrom`.

    Need `yum install dkms` too. Was getting no output at all when running `./VBoxLinuxAdditions.run`.

    On a minimal install of CentOS 6.4 64b the install command was `sh /media/cdrom/VBoxLinuxAdditions.run`. I also had to install Perl (`yum install perl`) and create the mount-point (`sudo mkdir -p /media/cdrom`).

    It doesn't work for me, it asks for linux headers.

    In CentOS 7 the cdrom is not at `/dev/scd0` but instead at `/dev/sr0`

    In case people are wondering... before any of this is done, you have to use _Insert Guest Additions CD image_, (currently found in _Devices_ in the virtualbox's window menu), in order for `VBoxLinuxAdditions.run` to be actually available.

    In addition to this, I had to do `sudo yum install kernel-headers` and when executing the install, `KERN_DIR=/usr/src/kernels/2.6.32-504.16.2.el6.x86_64 sudo /media/cdrom/VBoxLinuxAdditions.run`. `EXPORT`ing the `KERN_DIR` did not work. But alas, I was able to install this. :/

    If you can't mount the CD for some reason (eg: you're working over `ssh`), you can download an `ISO` of the guest additions for any version from `http://download.virtualbox.org/virtualbox`

    If you need to keep your guest additions in sync when using `vagrant`, check out the vagrant-vbguest plugin.

    in addition to jxmallet comment, if you can't mount the CD, then you can download the the ISO with `wget` e.g. `wget https://download.virtualbox.org/virtualbox/5.2.18/VBoxGuestAdditions_5.2.18.iso` (but choose the right version number) and then mount the iso with `mount -t iso9660 -o loop VBoxGuestAdditions_5.2.18.iso /mnt/cdrom`

    make sure you reboot after the yum update command. And remove the older kernel-devel package.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM