MAC下用VirtualBox跑ubuntu的一点经验

本文分享了在MAC环境下使用VirtualBox安装Ubuntu的步骤,包括从虚拟光驱启动的问题、将Ubuntu安装到虚拟硬盘、安装Guest Additions以提升体验,并详细描述了加载ISO文件和设置共享文件夹的过程。

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

软件版本:

MAC OSX:10.8.4,VirtualBox:4.2.16,ubuntu:ubuntu-12.04.2-desktop-amd64。

安装ubuntu

安装有两种方式:
  1. 跳过安装,直接从虚拟光驱启动。这有两个问题,一是会占用虚拟光驱,二是重启ubuntu后,以前的配置都丢失了。
  2. 安装ubuntu到虚拟硬盘上。

安装Guest Additions

如果要用VirtualBox自带的共享文件夹功能,必须先安装Guest Additions。安装方法:置顶的菜单条->devices->Install Guest Additions。
点击安装后,VirtualBox会把虚拟光驱中的已有的iso文件弹出,加载VBoxGuestAdditions.iso,然后运行。
如果直接从虚拟光驱启动,会出现已有iso不能弹出。在google上搜了半天,没有找到适合的解决方案。我后来自己想出一个好办法。
  1. 把/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso复制到home目录下,这一步是因为在下一步选择iso文件时,我不知道怎么进入/Applications/VirtualBox.app/Contents/MacOS目录。
  2. 在存储树里面增加一个光驱,用它来加载VBoxGuestAdditions.iso,如图所示。把ubuntu的iso设置成第一IDE控制器主通道,VBoxGuestAdditions.iso设置成从通道。
  3. 在ubuntu中,进入cdrom,执行autorun.sh,输出如下:
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.2.16 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.2.16 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.

Building the main Guest Additions module ...done.
Building the shared folder support module ...done.
Building the OpenGL support module ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used

Installing the Window System drivers
Installing X.Org Server 1.13 modules ...done.
Setting up the Window System to use the Guest Additions ...done.
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services components ...done.
Press Return to close this window...

按回车关闭窗口后,安装完成。

设置共享文件夹

点击置顶的菜单条->devices->shared folders后,弹出shared folders窗口,在里面设置共享文件夹。这里有个权限问题,如果让VirtualBox自动mount这个共享文件夹,它会以root用户mount。普通用户访问不了这个目录。我试过用chmod把目录权限改成所有人都能访问,但是没有成功。
在网上找到一个手动挂共享目录的方法:
ubuntu@ubuntu:~$ umask && id
0002
uid=999(ubuntu) gid=999(ubuntu) groups=999(ubuntu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare)
ubuntu@ubuntu:~$ sudo mkdir -p /media/sf_codes
ubuntu@ubuntu:~$ cd /media
ubuntu@ubuntu:/media$ ls
cdrom  sf_codes
ubuntu@ubuntu:/media$ cd sf_codes/
ubuntu@ubuntu:/media/sf_codes$ ls
ubuntu@ubuntu:/media/sf_codes$ cd ..
ubuntu@ubuntu:/media$ sudo mount -t vboxsf -o umask=002,uid=999,gid=999 codes /media/sf_codes
codes是VirtualBox设置的共享文件夹的目录名,/media/sf_codes是ubuntu上挂接的目录名。

在/etc/fstab增加下面这行,可以自动挂接:
codes /media/sf_codes vboxsf umask=002,uid=999,gid=999


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值