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

11

3

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

Posted 2016-08-18T04:46:01.400

Reputation: 211

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... – Zack – 2016-08-19T03:24:24.630

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. – Scott – 2016-08-19T03:52:12.600

agh.... I just want to copy/paste.... ok.... – Zack – 2016-08-19T03:55:49.963

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 – 2016-08-19T03:57:26.900

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. – Zack – 2016-08-19T04:02:08.260

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. – Scott – 2016-08-20T00:28:51.123

@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. – NZD – 2016-08-21T02:22:26.683

@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. – Scott – 2016-08-21T07:55:29.290

@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 http://imgur.com/a/Ci5HM

– NZD – 2016-08-21T20:16:22.547

@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.

– Scott – 2016-08-21T21:52:33.807

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. – Zack – 2016-08-22T04:03:41.950

@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 – 2016-08-22T05:23:38.063

1@Scott AFAIK, bash has no clipboard i.e. you can't copy/paste from/to a console-only system. – NZD – 2016-08-22T05:35:29.803

1@NZD: You may have just identified Zack's actual problem. – Scott – 2016-08-22T05:46:26.960

1I do indeed have only the console.

So... go get something with a GUI and report back? The plot thickens... – Zack – 2016-08-22T17:40:14.707

1@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 – 2016-08-22T19:16:23.173

1(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. – Scott – 2016-08-22T19:16:34.870

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. – Zack – 2016-08-22T19:38:30.323

@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). – NZD – 2016-08-22T22:12:40.663

@NZD: Of course, a minimal install might not include an SSH server, either. – Scott – 2016-08-22T23:26:57.720

4

Possible duplicate of Virtualbox clipboard sharing

– Ivan Yurchenko – 2017-07-24T11:58:24.480

Possible duplicate of Ubuntu Server VM: copy paste?

– Scott – 2019-05-08T21:34:57.603

Answers

7

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.

NZD

Posted 2016-08-18T04:46:01.400

Reputation: 2 142

I'll give this a try when I get home tonight. Off to work – Zack – 2016-08-18T12:31:48.347

6Jeez this looks crazy complicated just to get copy/paste working. – Zack – 2016-08-19T03:30:48.413

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 – 2016-08-19T03:34:04.570

This article assumes a lot of pre-existing knowledge. – Zack – 2016-08-19T03:35:05.477

See my edit please – Zack – 2016-08-19T03:49:05.023

@Zack When your VM is off, you can attach an iso image to it from the VirtualBox GUI. It is under the Storage tab. – NZD – 2016-08-20T00:19:02.980

4The 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. – Yablargo – 2018-03-29T17:39:19.263

@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 :) – sissy – 2018-09-27T15:02:32.907