centos

CentOS VirtualBox如何安装Guest Additions

小樊
44
2025-09-19 23:14:42
栏目: 智能运维

Installing VirtualBox Guest Additions on CentOS: A Step-by-Step Guide

VirtualBox Guest Additions enhance your CentOS virtual machine (VM) with critical features like shared folders, clipboard sharing, automatic screen resolution adjustment, and smoother mouse/keyboard integration. Below is a structured guide to installing them, including prerequisites and troubleshooting tips.

1. Preparation: Update System and Install Dependencies

Before installing Guest Additions, ensure your CentOS system is up-to-date and has the necessary tools to compile kernel modules. Run these commands in the terminal:

# Update system packages (CentOS 7/8/9 compatible)
sudo yum update -y   # For CentOS 7
# sudo dnf update -y # For CentOS 8/9 (uncomment if using DNF)

# Install compilation tools and kernel headers (critical for Guest Additions)
sudo yum install -y epel-release gcc make perl kernel-devel kernel-headers dkms bzip2

Why?

2. Mount the Guest Additions ISO

VirtualBox provides a virtual CD-ROM with Guest Additions. To mount it:

  1. Start your CentOS VM in VirtualBox.
  2. Click the Devices menu at the top of the VM window.
  3. Select Insert Guest Additions CD Image….
  4. A notification will appear; click Run (or open the CD-ROM manually via the file manager).

The ISO will mount to /run/media/[your-username]/VBox_GAs_[version] (e.g., /run/media/asfor/VBox_GAs_7.2.2).

3. Run the Installation Script

Open a terminal and execute these commands to install Guest Additions:

# Navigate to the mounted CD-ROM directory
cd /run/media/[your-username]/VBox_GAs_[version]  # Replace with your actual path

# Give execute permission to the script (if needed) and run it
sudo chmod +x VBoxLinuxAdditions.run
sudo ./VBoxLinuxAdditions.run

Notes:

4. Reboot the VM

After installation completes, restart your VM to apply changes:

sudo reboot

Wait for the system to reboot fully before proceeding.

5. Verify Installation Success

Check if Guest Additions are active using these methods:

Troubleshooting Common Issues

By following these steps, you’ll unlock VirtualBox’s full potential for your CentOS VM, enabling seamless interaction between the host and guest systems.

0
看了该问题的人还看了