Using VirtualBox to run Ubuntu and any other operating system

本文介绍如何使用VirtualBox轻松地在现有操作系统上安装和运行Ubuntu等其他操作系统,避免对主机系统造成任何影响。通过详细步骤指导用户从安装VirtualBox到设置虚拟机的全过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Using VirtualBox to run Ubuntu and any other operating system

The easy way to run operating systems without messing up your system

User space | Easy

By Andrew Min

Online on: 2007-07-02

GNU/Linux can be scary to a new user. After all, what if you mess up? What if you end up corrupting your hard drive so badly that you need to format it to get rid of GNU/Linux? The solution is to use virtualization technology. A virtual machine creates a virtual hard drive as well as a virtual computer, so you can install and run it from within another operating system. If you want to get rid of the virtualized (also known as the guest) operating system, just delete the virtual hard disk from the real (host) computer’s hard drive.

Introduction

First, choose which virtualization tool to use. Right now, there are four big ones: Parallels, VMWare, QEMU, and VirtualBox. Parallels is commercial at US$49.99 for Windows and GNU/Linux. For me, that is way too expensive. That leaves us with VMWare, QEMU, and VirtualBox. VMWare has two freeware versions. One (called a player) runs pre-built operating systems (known as appliances). The other one (called a server) will make machines, but isn't as fast as the professional version. The problem with QEMU is that it is completely command-line (there are GUIs made for it, but they never worked for me). Therefore, it is extremely complicated to create a new virtual machine with it. Besides, it just can’t do some basic things that the others can (like pause a virtual machine, for example). That leaves us with VirtualBox.

VirtualBox is free software. It is cross-platform (runs on Windows and GNU/Linux, with an Intel Mac version in beta). It runs Windows, OS/2, GNU/Linux, BSD, Netware, Solaris, and L4 guests. And on certain guests, you can install VirtualBox Guest Additions, which lets you share files and more between the guest and the host. The next version, coming soon, will include support for running the pre-built VMWare appliances [1]. It simply works.

Getting VirtualBox

Getting VirtualBox varies from platform to platform. There are binaries on the download site for Windows, Ubuntu 6.06-7.04, Debian 3.1-4.0, openSuSE 10.2, Mandriva 2007.1, Red Hat Enterprise 4, and the Univention Corporate Server 1.3-2. The SimplyMEPIS site has a guide to installing VirtualBox here. If you run Ubuntu or MEPIS, you can install Automatix, which will install VirtualBox for you. Lastly, there is also a generic installer for GNU/Linux on the download page. Unfortunately, there are two versions of VirtualBox: one is freeware and one is free software. These binaries are for the freeware version, rather than the free software version. For some reason, Innotek (the company behind VirtualBox) hasn’t released open-source edition binaries. I’m not really sure why hackers haven’t released any binaries using the source code (the exception is one by a Macintosh programmer, who created an unofficial free software OS X 10.4 binary here). However, I am sure binary versions of this fantastic piece of software will eventually appear for many different distributions. To compile, visit the Build_instructions page at the VirtualBox wiki. GNU/Linux and Windows are supported, with Macintosh OS X (Intel-only) and OS/2 in testing.

Setting up your first virtual machine

Now that VirtualBox is installed, create your first virtual machine. Your first guest will be the well-known Ubuntu. Download the 7.04 Desktop edition CD image here. When it finishes downloading, open VirtualBox (on GNU/Linux, LD_LIBRARY_PATH=. ./VirtualBox, on Windows, run VBoxSDL.exe in the folder you compiled it in).

Select the “New” button (or hit Ctrl + N). A “New Machine Wizard” window should pop up (figure 1).

Figure 1: New Machine Wizard
Figure 1: New Machine Wizard

Click “Next”. Then, type a name for the virtual machine (I typed Ubuntu). Choose Linux 2.6 (the standard for most modern Linux distros) for the OS type, then hit “Next”. You will be asked how much memory to give. Choose 256MB. For most GNU/Linux distros, you’ll need at least 256MB of RAM to be comfortable (you’ll also need to make sure you have at least 512MB of total physical RAM and have all possible programs closed). Next, you will be confronted with an option to create a hard disk (figure 2).

Figure 2: New Virtual Disk Wizard
Figure 2: New Virtual Disk Wizard

Click “New”, and yet another window opens. Click “Next”. Now, you have an option to create a dynamically expanding image (hard drive) or fixed-size. Fixed size stays a certain size, while a dynamically expanding one gets bigger or smaller depending on what’s on it. For now, choose dynamically expanding. The next dialog asks you how big you want the hard drive to pretend to be (actual size will vary as mentioned before). Choose 5GB. Next, make sure all details are correct, then click “Finish” to exit the virtual disk wizard. Hit “Next”, confirm everything is correct, then “Finish” to exit the new machine wizard.

Now, click “Ubuntu” once, then click “Settings” (figure 3).

Figure 3: Adding a CD/DVD-Rom
Figure 3: Adding a CD/DVD-Rom

Select “CD/DVD-ROM”. Then, check the “Mount CD/DVD Drive”, select “ISO Image File”, then click the folder icon. The Virtual Disk Manager will pop up. Click “Add”, browse to the place where you saved the Ubuntu file, then highlight it and click “Open”. Now, click “Select” to assign the Ubuntu CD to the Ubuntu virtual machine. You may also want to make sure the “Enable Audio” under the Audio section is checked, so your audio is working.

You are now ready. Click “Okay” and then double-click the “Ubuntu virtual machine”. A new window should launch (figure 4).

Figure 4: The Ubuntu installer
Figure 4: The Ubuntu installer

Select “Start or Install Ubuntu”, with the arrow keys, then hit “Enter”. Clicking inside of the window will capture the mouse so you can use it in the virtual machine. To release it hit the right control (Ctrl) key. Wait for Ubuntu to load the desktop. Then, double-click on the “Install” icon. Select a language, then a city, then a keyboard layout, and give some personal info. When you are asked to prepare disk space, choose to erase the whole disk, then hit “Next”. Verify everything is correct, then hit “Install”. Wait for Ubuntu to finish installing (this will take a very long time). Then, restart when it prompts you to. It will tell you to remove the CD. Click the “Devices” menu at the top of the window, and click “Unmount CD/DVD-ROM”. Then, hit “Enter”. Ubuntu will finish restarting. Now, you are done! You can delete the CD image by taking the following steps: first stop the virtual machine by shutting it down (click the power button in the top right corner in Ubuntu). Then click on the Virtual Disk Manager (“File→Virtual Disk Manager” in the main VirtualBox window), then the CD/DVD Images tab, then click “Release”, then “Remove”. Then, delete the actual CD image.

More advanced usage

Now that Ubuntu is up and running, do some more advanced things with it. You can integrate the mouse (in other words, you won’t have to keep hitting the right Ctrl key to release it) by installing Guest Additions. Guest Additions will also improve your video support and synchronize your time with the virtual machine’s time. Here’s how to install it: open the Ubuntu virtual machine, click “Devices” at the top of the window, and then “Install Guest Additions”. Then go to “Accessories→Terminal”, type cd /media/cdrom0. Then type sudo sh ./VBoxLinuxAdditions.run and hit “Enter”. Follow the on screen instructions. Then, restart (hit the power icon in the top right corner). Now, the cursor isn’t trapped inside the virtual machine!

Another powerful tool that VirtualBox offers is the pause feature. If you close the virtual machine, it will pop up a message asking whether to power off or save machine state. Powering off is the equivalent of unplugging the power cord to the virtual machine. Saving the virtual machine state basically pauses it. It is sort of like hibernating. When you open up a saved machine, it will automatically pick up from where it left off. This is particularly useful when you are installing a new operating system, and want to turn it off without messing up the install.

Where to go from here

Ubuntu isn’t the only GNU/Linux distribution (or operating system) that VirtualBox can run. It can run Windows, SuSE, Linspire, and much more (see the Guest OSes page at the VirtualBox wiki for more). It’s a great way to test out GNU/Linux distros before you install them for real. It’s great for security: getting viruses in the virtual machine doesn’t affect the host machine. And GNU/Linux users can run it and Windows at the same time without paying a cent. All in all, VirtualBox is a powerful program that is worth the download.

References

[1] Open source at CeBIT 2007

Tags: virtualbox, virtualization  
### Ubuntu 系统中 'Not Found Operating System' 的错误解决方案 当在安装或启动 Ubuntu 过程中遇到 `Operating System Not Found` 错误时,通常是因为引导加载程序未正确配置或者硬件设置不匹配所致。以下是针对该问题的具体分析和解决办法: #### 1. **检查 BIOS/UEFI 设置** BIOS 或 UEFI 是计算机固件的一部分,负责初始化硬件并加载操作系统。如果系统无法识别操作系统的存在,则可能是由于以下原因: - 启动顺序可能被更改,导致硬盘未作为首选启动项。 - 如果使用的是虚拟机环境,需确认是否启用了虚拟化支持。 调整方法如下: - 在开机时按下特定键(通常是 F2、F10、DEL 或 ESC)进入 BIOS/UEFI 配置界面。 - 将 HDD 或 SSD 设为优先启动设备[^2]。 - 对于 GPT 分区表的磁盘,请确保启用 UEFI 模式而非 Legacy Mode。 #### 2. **验证 ISO 文件完整性** 下载的 Ubuntu 安装镜像可能存在损坏的情况,这会阻止正常引导过程的发生。因此建议重新校验所使用的 ISO 文件哈希值以排除此可能性。 执行命令来对比官方发布的 SHA256SUM 值与本地副本的一致性: ```bash sha256sum ubuntu-xx.x-server/desktop-amd64.iso ``` #### 3. **修正 GRUB 引导记录** GRUB (Grand Unified Bootloader) 负责定位根分区上的核心映射文件 vmlinuz 和 initrd.img 并传递控制权给它们完成后续工作流。然而有时因意外断电等原因造成其丢失从而引发此类现象。 修复步骤包括但不限于以下几个方面: - 使用 Live CD/USB 启动至救援模式; - 执行 chroot 到现有安装目录下重建 grub.cfg 文件; ```bash sudo mount /dev/sdaX /mnt # 替换 X 表示实际挂载点编号 sudo grub-install --boot-directory=/mnt/boot /dev/sda sudo update-grub ``` #### 4. **虚拟环境中特殊注意事项** 如果是基于 VMware Workstation/VirtualBox 创建的虚拟实例表现出同样的症状,则应着重关注存储控制器属性设定部分。具体而言, - 如前述提到过那样切换到 SATA 接口类型的光驱模拟器,并指定确切位置指向所需 .iso 映象资源[^2];另外也要记得分配足够的 RAM 给 guest OS 实例以便顺利运行图形界面版本发行版。 通过以上措施应该能够有效缓解乃至彻底消除 “No operating systems were detected.” 提示信息带来的困扰。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值