windows磁盘(disk)分区(partition)卷(volume)

一、diskpart产看相关信息,初步感性认知

(1)使用管理员权限打开 cmd,输入 diskpart命令

 

 

 

 

二、卷(volume)和分区(partition)的不同

1、A volume is a single accessible storage area with a single file system. A partition is a logical division of a hard disk. Both are the units of data storage。

2、Types

There are five volume types: simple volume, mirrored volume, striped volume spanned volume, and RAID-5 volume, while there are three partition types: primary partition, logical partition, and extended partition.

Volume Types

Simple Volume: it is a physical disk that functions like a physically independent unit.

Mirrored Volume: it uses two copies on separate physical disks to duplicate data. When new data is written to the mirrored volume, it will be written to the two copies. If one of the physical disks fails, the data on the disk becomes unavailable, but mirrored volume is a fault-tolerant volume, which means the data on the other physical disk is still usable.

Striped Volume: it is created by combing areas of free space on two or more disks into one logical volume. This volume type does not provide fault tolerance, which means the entire volume will fail when one of the disks containing a striped volume fails.

Spanned Volume: it combines areas of unallocated space from multiple disks into one logical volume. When new data is written into a spanned volume, data will first fill up the free space on the first disk, the fill up that on the next disk, and so on.

RAID-5 Volume: it is a volume with data and parity striped intermittently across three or more physical disks. As a fault-tolerant volume, it allows you to recreate the data that was on the failed portion from the remaining data and parity when a portion of a physical disk doesn’t work.

Partition Types

Primary Partition: it is a hard disk partition that is identified by a drive letter and is used for storing Windows operating systems and other data. The C drive is often a primary partition.

Logical Partition: it is a contiguous area on the hard disk and it consists of one or more logical partitions.

Extended Partition: it is a partition that consists of additional logical partitions. Differing from a primary partition, you don’t need to assign a drive letter to it.

Max Size

What is the max size of a partition and a volume?

As we know, contiguous space on the same disk can be divided into one area, and therefore the max size of a partition is the hard drive space.

In contrast, the max size of a volume can be larger – when it is not a simple volume. The other four types of volume can be created on two or more disks and this combines these disks into a large volume, so that’s why the max size of a volume is larger than that of a partition.

Creation

The biggest difference between a volume and partition is the type of disk used. A volume is created on a dynamic disk, while a partition is created on a basic disk.

Note: When you create a partition via Disk Management, you will find that the New Simple Volume option is offered.

Basic disks are the most common type of partition used in Windows OS. They use a partition table to keep track of all partitions on them and support two styles of partitions – master boot record (MBR) and GUID partition table (GPT).

Dynamic disks also support MBR and GPT. However, they use a hidden logical disk manager (LDM) or virtual disk service (VDS) to track information about the volumes on them and this decides that dynamic disks are more flexible than basic disks.

To learn more about the differences between basic disks and dynamic disks, please read the comparison.

Max Number on Disk

Another difference is the max number of volume and partition on the hard disk.

Regardless of whether dynamic disks on a system use the MBR or GPT partition style, you can create up to 2,000 dynamic volumes on them.

However, the max number of partitions on a basic disk is determined by the style of partitions that the disk uses. When the basic disk uses the MBR partition style, you can create four primary partitions or three primary partitions and one extended partition that can consist of many logical partitions. When the basic disk uses the GPT partition style, you can create up to 128 primary partitions.

MBR vs. GPT Guide: What's The Difference and Which One Is Better

MBR or GPT, which one is better, and what's their exact differences? In this post, we will explain these 2 aspects in detail.

READ MORE

Reliability and Security

Compared with partitions, volumes feature higher reliability and security because data on volumes can be shared with two or more dynamic disks.

Now, what’s your opinion of partition vs volume? Regardless of whether you prefer volume or partition, go on reading. The next part shows you how to create a volume or partition on a disk. 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
下面是一个示例函数,它使用 IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS 和 IOCTL_DISK_GET_PARTITION_INFO_EX 控制码来获取指定分区信息: ```c #include <windows.h> #include <winioctl.h> #include <stdio.h> BOOL GetPartitionInfoByVolume(HANDLE hVolume, PULARGE_INTEGER pStartingOffset, PULARGE_INTEGER pPartitionSize, PWSTR pFileSystemName, DWORD cchFileSystemName) { BOOL bRet = FALSE; DWORD dwBytesReturned; STORAGE_DEVICE_NUMBER sdn; VOLUME_DISK_EXTENTS vde; PARTITION_INFORMATION_EX pie; // 获取的设备号 if (!DeviceIoControl(hVolume, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn), &dwBytesReturned, NULL)) { printf("DeviceIoControl(IOCTL_STORAGE_GET_DEVICE_NUMBER) failed %d\n", GetLastError()); goto Exit; } // 获取所在的磁盘编号和偏移量 if (!DeviceIoControl(hVolume, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &vde, sizeof(vde), &dwBytesReturned, NULL)) { printf("DeviceIoControl(IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS) failed %d\n", GetLastError()); goto Exit; } // 获取包含指定偏移量的分区信息 HANDLE hDisk = NULL; WCHAR szDiskName[MAX_PATH]; _snwprintf_s(szDiskName, MAX_PATH, L"\\\\.\\PhysicalDrive%d", sdn.DeviceNumber); hDisk = CreateFile(szDiskName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDisk == INVALID_HANDLE_VALUE) { printf("CreateFile(%ws) failed %d\n", szDiskName, GetLastError()); goto Exit; } LARGE_INTEGER liStartingOffset; liStartingOffset.QuadPart = pStartingOffset->QuadPart + vde.Extents[0].StartingOffset.QuadPart; if (!DeviceIoControl(hDisk, IOCTL_DISK_GET_PARTITION_INFO_EX, &liStartingOffset, sizeof(liStartingOffset), &pie, sizeof(pie), &dwBytesReturned, NULL)) { printf("DeviceIoControl(IOCTL_DISK_GET_PARTITION_INFO_EX) failed %d\n", GetLastError()); goto Exit; } // 返回分区信息 pPartitionSize->QuadPart = pie.PartitionLength.QuadPart; wcsncpy_s(pFileSystemName, cchFileSystemName, pie.FileSystemTypeName, cchFileSystemName - 1); bRet = TRUE; Exit: if (hDisk != INVALID_HANDLE_VALUE) { CloseHandle(hDisk); } return bRet; } ``` 该函数需要传入一个已经打开的句柄和指向 ULARGE_INTEGER 类型的指针,以获取的起始偏移量和分区大小。函数还需要传入一个指向 WCHAR 类型的缓冲区和一个 DWORD 类型的值,以获取文件系统类型的字符串和字符串长度。如果函数调用成功,则返回 TRUE;否则返回 FALSE。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值