确定驱动器是SAN

时间:2010-03-02 15:37:24

标签: sql-server

有人可以告诉我们如何确定本地磁盘或SAN。

由于

3 个答案:

答案 0 :(得分:2)

没有“操作系统不可知”的方法来确定文件系统是否由SAN后端。

也就是说,请告诉我们您正在使用的操作系统,以便我们可以帮助确定操作系统的具体方法,以确定是否(除了询问您的存储管理员)。

答案 1 :(得分:0)

SAN是存储区域网络拓扑结合到物理网络拓扑中,它表示存储器用于通过网络共享/存储数据(通常是tcp / ip)...它是类似于NFS(网络文件共享),或使用Microsoft特定的服务器消息块协议来指定服务器上使用驱动器号的共享 - 通用命名约定,其中共享驱动器以'\的形式映射到驱动器号\服务器\富”。

请您澄清这是否是您要找的?如何确定驱动器是否映射到共享驱动器,例如'\\ servername \ foo'?

在这里查看此线程...在映射驱动器和断开映射驱动器here上。并在此处检查路径是否在网络上here

修改:感谢 zombiesheep ,因为我在CompTIA Network + 2009培训期间被其他人告知后我的混淆澄清了。 ....杜!

希望这有帮助, 最好的祝福, 汤姆。

答案 2 :(得分:0)

在这里,您可以使用C#和WMI。使用此方法,您可以从命令提示符输入“enumSANDrives”,它将列出它们。您可能需要稍微调整一下这些描述,然后通过Scriptomatic手动查看WMI类,或者匹配您的特定SAN。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO; 
using System.Management;
using System.Data.SqlClient;
using Microsoft.Win32;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Security.Principal;

namespace EnumSANDrives
{
    class Program
    {


        static void Main(string[] args)
        {
            //1. Start with the Win32_DiskDrive class and query for instances of Win32_DiskPartition using the DeviceID property and the 
            //Win32_DiskDriveToDiskPartition association class. Now you have a collection of the partitions on the physical drive.
            //2. Query for the Win32_LogicalDisk that represents the partition using the Win32_DiskPartition.DeviceID property and 
            //Win32_LogicalDiskToPartition association class.
            //3. Get the drive letter from the Win32_LogicalDisk.DeviceID.

            ConnectionOptions connOptions = new ConnectionOptions();
            connOptions.Username = "<username>";
            connOptions.Password = "<pwd>";
            connOptions.Authentication = AuthenticationLevel.Packet; 
            connOptions.Impersonation = ImpersonationLevel.Impersonate;
            connOptions.EnablePrivileges = true;
            ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", machine), connOptions);
            manScope.Connect();
            ObjectQuery oQueryDiskDrive = new ObjectQuery("select * from Win32_DiskDrive");
            ManagementObjectSearcher oSearcherDiskDrive = new ManagementObjectSearcher(manScope, oQueryDiskDrive);
            ManagementObjectCollection oReturnDiskDrive = oSearcherDiskDrive.Get();
            foreach (ManagementObject DiskDrive in oReturnDiskDrive)
            {
                ObjectQuery oQueryDiskPartition = new ObjectQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + DiskDrive["DeviceID"] + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition");
                ManagementObjectSearcher oSearcherDiskPartition = new ManagementObjectSearcher(manScope, oQueryDiskPartition);
                ManagementObjectCollection oReturnDiskPartition = oSearcherDiskPartition.Get();
                foreach (ManagementObject DiskPartition in oReturnDiskPartition)
                {
                    ObjectQuery oQueryLogicalDisk = new ObjectQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" + DiskPartition["DeviceID"] + "'} WHERE AssocClass = Win32_LogicalDiskToPartition");
                    ManagementObjectSearcher oSearcherLogicalDisk = new ManagementObjectSearcher(manScope, oQueryLogicalDisk);
                    ManagementObjectCollection oReturnLogicalDisk = oSearcherLogicalDisk.Get();
                    foreach (ManagementObject LogicalDisk in oReturnLogicalDisk)
                    {
                        try
                        {
                            //Console.Write("Drive Name : " + LogicalDisk["DeviceID"].ToString());
                            if (DiskDrive["PNPDeviceID"] != null)
                            {
                                if (DiskDrive["PNPDeviceID"].ToString().Contains("VEN_EMC"))
                                {
                                    Console.WriteLine("Drive Name : " + LogicalDisk["DeviceID"].ToString() + " - " + "EMC SAN " + DiskDrive["Model"].ToString());
                                }
                                if (DiskDrive["PNPDeviceID"].ToString().Contains("VEN_IBM"))
                                {
                                    Console.WriteLine("Drive Name : " + LogicalDisk["DeviceID"].ToString() + " - " + "IBM SAN " + DiskDrive["Model"].ToString());
                                }
                                if (DiskDrive["PNPDeviceID"].ToString().Contains("VEN_COMPAQ"))
                                {
                                    Console.WriteLine("Drive Name : " + LogicalDisk["DeviceID"].ToString() + " - " + "HP SAN " + DiskDrive["Model"].ToString());
                                }



                            }
                            //Console.WriteLine("Size : " + BytesToGB(DiskDrive["Size"].ToString()));
                            //Console.WriteLine("Used Space : " + BytesToGB((Convert.ToDouble(DiskDrive["Size"].ToString()) - Convert.ToDouble(LogicalDisk["FreeSpace"].ToString())).ToString()));
                            //Console.WriteLine("Free Space : " + BytesToGB(LogicalDisk["FreeSpace"].ToString()));
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                    }
                }
            }

        }
    }
}