打造自己的Android源码学习环境之二:在虚拟机中安装Ubuntu(上)

打造自己的Android源码学习环境之二:在虚拟机中安装Ubuntu(上)

本篇主要针对Windows系统的读者,如果你用的已经是Linux系统,可以跳过此篇。

0. 安装虚拟机Virtual Box

VirtualBox的下载地址:https://www.virtualbox.org/wiki/Downloads

Windows版本的下载地址:http://download.virtualbox.org/virtualbox/5.1.14/VirtualBox-5.1.14-112924-Win.exe

目前最新的是5.1.14版本。

1. 下载Ubuntu镜像

可以从以下地址下载ubuntu系统镜像文件:
* (1) 网易的镜像:http://mirrors.163.com/ubuntu-releases/
* (2) Ubuntu官网:https://www.ubuntu.com/download/desktop
* (3) Ubuntu中文官网:http://cn.ubuntu.com/download/

最新的Ubuntu版本是16.10,代号Yakkety Yak,即2016年10月份的版本。
【可能会有问题】Ubuntu16.10下载地址:http://mirrors.163.com/ubuntu-releases/16.10/ubuntu-16.10-desktop-amd64.iso

【推荐安装Ubuntu16.04】下载地址:http://mirrors.163.com/ubuntu-releases/16.04/ubuntu-16.04-desktop-amd64.iso

【注:我用VirtualBox5.1.2安装Ubuntu16.10之后,安装VBoxGuestAdditions.iso的时候出现问题。升级到VirtualBox5.1.14之后,可以安装VBoxGuestAdditions.iso,但是Ubuntu系统总提示“发生错误”。
推荐使用VirtualBox5.1.14,安装Ubuntu15.04 或者 Ubuntu16.04】

关于Ubuntu版本的说明,可以参考:https://wiki.ubuntu.com/Releases
Ubuntu的版本采用x.y.z的格式,通常情况下,如果只有x.y,则表示x年y月发布的,例如14.04表示2014年4月发布。如果是x.y.z的形式,则表示是x.y的演进版本,例如14.04.1是2014年7月份发布的,14.04.5是2016年8月发布的。

Ubuntu版本与代号的对应关系(只是一部分):

Ubuntu版本Ubuntu代号
17.04Zesty Zapus
16.10Yakkety Yak
16.04Xenial Xerus
15.10Wily Werewolf
15.04Vivid Vervet
14.10Utopic Unicorn
14.04Trusty Tahr
13.10Saucy Salamander
13.04Raring Ringtail
12.10Quantal Quetzal
12.04Precise Pangolin
11.10Oneiric Ocelot

2. 在虚拟机中安装Ubuntu系统

Step 1: 新建虚拟电脑

打开“Oracle VM VirtualBox”,“新建”,显示界面如下:

“名称”:自定义的名字,与其他虚拟系统区分开即可,例如命名为ubuntu64_200GB。
“类型”:Linux
“版本”:选“Ubuntu (64-bit)”
“内存大小:当前系统内存的30%~40%作为虚拟系统的内存,例如16GB内存,留给虚拟系统6GB内存。

这里写图片描述

点击“创建”,进入下一步。

Step 2: 选择虚拟硬盘大小为200GB或者更大

“文件位置”:选择将虚拟系统放在哪个硬盘分区中,那个分区要满足虚拟系统对硬盘大小的要求。
“文件大小”:设置为200GB或者更大。
“存储在物理硬盘上”:选择“动态分配”

从实际情况来看,安装一些必备软件、下载Android7.1.1r13的代码、编译之后,虚拟硬盘大小接近150GB了,所以预留充足的空间是必要的。其实设置的大一些也无妨,因为是“动态分配”,虚拟系统不是一下子就占用很大的硬盘空间。

这里写图片描述

点击“创建”,在Virtual Box中就创建了一个新的虚拟电脑(图中选中的那个),如下:

这里写图片描述

Step 3:设置虚拟电脑

为了方便主机系统和虚拟系统之间互操作,将“共享粘贴板”和“拖放”都设置为“双向”:

这里写图片描述

如果之前内存大小设置的不合适,这时还可以设置内存大小:

这里写图片描述

设置CPU:
处理器数量要小于实际的CPU数量。
运行峰值:100%。如果考虑运行虚拟系统时,主机系统也要正常工作,可以调低此值。为了编译Android源码,我选择了100%。

这里写图片描述

选择刚下载的ubuntu镜像文件(iso文件):
在启动虚拟电脑时会安装ubuntu系统。
如果此时不选择镜像文件,在启动虚拟电脑时也会提示选择。

这里写图片描述

设置共享文件夹:
“共享文件夹路径”:存放共享文件的地方
“共享文件夹名称”:此名称最好为英文,因为此文件夹名称还要在之后进行mount
如果双向共享,不要勾选“只读分配”。
为了打开系统后就能使用共享文件夹,勾选“自动挂载”。

这里写图片描述

其他设置使用默认选项即可。

Step 4:启动刚才创建的虚拟电脑

选中刚创建的“ubuntu64_200GB”,点击”启动“。

如果之前没有选择ubuntu镜像(iso文件),此时会弹出选择界面(如下),否则将会进入安装ubuntu系统的界面。

这里写图片描述

安装ubuntu的过程,请看下一篇。

3. 可能出现的问题

这里写图片描述

如果没有显示Ubuntu(64-bit),只显示了Ubuntu (32-bit),可能的原因是你的电脑禁用了“虚拟化技术”。
对于HP笔记本来说,按F10键进入BIOS,“系统设置”页,启用“虚拟化技术”,如下:

这里写图片描述

如果是“禁用”,则在virtualbox创建虚拟系统界面只有32bit的选项。
而且在虚拟化技术被禁用的情况下,用virtualbox创建的guest系统总是反复重启,停在输入账户密码界面。

参考:https://zhidao.baidu.com/question/1732222046289666187.html

———————– 分 割 线 ———————–
本系列文章如下:

Android虚拟机Dalvik完整源码,宝贵资源,欢迎下载! This directory contains the Dalvik virtual machine and core class library, as well as related tools, libraries, and tests. A note about the licenses and header comments --------------------------------------------- Much of the code under this directory originally came from the Apache Harmony project, and as such contains the standard Apache header comment. Some of the code was written originally for the Android project, and as such contains the standard Android header comment. Some files contain code from both projects. In these cases, the header comment is a combination of the other two, and the portions of the code from Harmony are identified as indicated in the comment. Here is the combined header comment: /* * Copyright (C) The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ---------- * * Portions of the code surrounded by "// BEGIN Harmony code" and * "// END Harmony code" are copyrighted and licensed separately, as * follows: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Native SH call bridge --------------------- Native SH call bridge is written by Shin-ichiro KAWASAKI and Contributed to Android by Hitachi, Ltd. and Renesas Solutions Corp.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值