<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/ DTD/wml_1.1.xml">

<wml>
<head>
<meta http-equiv="cache-control" content="max-age=180,private" />
</head>
<card title="基于Ubuntu Jeos打造自己的精简版Linux服务器">
<p>
作者:<a href="index.php?action=showuser&amp;userid=1&amp;hash=">admin</a><br />时间:2010-10-10 14:53<br />分类:<a href="index.php?action=list&amp;cid=3&amp;hash=">电脑技术</a><br />内容:
基于Ubuntu Jeos打造自己的精简版Linux服务器


1. 下载 Ubuntu Server 


官网的地址是：http://www.ubuntu.com/getubuntu/download-server


在这里下载的是标准的服务器版Ubuntu。为什么呢？因为 Ubuntu Jeos 现在已经并入了 Ubuntu Server 的ISO中了，这里有提到：


Now part of the standard server ISO image


2. 下载并安装VMware Workstation


当前最新版本是 7.0.1 build-227600


3. 安装 Ubuntu Jeos虚拟机


一般选择默认，直接一路next即可，需要注意的地方本文会给出说明。











这里一定要选择 &ldquo;I will install the operating system later&rdquo;，因为如果选择前面两个，就会启用 &ldquo;Easy Install&rdquo;功能，即VMWare会很智能的识别这是Ubuntu，自动给你安装，你待会儿就没机会选择选项了。


















































注意：这里最为关键，按F4，选择 &ldquo;Install a minimal virtual machine&rdquo; 












一连串的&ldquo;NO&rdquo;，一般会探测出你的键盘类型是&rdquo;us&rdquo;即美国键盘。







计算机名字，随便取








格式化硬盘














用户的显示名字，随便取





用户名和密码就不能随便取了，不能忘了，否则进不了系统你就杯具了。我一般就把用户名和密码设置为：

Hostname:ubuntu-10.04

Full name for the new user:developer

Username for your account:developer

Chose a password for the new user:developer123

Re-enter password to verify:admin

New password for the MySQL &ldquo;root&rdquo; user: root















选一个国内的源，待会儿下载一些包速度比较快，这里用的地址来自这里。














选择需要安装的服务器软件，我选择了4个，按空格选择。注意，不要选samba，后面会安装vmware-tools，比samba方便多了。


Ubuntu JDK 默认路径为 /usr/lib/jvm/java-1.6.0-openjdk。














大公告成，重启！


给刚安装好的机器创建一个快照，免得后面的操作不成功是可以退回。








4. 在真机上安装一个SSH客户端


推荐 SSH Secure Shell Client 3.2.9，下载，安装好后，登陆








启动SSH Secure File Transfer，待会儿传输文件要用到。





5.升级一下系统，然后清理一下，再建一个快照，命名为 &ldquo;updated&rdquo;。


备份源列表：


hadoop@soulmachine:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bk


将 /etc/apt/sources.list 下载到本地 d:/tmp/sources.list





用记事本或UltralEdit打开，清空其中内容，然后用如下内容替换，保存。这个APT源来自这里，速度比较快。



deb http://ubuntu.srt.cn/ubuntu/ karmic main restricted universe multiverse


deb http://ubuntu.srt.cn/ubuntu/ karmic-security main restricted universe multiverse


deb http://ubuntu.srt.cn/ubuntu/ karmic-updates main restricted universe multiverse


deb http://ubuntu.srt.cn/ubuntu/ karmic-proposed main restricted universe multiverse


deb http://ubuntu.srt.cn/ubuntu/ karmic-backports main restricted universe multiverse


deb-src http://ubuntu.srt.cn/ubuntu/ karmic main restricted universe multiverse


deb-src http://ubuntu.srt.cn/ubuntu/ karmic-security main restricted universe multiverse


deb-src http://ubuntu.srt.cn/ubuntu/ karmic-updates main restricted universe multiverse


deb-src http://ubuntu.srt.cn/ubuntu/ karmic-proposed main restricted universe multiverse


deb-src http://ubuntu.srt.cn/ubuntu/ karmic-backports main restricted universe multiverse


上传文件到 /home/hadoop/下，因为直接上传到 /etc/apt/不行，没有权限。





覆盖系统中的源列表：


hadoop@soulmachine:~$ sudo cp sources.list /etc/apt/sources.list


刷新列表：


hadoop@soulmachine:~$ sudo apt-get update


注意：一定要执行刷新


更新已安装的包，这一步要花一点时间。


hadoop@soulmachine:~$ sudo apt-get upgrade


清理无用的包：



hadoop@soulmachine:~$ sudo apt-get clean &amp;&amp; sudo apt-get autoclean


hadoop@soulmachine:~$ rm sources.list
// 删除用户目录下的这个文件，可选


新建一个快照，取名为&rdquo;upgraded&rdquo;。





6.在ubuntu中安装 vmware-tools


找到 C:\Program Files\VMware\VMware Workstation\linux.iso，解压，得到一个 VMWARETO.TGZ，把它上传到Ubuntu中。








解压，命令为 tar -zxvf VMWARETO.TGZ


hadoop@soulmachine:~$ tar -zxvf VMWARETO.TGZ 


解压好后，执行 vmware-tools-distrib/vmware-install.pl





一路回车，YES下去就行了



Installing VMware Tools.


In which directory do you want to install the binary files?


[/usr/bin]


What is the directory that contains the init directories (rc0.d/ to rc6.d/)?


[/etc]


What is the directory that contains the init scripts?


[/etc/init.d]


In which directory do you want to install the daemon files?


[/usr/sbin]


In which directory do you want to install the library files?


[/usr/lib/vmware-tools]


The path &ldquo;/usr/lib/vmware-tools&rdquo; does not exist currently. This program is


going to create it, including needed parent directories. Is this what you want?


[yes] yes


In which directory do you want to install the documentation files?


[/usr/share/doc/vmware-tools]


The path &ldquo;/usr/share/doc/vmware-tools&rdquo; does not exist currently. This program


is going to create it, including needed parent directories. Is this what you


want? [yes] yes


The installation of VMware Tools 8.1.4 build-227600 for Linux completed


successfully. You can decide to remove this software from your system at any


time by invoking the following command: &ldquo;/usr/bin/vmware-uninstall-tools.pl&rdquo;.


Before running VMware Tools for the first time, you need to configure it by


invoking the following command: &ldquo;/usr/bin/vmware-config-tools.pl&rdquo;. Do you want


this program to invoke the command for you now? [yes]


接下来这一处默认是NO，我们也输入NO



[EXPERIMENTAL] The VMware FileSystem Sync Driver (vmsync) is a new feature that


creates backups of virtual machines. Please refer to the VMware Knowledge Base


for more details on this capability. Do you wish to enable this feature?


[no] no


安装好了，删除安装包，然后关机，因为我们需要设置一个东西，下一步就会看到。



hadoop@soulmachine:~/vmware-tools-distrib$ cd ..


hadoop@soulmachine:~$ ls


vmware-tools-distrib VMWARETO.TGZ


hadoop@soulmachine:~$ rm -rf ./vmware-tools-distrib/


hadoop@soulmachine:~$ ls


VMWARETO.TGZ


hadoop@soulmachine:~$ rm ./VMWARETO.TGZ


新建一个快照，取名为 &ldquo;vmware-tools-installed&rdquo;，然后关机。


hadoop@soulmachine:~$ sudo shutdown -h now 


7.设置文件夹共享


点击 Edit virtual machine settings，激活文件夹共享，





添加本机上的一个文件夹，Name 为linux上显示的名字，





其他默认，点击&ldquo;Finish&rdquo;，然后点击&rdquo;Power on this virtual machine&rdquo;，开机，可以在linux里访问这个文件夹了，windows上的这个文件夹会被vmware-tools自动映射 (mount) 到linux下的 /mnt/hgfs/xpshare 。


hadoop@soulmachine:~$ ls /mnt/hgfs/


xpshare


8.将本虚拟机打包。


右击本虚拟机标签，选择 &ldquo;clone&rdquo;。





这一步默认，





选择 &ldquo;create full clone&rdquo;，





选择存放路径。





注意：没必要删除之前创建的快照再克隆，因为克隆时不会把快照考虑进去。


接下来可以把这个文件夹用WinRAR压缩，大小大约500M多，我的是 514M。


9.使用别人打包好的虚拟机


如何使用这个打包好后的虚拟机呢？很简单，解压，然后再VMWare Workstation里点击&rdquo;File-&gt;Open&rdquo;，浏览到此文件夹，打开.vmx后缀的文件即可。


当打开一个vmx文件时，会跳出一个对话框，一般选择&rdquo;I copied it&rdquo;。





10.VMWare克隆后Ubuntu的 &ldquo;No such device eth0&Prime; 错误 


其实克隆后的虚拟机，第一个碰到的问题，便是不能上网。用ifconfig命令发现机器没有获得IP，只有一个 127.0.0.1。Google了一下，找到了答案。


原因：


新克隆的虚拟机镜像的网卡mac地址已经变更。打开虚拟机的.vmx文件，ethernet0.generatedAddress项记录了该虚拟机的 mac地址。


查看所有适配器信息


ifconfig -a


发现除了原来的eth0外，Ubuntu已经将新网卡命名为eth1。


Ubuntu保存网卡mac地址和设备名的配置文件在


/etc/udev/rules.d/70-persistent-net.rules


网卡的网络配置保存在


/etc/network/interfaces


该配置文件中只有原来eth0的配置信息。


解决方案：移动/删除rules文件。（已验证）



sudo mv /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.old


重启后Ubuntu会创建新的rules文件，将新网卡辨认为eth0，沿用原eth0 的网络配置。
</p><p>
<a href="index.php?action=login&amp;hash=">立即登陆发表评论</a><br />
</p>
<p><a href="index.php?action=list&amp;hash=">返回日志列表</a><br /><a href="index.php?action=index&amp;hash=">返回主页</a></p>
</card>
</wml>
