Activer le copier-coller bidirectionnel dans VirtualBox sur Ubuntu - guide complet
Par défaut, le copier-coller entre ta machine hôte Windows et ta VM Ubuntu ne fonctionne pas dans VirtualBox. Voici comment l'activer étape par étape.
Prérequis : VirtualBox installé, VM Ubuntu, utilisateur avec droits sudo.
Étape 1 : Configurer VirtualBox
- Éteins la VM
- Dans le gestionnaire VirtualBox, sélectionne ta VM
- Clique sur Configuration -> Général -> Avancé
- Dans Presse-papier partagé, sélectionne Bidirectionnel
- Clique sur OK
Étape 2 : Installer les Guest Additions via apt-get
Démarre la VM, ouvre un terminal et lance :
vboxuser@test1:~$ sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11
[sudo] password for vboxuser:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
virtualbox-guest-utils virtualbox-guest-x11
0 upgraded, 2 newly installed, 0 to remove and 349 not upgraded.
Need to get 1 675 kB of archives.
After this operation, 8 277 kB of additional disk space will be used.
Get:1 http://fr.archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 virtualbox-guest-utils amd64 6.1.50-dfsg-1~ubuntu1.22.04.3 [1 042 kB]
Get:2 http://fr.archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 virtualbox-guest-x11 amd64 6.1.50-dfsg-1~ubuntu1.22.04.3 [633 kB]
Redémarre ensuite :
sudo reboot
Étape 3 : Installer les Guest Additions via le CD (si étape 2 insuffisante)
Si le copier-coller ne fonctionne toujours pas, installe d'abord les outils de compilation :
vboxuser@test1:~$ sudo apt-get install build-essential dkms linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
linux-headers-6.8.0-106-generic is already the newest version (6.8.0-106.106~22.04.1).
linux-headers-6.8.0-106-generic set to manually installed.
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu cpp-12 dctrl-tools
dpkg-dev fakeroot g++ g++-11 gcc gcc-11 gcc-12 libalgorithm-diff-perl
...
Puis dans le menu VirtualBox : Périphériques -> Insérer l'image CD des Additions invité...
Lance ensuite l'installation :
vboxuser@test1:~$ sudo /media/vboxuser/VBox_GAs_7.1.10/VBoxLinuxAdditions.run
[sudo] password for vboxuser:
Verifying archive integrity... 100% MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.1.10 Guest Additions for Linux 100%
VirtualBox Guest Additions installer
This system appears to have a version of the VirtualBox Guest Additions
already installed. If it is part of the operating system and kept up-to-date,
there is most likely no need to replace it. If it is not up-to-date, you
should get a notification when you start the system. If you wish to replace
it with this version, please do not continue with this installation now, but
instead remove the current version first, following the instructions for the
operating system.
If your system simply has the remains of a version of the Additions you could
not remove you should probably continue now, and these will be removed during
installation.
Do you wish to continue? [yes or no]
Réponds yes :
yes
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-6.8.0-106-generic': No such file or directory
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-6.8.0-40-generic': No such file or directory
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 6.8.0-106-generic.
update-initramfs: Generating /boot/initrd.img-6.8.0-106-generic
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted or 'rcvboxadd reload' triggered
VirtualBox Guest Additions: reloading kernel modules and services
VirtualBox Guest Additions: cannot reload kernel modules: one or more modules
is still in use
VirtualBox Guest Additions: kernel modules and services were not reloaded
The log file /var/log/vboxadd-setup.log may contain further information.
Les messages
cannot touchetcannot reload kernel modulessont normaux - ils indiquent juste qu'un redémarrage est nécessaire.
Redémarre la VM :
sudo reboot
Vérification
Après le redémarrage, fais un clic droit dans le terminal. Paste doit être disponible et cliquable.
Les raccourcis clavier dans le terminal :
- Copier :
Ctrl+Shift+C - Coller :
Ctrl+Shift+V
Ce que j'ai appris
- Les Guest Additions installées via
apt-getpeuvent être en version différente de VirtualBox - installer via le CD garantit la bonne version - Les messages d'erreur
cannot touchpendant l'installation sont normaux et ne bloquent pas le processus Ctrl+Shift+Vest le raccourci pour coller dans un terminal Linux, et nonCtrl+Vcomme sur Windows