朗志工作室(Langzhi Studio)

江浙沪一带找工作中,欢迎联系
方向:爬虫、搜索 技术:python,rails,node.js

  博客园 :: 首页 :: 联系 :: 订阅 订阅 :: 管理
  5662 Posts :: 2 Stories :: 515 Comments :: 7 Trackbacks

公告

2012年2月11日 #

www.cdnzz.com/plan

posted @ 2012-02-11 23:40 lexus 阅读(20) 评论(0) 编辑

http://www.sysprobs.com/

posted @ 2012-02-11 14:14 lexus 阅读(10) 评论(0) 编辑

Physical to Virtual Machine by VMware vCenter Converter

If you are trying to convert physical tovirtual machine and to be used in VMware workstation or Sun VirtualBox, then continue reading this article. VMware vCenter converter is being used to convert physical to virtual (P2V) to VMware ESX server. But you can use this converter to create VMDK and VMX files locally.

When you want to convert physical tovirtual machine and use locally in VMware workstation or Sun VirtualBox, this method will help you lot.

Physical to Virtual

Follow the steps to create VMX and VMDK files by converting physical to virtual (P2V) in VMware vCenter Converter.

1)  Download VMware vCenter Convert for Physical to Virtual (it’s completely free- registration required)

2)  Complete the installation.

3)  Open the converter, select ‘This local machine’. You can select remote computer also. You must have administrator privileges on remote computer to achieve this.

Physical to Virtual

Click on View Source details to make sure converter is reading your physical computer resources correctly.

4) Click next. In destination type select VMware workstation and choose your VMware product version where you will be running this virtual machine.

Physical to Virtual

Type a name for new virtual machine. If you will be connecting this physical machine and new virtual machine by networking, better to give separate name. Select the location for virtual machine. Make sure the location is having enough of disk space. It depends on your physical computer disk sizes and what disks you select to convert.

5) Click Next, this screen brings some more advanced option. Click on ‘Data to copy’ to choose the physical partitions to be included in conversion. Obviously, you can’t remove system or boot partitions from the list which will cause virtual machine booting problems. Target disks size in virtual machine is editable in this screen.

convert3

6) Other options such as processors, disk types, memory size, network type and even running windows services also can be changed.
Similar options are available when you convert by VMware workstation converter which is mentioned here.

7) Click Next and check the summery list as per your selection. Press Finish to start Physical to Virtual machine conversion by VMware vCenter Converter. Let the conversion complete. Status can be viewed as below.

Physical to Virtual

8)  Unfortunately I didn’t allow completing due to space problem. But I did the same live physical to virtual conversation by VMware workstation converter, and opened virtual machine successfully.Read here for more information.

9) Once conversation is over, open the virtual machine in VMware workstation or VMware player. That’s it. Enjoy.

Recommended Posts

posted @ 2012-02-11 14:13 lexus 阅读(14) 评论(0) 编辑

Is it possible to convert a Physical Ubuntu Install (Intel based PC with Ubuntu 10.10) to a virtual box disk, so that I can use that same environment on a separate pc or can keep it virtual for testing?

Something similar to "Disk2VHD" which converts a physical Windows 2K3 and above box into a VHD or VMware image.

Will be grateful for your assistance ! Kind Regards

linkimprove this question

25% accept rate
feedback

Yes, however it will most likely take a very long time. I haven't actually tried the steps below, but they should work.

First, you need to make an image of your entire partition. You need to know the partition path of the Ubuntu partition, for example /dev/sda1 would be the first partition on the first attached hard drive.

sudo dd if=PART_PATH of=OUTPUT_PATH/ubuntu.bin

note that you should do the above command from a liveCD with the partition you are trying to copy unmounted -- i.e. you need to have another hard drive or something to copy all the data to.

You can shut the liveCD down and boot back into Ubuntu to perform the last step:

Convert the binary into a vbox drive:

VBoxManage convertdd PATH_TO_ubuntu.bin ubuntu.vdi --format VDI

you can then use the resulting ubuntu.vdi as a Virtualbox drive. Just make sure you have plenty of time and hard drive space for this operation. A little tip: commandline tasks can be suspended by hitting The operation will go to sleep, and you can use you computer again. When you are interested in resuming the process, type fg in the terminal, and the operation will resume. Quite handy for long operations like this.

posted @ 2012-02-11 14:05 lexus 阅读(13) 评论(0) 编辑

P2V of a Physical Machine with vCenter Converter

P2V is a large subject to cover, as I cannot cover every scenario, so I am going to briefly cover a P2V conversion of an physical Ubuntu server I have kicking around. Many companies are trying to reduce there footprint and convert many physical machines into virtual ones, web servers, SMTP server are ideal candidates. The conversion is a two step process, the actual conversion and the cleanup process after you have created the VM. There are a number of 3rd party P2V converters including free ones but I will be using VMware own vCenter Converter to perform this task. Vware vCenter converter is a windows based application, that installs onto the vCenter management server, it fully supports both windows and linux conversions but you may want to check VMwareown website for all the available supported OS's. There are two versions of the converter available

  • Starter - is agent based and is free
  • Enterprise - can be either be agent or can boot from a cd

VMware vCenter converter is not a silver bullet, you may have to work with the converted VM to get it working properly, also if the server originally had problems those problems may be replicated in the VM environment. The more complex the physical server (could be a domain control, cluster server, etc), the more you may have problems converting it and getting it to work, here is where you need to look at the VMware forums or search the internet for answers.

Installing vCenter Converter

Installing the vCenter converter is like a normal application installation, on the vCenter server start the installation by putting in the vCenter 4.1 cd, and then selecting vCenter Converter

During the installation process, you will be asked about the vCenter management server details

Once the installation has finished select the plugins -> manage-plugins from the top bar of the vCenter window, then select download and install plugin

That's it, you are now ready to convert physical servers

P2V

Once you have the P2V plugin installed we can now import a physical server, I have a old HP D510 desktop PC with Ubuntu 32-bit OS running on it (yep old pc and old OS), lets convert this physical machine into a virtual machine. First select the ESXi server that you wish to import the new virtual machine into, in my case I have selected vmware01, right-click and select "import machine"

Now enter the details of the running physical server, I selected "view source details", just to make sure the connection is working and we have access to the physical server

All looks good, it see's my physical server as a Ubuntu 8.04 32-bit server

The next screen, gives us details on where the VM will be placed, I changed the datastore to a shared storage area (filer2_ds1), you can change the name of the VM if you wish

The screen allows us to configure the VM's hardware

I notice that the network was in correct, so selected edit and changed the network from private to public and can add additional NIC's if you wish

The "data to copy" screen allows us to select what volumes/filesystems we wish to copy across, there may be a case that you do not some volumes/filesystems copied and thus speed up the importing process.

With very little effort we are at the summary screen ready to import our physical server

It took about 5 minutes to import this server, the time it takes all depends on how much data you need to import, you can monitor the progress from the "recent tasks" window in the vCenter man screen

And here we have it, a fully imported physical server, I double checked the hardware settings and it done a pretty good job as I did not have to change anything

When I started the VM, all I had to do was edit the /etc/network/interfaces file and change the NIC to eth3 and up the interface and away we go, as you can see below

Ok not all P2V conversions will go as smoothly as this one did but you get the idea on what is involved and what you need to prepare before hand when performing a P2V conversion. There is also a Cold-Clone boot CD which allows you reboot the physical server from the CD and clone the physical server while it is offline.

posted @ 2012-02-11 14:01 lexus 阅读(14) 评论(0) 编辑

Ubuntu 10.04 Desktop 快速添加微软雅黑字体

向Ubuntu里添加雅黑字体,貌似已经成为了中文用户的一项必要功课。

即使你像我一样喜欢使用英文的系统,还是需要在浏览网页,编辑文档,收发邮件等过程中用到中文字体。

如果你Google或者参考 Ubuntu Wiki 就很容易找到向 Ubuntu 里添加字体的方法。

一直以来我也是这么做的,但是最近我发现 Ubuntu 10.04 以后有了更简单的方法。

你只需要三步便可完成:

1. 从Windows的机器上复制雅黑字体文件。以Win7为例,在 %windir%\fonts 下面找到雅黑字体,默认有两个文件(字体)

2. 复制到Ubuntu的机器上,双击字体文件选择 Install Font (安装字体),或者在右键列表里选择安装

3. 现在字体已经可以使用了,你直接在你想要设置的程序里修改就可以了

 

另外设置Firefox的中文字体有一个小技巧。

你不应该去设置默认字体,这样会更改英文的字体。

你应该去高级里设置中文Chinese的字体以及其他Other的字体。

Other对应于Unicode。

这样可以保持英文字体不变,中文字体改为雅黑。

posted @ 2012-02-11 12:43 lexus 阅读(58) 评论(0) 编辑

Ubuntu/linux下最强大的下载工具-aria2

aria2是我今天新学到的一个命令行的下载工具,虽然还没研究透,但是他绝对比wget更好.

 

aria2 是 Linux 下一个不错的高速下载工具。由于它具有分段下载引擎,所以支持从多个地址或者从一 个地址的多个连接来下载同一个文件。这样自然就大大加快了文件的下载速 度。aria2 也具有断点续传功能,这使你随时能够恢复已经中断的文件下载。除了支持一般的 http(s) 和 ftp 协议外,aria2 还支持 BitTorrent 协议。这意味着,你也可以使用 aria2 来下载 torrent 文件。

 

安装 aria2
 
aria2 目前已被包含到许多 Linux 发行版中,因此你可以通过所用的系统直接加以安装。例如,在 Debian/Ubuntu 中,你可以在终端执行如下指令来安装 aria2:

 

sudo apt-get install aria2

 

aria2 的使用方法

 

aria2 是命令行程序,使用非常简单。

 

  • 一般使用使用 aria2 下载文件,只需在命令后附加地址即可。比如我们下载ubuntu如:
    aria2c http://www.mirror.tw/pub/ubuntu/releases/jaunty/ubuntu-9.04-desktop-i386.iso
  • 分段下载利用 aria2 的分段下载功能可以加快文件的下载速度,对于下载大文件时特别有用。为了使用 aria2 的分段下载功能,你需要在命令中指定 s 选项。如:
    aria2c -s 2 http://www.mirror.tw/pub/ubuntu/releases/jaunty/ubuntu-9.04-desktop-i386.iso

    这将使用 2 个连接来下载该文件。s 后面的参数值介于 1~5 之间,你可以根据实际情况选择。

  • 断点续传在命令中使用 c 选项可以断点续传文件。如:
    aria2c -c http://www.mirror.tw/pub/ubuntu/releases/jaunty/ubuntu-9.04-desktop-i386.iso
  • 下载 torrent 文件你也可以使用 aria2 下载 BitTorrent 文件。如:
    aria2c -o gutsy.torrent http://cdimage.ubuntu.com/daily-live/current/gutsy-desktop-i386.iso.torrent

关于 aria2 的更多用法,可以通过 man aria2c 查阅。

posted @ 2012-02-11 07:51 lexus 阅读(167) 评论(0) 编辑

Home > virtualization > How To Convert VMWare Image (.vmdk) to VirtualBox Image (.vdi)

How To Convert VMWare Image (.vmdk) to VirtualBox Image (.vdi)

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

I’ve found more and more people are switching to Virtualbox these days and I keep running into the same question.  ”How can I convert my VMware images to Virtualbox images?”  Well, breath easy because it is possible and not very difficult!

There are two methods that I am aware of that will allow you to use your VMware images on Virtualbox.  The first method I’ll outline uses the graphical Virtualbox interface and the second uses the command line. Each method should be equally as stable, it simple depends on your preference.

Method 1

Start Virtualbox
Inside the Virtualbox Menu click: File > Virtual Media Manager
Click on the “Add” button.
Locate and select the VMware .vmdk file you’d like to convert.
Click Open.
Verify your disk image has been added to the list of images and that the virtual and actual sizes appear accurate.
Click OK
Create a new virtual machine profile, selecting your imported image for the storage.
Boot your new virtual machine.

Method 2
To use the second method we’ll need an addition command-line tool called qemu.

sudo aptitude install qemu

You’ll new be able to convert a .vmdk (VMware image) to a .bin format, which can then be converted to a Virtualbox native .vdi format.

qemu-img convert /path/to/original.vmdk converted.bin

You’ll then need to use the VBoxManage utility that comes with Virtualbox to convert the .bin to a native .vdi format:

VBoxManage convertdd converted.bin converted.vdi

You can now create your new Virtualbox machine profile, using this new .vdi file as your disk image.

Two methods for converting VMware images to Virtualbox images.  Are there any other methods that you can suggest, or have you had better experience with one or the other?  Let us know!

  1. Kragil
    March 22nd, 2009 at 08:41 | #1
posted @ 2012-02-11 06:45 lexus 阅读(33) 评论(0) 编辑

VMware vCenter Converter Standalone

Automate and simplify physical to virtual machine conversions as well as conversions between virtual machine formats with Converter Standalone.

Features & Benefits

VMware vCenter Converter Standalone can be run on a wide variety of hardware and supports most commonly used versions of Microsoft Windows and Linux operating systems. Quickly and reliably convert local and remote physical machines into virtual machines without any disruption or downtime.

Complete multiple conversions simultaneously with a centralized management console and an intuitive conversion wizard.

DOWNLOAD INCLUDES
  • VMware vCenter Converter Standalone

Learn more about VMware vCenter Converter Standalone
Evaluate VMware vSphere

posted @ 2012-02-11 06:35 lexus 阅读(14) 评论(0) 编辑

VBoxManage modifyhd xpvm.vdi --resize 20000
du -sh vmxp.vdi
ref:
posted @ 2012-02-11 00:52 lexus 阅读(15) 评论(0) 编辑

 

Java: Good way to encapsulate Integer.parseInt()

http://stackoverflow.com/questions/1486077/java-good-way-to-encapsulate-integer-parseint#

 

 

 

 

java.toString() ,(String),valueOf

 (2009-11-14 23:56:43)
标签: 

it

 
在java项目的实际开发和应用中,常常需要用到将对象转为String这一基本功能。本文将对常用的转换方法进行一个总结。常用的方法有Object#toString(),(String)要转换的对象,String.valueOf(Object)等。下面对这些方法一一进行分析。
方法1:采用 Object#toString()方法请看下面的例子:
Object object = getObject();
System.out.println(object.toString());
在这种使用方法中,因为java.lang.Object类里已有public方法.toString(),所以对任何严格意义上的java对象都可以调用此方法。但在使用时要注意,必须保证object不是null值,否则将抛出NullPointerException异常。采用这种方法时,通常派生类会覆盖Object里的toString()方法。
方法2:采用类型转换(String)object方法这是标准的类型转换,将object转成String类型的值。使用这种方法时,需要注意的是类型必须能转成String类型。因此最好用instanceof做个类型检查,以判断是否可以转换。否则容易抛出CalssCastException异常。此外,需特别小心的是因定义为Object 类型的对象在转成String时语法检查并不会报错,这将可能导致潜在的错误存在。这时要格外小心。如:
Object obj = new Integer(100);
String strVal = (String)obj;
在运行时将会出错,因为将Integer类型强制转换为String类型,无法通过。但是,
Integer obj = new Integer(100);
String strVal = (String)obj;
如是格式代码,将会报语法错误。
此外,因null值可以强制转换为任何java类类型,(String)null也是合法的。
方法3:采用String.valueOf(Object) String.valueOf(Object)的基础是Object#toString()。但它与Object#toString()又有所不同。在前面方法1的分析中提到,使用后者时需保证不为null。但采用第三种方法时,将不用担心object是否为null值这一问题。为了便于说明问题,我们来分析一下相关的源代码。Jdk里String# valueOf(Object)源码如下:

public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString(); }
从上面的源码可以很清晰的看出null值不用担心的理由。但是,这也恰恰给了我们隐患。我们应当注意到,当object为null时,String.valueOf(object)的值是字符串”null”,而不是null!!!在使用过程中切记要注意。试想一下,如果我们用 if(String.valueOf(object)==null){System.out.println(“传入的值是null!”);}这样的语句将可能会发生什么问题。再想一下,向控制台输出时,在视觉上如下语句在执行的结果上有什么不同:
System.out.println(String.valueOf(null));
System.out.println(null);
我们看到的输出将是一模一样的东西:null,但它们意义相同吗?
以上是对object对象转换为String的一些总结。
Convert a String to an int, returning zero if the conversion fails.
 
    
   
/**
 * 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.
 */
 
 
/**
 
 *
 @author John Keyes (john at integralsource.com)
 @version $Revision: 680644 $, $Date: 2008-07-29 01:13:48 -0700 (Tue, 29 Jul 2008) $
 */
public class Main {
 
 
  //--------------------------------------------------------------------
  
  /**
   * <p>Convert a <code>String</code> to an <code>int</code>, returning
   * <code>zero</code> if the conversion fails.</p>
   
   @param str  the string to convert
   @return the int represented by the string, or <code>zero</code> if
   *  conversion fails
   */
  public static int stringToInt(String str) {
      return stringToInt(str, 0);
  }
 
  /**
   * <p>Convert a <code>String</code> to an <code>int</code>, returning a
   * default value if the conversion fails.</p>
   
   @param str  the string to convert
   @param defaultValue  the default value
   @return the int represented by the string, or the default if conversion fails
   */
  public static int stringToInt(String str, int defaultValue) {
      try {
          return Integer.parseInt(str);
      catch (NumberFormatException nfe) {
          return defaultValue;
      }
  }
 
}
 
   

http://www.java2s.com/Code/Java/Data-Type/ConvertaStringtoanintreturningzeroiftheconversionfails.htm

 

 

posted @ 2012-02-11 00:37 lexus 阅读(12) 评论(0) 编辑