首页主机资讯如何在Linux用VirtualBox

如何在Linux用VirtualBox

时间2025-10-20 09:50:03发布访客分类主机资讯浏览958
导读:Installing VirtualBox on Linux To use VirtualBox on Linux, you first need to install it. The easiest method is via your...

Installing VirtualBox on Linux
To use VirtualBox on Linux, you first need to install it. The easiest method is via your system’s package manager (recommended for most users):

  • Ubuntu/Debian: Run sudo apt update & & sudo apt install virtualbox to install the latest version from the official repositories.
  • Fedora/CentOS/RHEL: Use sudo dnf install virtualbox (Fedora) or enable the EPEL repository first (sudo dnf config-manager --set-enable ol8_developer_EPEL for Oracle Linux 8), then install with sudo dnf install virtualbox.
  • Arch Linux: Run sudo pacman -S virtualbox to install from the Arch repositories.

For advanced users, you can download the latest version directly from the VirtualBox website. After downloading the .deb (Debian/Ubuntu) or .rpm (Fedora/CentOS) package, install it using sudo dpkg -i virtualbox-*.deb (Debian) or sudo rpm -ivh VirtualBox-*.rpm (Fedora). If dependencies are missing, run sudo apt-get install -f (Debian) or sudo dnf install -y kernel-devel gcc make (Fedora) to resolve them.

Starting VirtualBox
Once installed, you can launch VirtualBox from your application menu (search for “VirtualBox”) or via the terminal with virtualbox. If you encounter permission issues, ensure your user is part of the vboxusers group by running sudo usermod -aG vboxusers $USER and logging out/in.

Creating a Virtual Machine (VM)

  1. Click the “New” button in VirtualBox to start the wizard.
  2. Enter a name for your VM (e.g., “Ubuntu 22.04”) and select the OS type (e.g., “Microsoft Windows” or “Linux”) and version (e.g., “Ubuntu (64-bit)”).
  3. Allocate RAM: Assign 2–4 GB (or more) of RAM, ensuring you leave enough for your host system (e.g., 8 GB total RAM → assign 4 GB to the VM).
  4. Create a virtual hard disk: Choose “Create a virtual hard disk now,” select VDI format (default), and set a dynamic or fixed size (at least 20 GB for Windows, 10 GB for Linux).
  5. Complete the wizard and click “Create” to finalize the VM.

Installing the Guest Operating System

  1. Select your newly created VM and click “Settings.”
  2. Go to the “Storage” tab, click the empty optical drive icon, and add your OS ISO file (e.g., Ubuntu ISO) from your computer.
  3. Start the VM by clicking “Start.” The VM will boot from the ISO, and you can follow the on-screen instructions to install the OS (e.g., select language, partition disk, create a user).
  4. After installation, remove the ISO from the VM’s storage settings (go to “Settings” > “Storage” and eject the ISO) to boot into the installed OS.

Configuring VM Settings
After creating the VM, you can customize its behavior:

  • Network: Set the network adapter to “NAT” (default, shares host’s internet) or “Bridged Adapter” (VM gets its own IP on the local network).
  • Shared Folders: Go to “Settings” > “Shared Folders,” add a host folder (e.g., /home/user/Documents), and set a mount point in the VM (e.g., /mnt/shared). Install Guest Additions in the VM to enable this feature.
  • USB Devices: Attach USB drives to the VM by clicking the “Devices” menu in the VM window and selecting the USB device. Ensure your user is in the vboxusers group.

Using VirtualBox Features

  • Snapshots: Take a snapshot of the VM (click “Snapshots” > “Take”) to save its current state. Revert to this state anytime using “Restore.”
  • Cloning: Clone a VM (right-click VM > “Clone”) to create an identical copy for testing or backups.
  • Command-Line Management: Use VBoxManage commands to automate tasks (e.g., VBoxManage startvm "VM Name" --type gui to start a VM, VBoxManage list vms to list all VMs).

Troubleshooting Common Issues

  • Missing Dependencies: If you see errors like “missing libqt5core,” install the required packages (e.g., sudo apt install build-essential dkms libqt5opengl5 libsdl1.2debian for Debian/Ubuntu).
  • Kernel Module Loading Failures: Run sudo /sbin/vboxconfig to rebuild and load kernel modules.
  • USB Access Denied: Ensure your user is in the vboxusers group and logout/login.
  • Black Screen on Boot: Enable 3D acceleration in the VM’s “Settings” > “Display” tab (check “Enable 3D Acceleration”).

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: 如何在Linux用VirtualBox
本文地址: https://pptw.com/jishu/729795.html
VirtualBox快照怎么使用 ubuntu readdir如何实现文件传输

游客 回复需填写必要信息