问题..我只能访问wmic ... Lame我知道..但需要找出哪个卷对应哪个分区对应哪个磁盘..我知道如何对应哪个分区对应什么磁盘,因为磁盘ID直接在wmic查询的结果中。但是,问题的第一部分更加困难。如何关联哪个卷属于哪个分区?..
有没有办法,使用wmic来反向设计哪个卷映射到哪个分区?
如果是这样,这个查询会怎么样?
答案 0 :(得分:1)
最简单的方法是在命令提示符下使用diskpart
:
C:\>diskpart
Microsoft DiskPart version 10.0.10586
Copyright (C) 1999-2013 Microsoft Corporation.
On computer: TIMSPC
DISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART> detail disk
HGST HTS725050A7E630 *(Note: This is the Model of my hard disk)*
Disk ID: 00C942C7
Type : SATA
Status : Online
Path : 0
Target : 0
LUN ID : 0
Location Path : PCIROOT(0)#PCI(1F02)#ATA(C00T00L00)
Current Read-only State : No
Read-only : No
Boot Disk : Yes
Pagefile Disk : Yes
Hibernation File Disk : No
Crashdump Disk : Yes
Clustered Disk : No
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 System NTFS Partition 350 MB Healthy System
Volume 1 C OSDisk NTFS Partition 464 GB Healthy Boot
Volume 2 NTFS Partition 843 MB Healthy Hidden
DISKPART> exit
Leaving DiskPart...
C:\>
您可以访问命令行,因为您可以访问WMIC,因此 这个方法。
基于以下评论: 不,没有办法使用WMIC以100%准确度确定哪个分区对应于特定驱动器上的哪个分区。通过WMI确定此信息的问题在于并非所有驱动器都是基本驱动器。某些磁盘可能是dynamic disks,其中包含跨多个驱动器的RAID卷。有些可能是完整的硬件实现抽象,如存储阵列(例如,HP ProLiant中的p410i RAID控制器)。此外,还有多种分区方案(例如UEFI/GPT vs BIOS/MBR)。然而,WMI与其环境无关。也就是说,它并不关心硬件。它只是另一种抽象形式,它提供了unifies and extends existing instrumentation and management standards。
的通用接口模型要获得所需的详细程度,需要一个可以在更低级别进行连接的工具,例如设备的驱动程序,并希望驱动程序提供所需的信息。如果它没有,你将看到非常低级别的编程与设备本身接口......实质上是创建一个提供所需信息的新驱动程序。但基于您仅限命令行访问的限制,Diskpart是您将找到的最接近的预建工具。
- 有些卷没有传统的字母。
醇>
和? Diskpart可以根据分配的编号选择磁盘,分区和卷。驱动器号无关紧要。
- 磁盘部分中没有列出任何类型的ID,允许用户在引用卷时100%知道他们正在处理哪个分区。
醇>
以下是我的一台带有两个500GB硬盘的服务器的示例。 Boot / OS驱动器中的第一个。第二个有2GB的未分配空间。
DISKPART> list volume
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- ------
Volume 0 System NTFS Partition 350 MB Healthy System
Volume 1 C OSDisk NTFS Partition 465 GB Healthy Boot
Volume 2 D New Volume NTFS Partition 463 GB Healthy
DISKPART> select volume 2
Volume 2 is the selected volume.
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 465 GB 0 B
* Disk 1 Online 465 GB 2049 MB
DISKPART> list partition
Partition ### Type Size Offset
------------- ---------------- ------- -------
* Partition 1 Primary 463 GB 1024 KB
DISKPART> list volume
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- ------
Volume 0 System NTFS Partition 350 MB Healthy System
Volume 1 C OSDisk NTFS Partition 465 GB Healthy Boot
* Volume 2 D New Volume NTFS Partition 463 GB Healthy
DISKPART>
注意星号?这些表示活动磁盘,分区和卷。虽然这些不是允许用户100%知道他们正在处理哪个分区所需的ID,但您至少可以清楚地看到第2卷(D :)位于磁盘1的分区1上。
- 有些卷是RAW磁盘,本质上是说..这是一个原始磁盘,我想找出这些原始磁盘所在的位置。
醇>
正如您在2gb可用空间中创建没有文件系统的卷之后所看到的那样,这没有任何区别:
DISKPART> list volume
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- -------
Volume 0 System NTFS Partition 350 MB Healthy System
Volume 1 C OSDisk NTFS Partition 465 GB Healthy Boot
Volume 2 D New Volume NTFS Partition 463 GB Healthy
Volume 3 RAW Partition 2048 MB Healthy
DISKPART> select volume 3
Volume 3 is the selected volume.
DISKPART> list volume
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- -------
Volume 0 System NTFS Partition 350 MB Healthy System
Volume 1 C OSDisk NTFS Partition 465 GB Healthy Boot
Volume 2 D New Volume NTFS Partition 463 GB Healthy
* Volume 3 RAW Partition 2048 MB Healthy
DISKPART> list partition
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 463 GB 1024 KB
* Partition 2 Primary 2048 MB 463 GB
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 465 GB 0 B
* Disk 1 Online 465 GB 1024 KB
- 我使用wmic的原因是因为我需要编写许多磁盘操作脚本。您是否尝试过编写从diskpart获取信息的脚本?
醇>
不,但是 scriptable。
在示例数据中,您可以枚举磁盘,卷和分区。通过循环遍历每个对象并选择它,您可以创建哪个卷位于哪个分区以及哪个驱动器包含该分区的映射。 Diskpart可能无法提供100%的所需数据,100%的精确度,但它是您要找到的最接近命令行的工具。
答案 1 :(得分:0)
wmic logicaldisk get name, volumename
有关更多信息,请使用wmic logicaldisk get /?