How do I copy/paste into a minimal installation of CentOS on VirtualBox?

65,896

For that to work, you have to install the Guest Additions. That will give you a shared clipboard.

After starting your VM, you can install the Guest Additions from the menu. Click on Devices and then select Insert Guest additions CD image.

Another way is, when your VM is off, you can attach an ISO image to it from the VirtualBox GUI. It is under the Storage tab.

When you install VirtualBox, it should contain the Guest Additions ISO image as well. If you can't find it, you can download it from here. Make sure it matches the exact version of Virtualbox.

The reason you need to install the Guest Additions to get copy and paste working is that your VM is a separate machine running in its own environment that is unaware of the host machine. You have to install drivers on the guest machine so it can communicate with the Virtualbox instance running on the host.

You can use your mouse without Guest Additions, but then it is either captured by the guest or owned by the host. You transfer control to the Guest by clicking in the Guest window. You have to "release" the mouse from the guest using a key combination (Right-Alt by default) to use it on the host again. See imgur.com/a/Ci5HM

If you have the Guest Additions installed, you mouse moves seamlessly between guest and host.

Note that if you don't have a GUI on your VM, but only a console, then you won't get a mouse pointer. A console system has no mouse. The Bash shell has no clipboard i.e. you can't copy/paste from/to a console-only system.

The easiest way to get around that is to use ssh to your VM from your host. You can then use copy and paste in the ssh terminal.

Share:
65,896

Related videos on Youtube

Zack
Author by

Zack

Updated on September 18, 2022

Comments

  • Zack
    Zack over 1 year

    I am trying to copy&paste from my local Windows machine into my CentOS guest machine, running on VirtualBox. The CentOS installation is minimal (only the console).

    I followed this guide, and enabled both shared clipboard and drag and drop, and rebooted. Now, when I get to the end of the article, it says

    That’s it!  When you log back into the guest machine, you should be able to copy text from the host machine to the guest easily. The Drag’n’Drop option lets you select a whole data file from the host to the guest or vice versa.

    I am not able to copy&paste. I tried right clicking on my guest OS, expected a copy/paste dialog to open up. No dice. I can't even see a mouse arrow on my guest OS.

    I tried Ctrl+V and Ctrl+Shift+V....but they didn’t work.

    Ctrl+Shift+V caused a ^V to appear on the command line, but nothing got pasted.

    I was able to paste into Notepad on my Windows host machine, so I know my copy buffer (clipboard) is at least getting filled with what I want to copy on the host side of things.

    The article just treats it as self-evident that there are no further instructions to be given. Did anyone run into this dilemma? What combination of keystrokes / mouse clicks do I need to copy/paste into my guest OS?

    EDIT I managed to track down this forum which was talking about Guest Additions/Centos and a .iso that I would need to replace another with. I downloaded the .iso, so.... now what?

    I tried going into

    > devices
        >> Insert Guest additions CD image
    

    Which looked promising. But then I got hit with this error.

    Unable to insert the virtual optical disk D:\virtualbox\VBoxGuestAdditions.iso into the machine Centos 7.
    
    Would you like to try to force insetion of this disk?
    
    Could not mount the media/drive 'D:\virtualbox/VBoxGuestAdditions.iso'
    (VERR_PDM_MEDIA_LOCKED).
    

    Clicking force unmount appears to do nothing.

    • Zack
      Zack over 7 years
      But I don't even have an arrow key on the guest, much less the option to right click and select something out of a dropdown...
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      If you don't have a (visible) mouse pointer on your guest, maybe you should focus on fixing that first.   But we can't teach you how to use VirtualBox — that's too broad a topic.  If you don't know how to insert a CD ISO file into your guest's virtual CD-ROM drive, you need to read the VirtualBox documentation.
    • Zack
      Zack over 7 years
      agh.... I just want to copy/paste.... ok....
    • Zack
      Zack over 7 years
      part of my trouble is I am coming from a very dev oriented background, so setting this stuff up is a major learning curve for me. A lot of the stuff in the documentation felt way over my head.
    • Zack
      Zack over 7 years
      it sort of looks like, to get the mouse features, I will need to install guest additions as NZD suggested below. So back to that issue.
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      I doubt that.  When I installed Kali Linux on a VirtualBox VM (with a Windows host), I was able to use my mouse to operate the Kali desktop/GUI — select and move windows, access menus, etc. — immediately; I didn't need to install guest additions.
    • NZD
      NZD over 7 years
      @scott Yes, you can use your mouse. But without Guest Additions it's either captured by the guest or owned by the host. You have to "release" the mouse from the guest using a key combination to use it on the host again. If you have the Guest Additions installed, you mouse moves seamlessly between guest and host.
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      @NZD: (1) My point is that the mouse should work in the guest without guest additions.  I didn’t say it would be pretty or easy.  But the OP seems to be saying that he has absolutely no mouse function in the guest, and I’m saying that might be a sign of deeper problems, and that installing the guest additions might not help. (2) I’m pretty sure that I got seamless mouse operation (without using the “release” key combination) without installing guest additions.
    • NZD
      NZD over 7 years
      @Scott. The "release key" is Right-Alt by default. You need it when you have a Gui-based guest and don't have the Guest Additions installed. You transfer control to the Guest by clicking in the Guest window and you get your mouse back when you press Right-Alt. See imgur.com/a/Ci5HM
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      @NZD: (1) Thanks for reading the manual to me. (2) If you look here, you’ll see that VirtualBox says that some versions of Linux work without additions. (3) I get this on my Kali VM without additions, so I guess Kali has VB mouse pointer integration built in. (4) You seem to be ignoring my point that the OP cannot get a right-click menu on his guest AT ALL. By your own statements, the guest should grab the mouse if the user clicks in the VM, even without additions.  Therefore, I believe that he has a bigger problem.
    • Zack
      Zack over 7 years
      I think you are right Scott. I am not able to get a mouse at all. It's probably going to be slow going for me while I read the manual. I'm wondering if this is a centos specific issue. I did a minimal install for centos.
    • NZD
      NZD over 7 years
      @Scott @Zack Does a minimal install for centos mean that you don't have a GUI on your VM, but only a console? If so, then it is correct that you don't see a mouse pointer. A console system has no mouse.
    • NZD
      NZD over 7 years
      @Scott AFAIK, bash has no clipboard i.e. you can't copy/paste from/to a console-only system.
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      @NZD: You may have just identified Zack's actual problem.
    • Zack
      Zack over 7 years
      I do indeed have only the console. So... go get something with a GUI and report back? The plot thickens...
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      @Zack: If your objective is to copy&paste small bits of text, like commands and command outputs, then you probably need to have a GUI. To repeat what I’ve been saying another way: if you currently can’t copy&paste within your guest (i.e., from one CentOS program to another), then guest additions won’t help you with that. If you want to move larger chunks of data between your host and guest, and you have network connectivity, then you should be able to do things like FTP, rsync, scp, or set up shared directories. … (Cont’d)
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      (Cont’d) …  Or maybe guest additions will give you other options.  (@NZD can probably help you with this.) But, if all you have on the guest is a console (i.e., one "window" with no borders (so not movable or resizable), not scrollable in bash (programs like less and vi will support scrolling), no option of creating new windows, and no way of selecting text on the screen) then you won’t be able to do clipboard-style copy&paste.
    • Zack
      Zack over 7 years
      Thanks Scott. All of the above is true. I'm going to attempt another more complete install when I get home, preferably something with a GUI. I really just want to copy/paste small bits of text for now.
    • NZD
      NZD over 7 years
      @Scott Use ssh to access the VM from the host. You can use copy and paste from your ssh terminal (at least on Linux hosts).
    • Scott - Слава Україні
      Scott - Слава Україні over 7 years
      @NZD: Of course, a minimal install might not include an SSH server, either.
    • Ivan Yurchenko
      Ivan Yurchenko almost 7 years
      Possible duplicate of Virtualbox clipboard sharing
    • Scott - Слава Україні
      Scott - Слава Україні almost 5 years
      Possible duplicate of Ubuntu Server VM: copy paste?
  • Zack
    Zack over 7 years
    I'll give this a try when I get home tonight. Off to work
  • Zack
    Zack over 7 years
    Jeez this looks crazy complicated just to get copy/paste working.
  • Zack
    Zack over 7 years
    For example "Insert the VBoxGuestAdditions.iso CD file into your Linux guest's virtual CD-ROM drive" Where do I get this .iso, what is the Linux guest's virtual CD ROM drive, and how do I insert the .iso?
  • Zack
    Zack over 7 years
    This article assumes a lot of pre-existing knowledge.
  • Zack
    Zack over 7 years
    See my edit please
  • NZD
    NZD over 7 years
    @Zack When your VM is off, you can attach an iso image to it from the VirtualBox GUI. It is under the Storage tab.
  • Yablargo
    Yablargo about 6 years
    The last line is the MVP here -- if you are doing console work on your VM, the easiest solution is just SSH into it, and have copy-paste working without issue.
  • sissy
    sissy over 5 years
    @Yablargo i love you! you saved me 2 days trying without success and gues additions installed to share my f****g clipboard between host and guest. And it was as easy as a ssh tunneling... I'm astonished I didnt' think about it before! thank you, thank you in all the languages of the world :)
  • Excalibur
    Excalibur about 4 years
    Agreed. Why the hell can't VirtualBox just do basic keyboard input to paste into a guest OS. The need to paste into a console to configure things is vastly larger of a use case than pasting out of a VM, which is likely more technically difficult.