So Tired !_! 逆水行舟, 不进则退!



发布在 Nick Xu

前段时间我的小黑ibm x30网卡退休了,买了个硬盘盒,把硬盘拆来当移动硬盘用,硬盘已经装有系统debian,用Vmware建虚拟机选择磁盘的时候可以直接选择物理磁盘作 为系统磁盘,这样就很方便启动原来笔记本装有的debian系统,最近换了VirtualBox,发现不能像Vmware那样傻瓜化操作,只能用命令行来 建立磁盘才可以使用物理硬盘。

1.运行cmd,cd进入你的VirtualBox目录,如:  cd C:\Program Files\Sun\VirtualBox
2.命令行运行VBoxManage.exe,如:VBoxManage internalcommands createrawvmdk -filename  d:\x30.vmdk -rawdisk \\.\PhysicalDrive1
\\.\PhysicalDrive1 表示我的机器上的第二块硬盘,\\.\PhysicalDrive0是第一块,\\.\PhysicalDrive3是第三块,以此类推。
网上有朋友说在windows 的磁盘管理中能看到硬盘的分区路径,格式如\\.\PhysicalDrive0。但是我没有找到,如果有朋友能知道这个怎得来的请告诉我,谢谢。

附 VBoxManage internalcommands createrawvmdk 命令:

VBoxManage internalcommands createrawvmdk  创建一个vmdk格式的硬盘
-filename <filename> vmdk格式的硬盘所对应的vmdk文件
-rawdisk <diskname>  vmdk文件所对应的物理硬盘
[-partitions <list of partition numbers>  vmdk文件对应的物理硬盘的分区
[-mbr <filename>] ] 将这个文件包含的引导记录写到vmdk文件
[-register] 将这个新创建的硬盘注册到virtualbox
[-relative] 激活这个新创建的硬盘的分区


Build ASP.NET/Mono Applications with mod_mono and Apache on Debian 5 (Lenny)

发布在 Nick Xu

mod_mono is an Apache module that makes it possible to run ASP.NET applications in Linux environments running Apache. While ASP.NET is a Microsoft technology and is traditionally used with IIS, mod_mono has become a viable option for deploying ASP.NET applications on Linux. This guide is inspired by the mod_mono guide created by the Ubuntu CommunityExternal Link and the Mono Project's Apache and Mono documentExternal Link with minor modifications. This guide does not cover installation and configuration of the Mono IDE which is used to develop ASP.NET applications on Linux. If you are interested in developing using Visual Studio for Mono, you can download a 30-day trial of the commercial Mono Tools plugin at the Mono Tools for Visual Studio pageExternal Link.

This guide assumes that you've followed the steps outlined in our getting started guide. You will install the Apache web server with very minimal configuration. If you already have Apache installed and configured, you may omit these steps; however, if you have not installed Apache and are unfamiliar with this server read the installation guide for additional documentation. Additionally, mod_mono is incompatible with the integrated PHP interpreter described in other guides. If you need to have both mod_mono and PHP running on the same Apache server you will need to run PHP scripts using the CGI method

These instructions work with the Linode platform. If you don't have a Linode yet, sign up for a Linux VPS and get started today.


Install Required Software Link

Before beginning the installation process, issue the following command to update your package lists:

apt-get update
apt-get upgrade

Install Apache Link

If you already have Apache installed and configured, you can safely skip this section of the guide. Install Apache by running the following command:

apt-get install apache2

As mentioned earlier, you will need to go to the installation guide if you wish to configure your server beyond the default configuration.

Install mod_mono Link

The Apache daemon must be stopped before mod_mono is installed. Issue the following command to stop the apache process:

/etc/init.d/apache2 stop

At this point we're able to install the required packages for mod_mono. Run the following command:

apt-get install mono-apache-server2 libapache2-mod-mono libmono-i18n2.0-cil

When the installation process completes start Apache with the following command:

/etc/init.d/apache2 start

Configure Apache Link

We recommend using name-based virtual hosts for web hosting. Refer to the Apache documentation for setting up Name-based virtual hosts.

Recent versions of mod_mono utilize the AutoHosting method of application deployment. This allows non-privileged users to deploy new applications without modifying Apache configuration files. While this provides great flexibility, it may also present a security risk. As a result, mod_mono must be enabled on a per-virtual host basis.

For the sake of this guide, we're going to create a site on the root of our example domain, If you already have an Apache configuration for the root of your site, you will need to modify your existing virtual host file or create a new one on a subdomain of your site. Create the virtual host file, taking the following example virtual host configuration and modifying it to suit your needs. You may also use the Mod_Mono Configuration GeneratorExternal Link to generate your own custom configuration.

File excerpt: /etc/apache2/sites-available/

<VirtualHost *:80>
  DocumentRoot /srv/www/
  ErrorLog /srv/www/
  CustomLog /srv/www/ combined

  MonoServerPath "/usr/bin/mod-mono-server2"
  MonoDebug true
  MonoSetEnv MONO_IOMAP=all
  MonoApplications "/:/srv/www/"
  <Location "/">
    Allow from all
    Order allow,deny
    SetHandler mono
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
  <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript

Save and close the file, and create the directories referenced in the DocumentRoot and ErrorLog directive:

mkdir -p /srv/www/
mkdir /srv/www/

Enable the site by running the a2ensite command:


Since we have modified the virtual host configuration, Apache must be reloaded:

/etc/init.d/apache2 reload

Note: Should you restart Apache in the future, you will see an error that will look similar to this:

[crit] (13)Permission denied: Failed to attach to existing dashboard,
and removing dashboard file '/tmp/mod_mono_dashboard_XXGLOBAL_1' failed
(Operation not permitted). Further action impossible.

You can safely ignore this warning, as it won't affect deployment using the methods explained in this guide.

Installing MySQL Connector/Net for ASP.NET Link

This section assumes that you already have a functioning MySQL installation. Please refer to our MySQL Installation Guide for more detailed instructions for installing MySQL, otherwise issue the following command:

apt-get install mysql-server

In order for your ASP.NET application to communicate properly with your MySQL server, you must install the MySQL Connector/Net driver. The following commands download and install the 6.2.3 version of the connector. Check the MySQL UpstreamExternal Link to ensure that this the latest version of the plugin:

cd /opt/
unzip -d mysqlConnector
cd mysqlConnector
gacutil -i
gacutil -i mysql.web.dll

Creating a Database to Test the MySQL Connector Link

Now that the MySQL Connector has been installed, you should test it by creating a sample database and a test table. First you must log in to your MySQL DBMS:

mysql -u root -p

Next you must create the sample table. Issue the following commands at the MySQL prompt:

USE sample;
INSERT INTO sample.test VALUES (null, 'Lucy');
INSERT INTO sample.test VALUES (null, 'Ivan');
INSERT INTO sample.test VALUES (null, 'Nicole');
INSERT INTO sample.test VALUES (null, 'Ursula');
INSERT INTO sample.test VALUES (null, 'Xavier');

Finally you must create a test user named "testuser" and give that user access to the newly created sample database:

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'somepassword';
GRANT ALL PRIVILEGES ON sample.* TO 'testuser'@'localhost';

Creating a Simple ASP.NET Application Link

Now that you have created a sample database, you can test your installation with the following test page. This will not only test your Mono installation but it will also will test your MySQL connector configuration. First create a file called testdb.aspx in your DocumentRoot and paste the text below into it. Be sure to change the User ID and Password to match what you specified above.

File excerpt: /srv/www/

[COLORIZE aspx-cs] <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="MySql.Data.MySqlClient" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " Link"> <html xmlns=" Link" xml:lang="en" lang="en"> <head> <title>ASP and MySQL Test Page</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script runat="server"> private void Page_Load(Object sender, EventArgs e) { string connectionString = "Server=;Database=sample;User ID=testuser;Password=somepassword;Pooling=false;"; MySqlConnection dbcon = new MySqlConnection(connectionString); dbcon.Open();

MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM test", dbcon); DataSet ds = new DataSet(); adapter.Fill(ds, "result");

dbcon.Close(); dbcon = null;

SampleControl.DataSource = ds.Tables["result"]; SampleControl.DataBind(); } </script>


<body> <h1>Testing Sample Database</h1> <asp:DataGrid runat="server" id="SampleControl" /> </body>

</html> [/COLORIZ]

Next you will need to create a web.config file. You can copy and paste the the example below. Please note that Custom Errors have been turned off in this web.config for debugging purposes. The customErrors mode line should be removed in a production environment.

File excerpt: /srv/www/

                <customErrors mode="Off"/>
                        <add assembly="MySql.Data"/>

Visit the testdb.aspx file in a web browser. If you see the text "Testing Sample Databases" in your browser with the information that you inserted into the database above, you now have a functioning mod_mono installation and can continue with the development and deployment of your own application!

More Information Link

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.