How do I get the clipboard to work in CentOS inside VirtualBox on Windows?

6,542

I don't think you'll be able to get clipboard sharing to work without the additions installed. Can you manually run the VBoxLinuxAdditions.run file and see if it will either install or give you a proper error?

Share:
6,542

Related videos on Youtube

Chloe
Author by

Chloe

Updated on September 18, 2022

Comments

  • Chloe
    Chloe over 1 year

    I have CentOS 7.3.1611 running with XFCE inside Oracle VirtualBox 5.1.16 on Windows 8.1. The other questions are for older versions or the guest/host are switched. I set Devices > Shared Clipboard > Bidirectional, but nothing I copy in Windows is pasteable in CentOS, and nothing I copy in CentOS is pasteable in Windows.

    I used Vagrant to create the box. 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.
        default:
        default: This is not an error message; everything may continue to work properly,
    

    I also manually added an optical drive and loaded VBoxGuestAdditions.iso from the VirtualBox folder, restarted, manually mount the CDROM, and manually ran the script, but:

    [vagrant@localhost ~]$ sudo mount /dev/sr0/ /mnt
    mount: /dev/sr0 is write-protected, mounting read-only
    [vagrant@localhost ~]$ cd /mnt
    [vagrant@localhost mnt]$ sudo ./autorun.sh
    Linux guest additions installer not found -- try to start them manually.
    [vagrant@localhost mnt]$ ls
    32Bit  AUTORUN.INF  cert  runasroot.sh            VBoxSolarisAdditions.pkg        VBoxWindowsAdditions.exe
    64Bit  autorun.sh   OS2   VBoxLinuxAdditions.run  VBoxWindowsAdditions-amd64.exe  VBoxWindowsAdditions-x86.exe
    

    So now I don't know how to get the clipboard to work.


    Here is the log from running VBoxLinuxAdditions.run.

    [vagrant@localhost mnt]$ sudo ./VBoxLinuxAdditions.run
    Verifying archive integrity... All good.
    Uncompressing VirtualBox 5.1.16 Guest Additions for Linux...........
    VirtualBox Guest Additions installer
    Removing installed version 5.1.16 of VirtualBox Guest Additions...
    Copying additional installer modules ...
    Installing additional modules ...
    vboxadd.sh: Building Guest Additions kernel modules.
    Failed to set up service vboxadd, please check the log file
    /var/log/VBoxGuestAdditions.log for details.
    [vagrant@localhost mnt]$ cat /var/log/VBoxGuestAdditions.log
    
    vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
    vboxadd.sh: failed: Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed..
    [vagrant@localhost mnt]$ 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.
    [vagrant@localhost mnt]$ gcc
    gcc: fatal error: no input files
    compilation terminated.
    [vagrant@localhost mnt]$
    
  • Chloe
    Chloe about 7 years
    OK I updated it.
  • Luke G.
    Luke G. about 7 years
    That helps, thanks. It looks like you'll need the kernel sources at least, as it looks like you tested gcc and it's there. I'm not sure what package that would be on CentOS, but according to this it seems that yum install kernel-devel might do the trick for you.
  • Chloe
    Chloe about 7 years
    OK installed. It still says I don't have KERN_DIR set, but I don't know what to set it to.
  • Luke G.
    Luke G. about 7 years
    I did a little digging here and it looks like there it could be installing the wrong version of the kernel-devel package for what you are running. You can ensure you are getting the correct version by running " yum remove kernel-devel " and then " yum install kernel-devel-`uname -r` "
  • Chloe
    Chloe about 7 years
    I got it working! export KERN_DIR=/usr/src/kernels/`uname -r` (after yum update and yum install kernel-devel and restart) and now mouse integration and clipboard works! I have to use the menu or keyboard to copy from guest to host, but otherwise works great with just mouse right-click!