了解硬盘扇区大小(Understanding Hard Disk Sector Size)
我目前正在开发一个与原始磁盘操作交互的内核模式驱动程序。
我希望更多地了解行业规模的概念。 在制造HDD时,每个物理驱动器的扇区大小是否为恒定值?
或者它是由在磁盘上格式化的文件系统定义的? 如果是这样,他们可以是2扇区大小? 一个用于物理磁盘,一个用于文件系统?
我知道例如NTFS在其BIOS参数块中有一个名为“扇区大小”的DWORD,这是NTFS FS扇区大小吗? 或者它是物理HDD扇区大小?
非常感谢迈克尔
I'm currently developing a kernel mode driver that interacts with raw disk operations.
I wish to understand more about the concept of Sector Size. Is a sector size a constant value per physical drive that was set when the HDD was manufactured ?
Or is it defined by the file system that is formatted on the Disk ? If so can they be 2 Sector Size ? One for the physical disk and one for the File System ?
I know for example that NTFS has in its BIOS Parameter Block a DWORD called "sector size", is this the NTFS FS sector size ? Or is it the Physical HDD sector size ?
Thanks a lot Michael
原文:https://stackoverflow.com/questions/17533474
更新时间:2021-03-07 07:03
最满意答案
Yes, the sector size is established by the drive manufacture.
According to wikipedia:
The standard sector size of 512 bytes for magnetic disks was established with the inception of the hard disk drive in 1956 http://en.wikipedia.org/wiki/Disk_sector
Hard drives have typically been shipped with 512 byte sectors. That was until January 2011, when hard drive manufactures unanimously switched to 4k sectors.
As all hard drive manufacturers have agreed to transition to the Advanced Format sector design by January 2011 http://www.seagate.com/tech-insights/advanced-format-4k-sector-hard-drives-master-ti/
Querying the device for its sector size is not reliable. It is not uncommon for drives report the wrong sector size.
Unfortunately, some HDD manufacturers do not properly respond to the device inquiry sizes. ... The problem is that some HDDs misrepresent 4KB sector disks as having a physical sector size of 512 bytes. http://wiki.illumos.org/plugins/viewsource/viewpagesrc.action?pageId=1147716
相关问答
你想要fsutil。 确保您以管理员身份运行命令提示符。 C:\Windows\system32>fsutil fsinfo ntfsinfo c:
NTFS Volume Serial Number : 0xf4ca5d7cca5d3c54
Version : 3.1
Number Sectors : 0x00000000378fd7ff
Total Clusters :
...
由于您在谈论物理磁盘而不是分区,请查看DeviceIoControl 。 从那里的示例,其中包括在wmain计算总磁盘大小: #include
#include
#include
BOOL GetDriveGeometry(LPWSTR wszPath, DISK_GEOMETRY *pdg)
{
HANDLE hDevice = INVALID_HANDLE_VALUE; // handle to the drive
...
我从另一个主题得到答案。 基本上,我们正在创建Microsoft VHD(虚拟硬盘)并使用RoboCopy填充文件并运送VHD。 请参阅: 解压缩太慢,无法传输许多文件 I got the answer from a different thread. Basically, we are creating a Microsoft VHD (virtual Hard Disk) and filling in the files with RoboCopy and shipping the VHD.
...
“块大小为4096”并不是特别需要,并且您没有提到任何会破坏内核内置缓存机制的访问模式。 读取和写入数据的最有效方法是使用文件。 "Blocks in size of 4096" is not a special need, and you have not mentioned any access patterns that would break the kernel's built-in caching mechanisms. The most efficient way to read a
...
原来我的代码没问题,确实改变了Michael Petch提出的一些事情,但实际的加载没有问题。 问题是当我使用linux的“dd”程序复制引导扇区时,它将截断整个文件。 我通过启用标志来防止截断来解决这个问题。 Turns out my code is fine, did change a few things that Michael Petch proposed but the actual loading was fine. The problem was that when I was u
...
是的,扇区大小由驱动器制造商确定。 根据维基百科: 磁盘的标准扇区大小为512字节是在1956年硬盘驱动器启动时建立的http://en.wikipedia.org/wiki/Disk_sector 硬盘驱动器通常附带512字节扇区。 直到2011年1月,硬盘制造商一致转向4k扇区。 由于所有硬盘制造商已同意在2011年1月之前过渡到高级格式部门设计http://www.seagate.com/tech-insights/advanced-format-4k-sector-hard-drives-
...
我在我的机器上运行它(Python 3.4): import shutil
total, used, free = shutil.disk_usage("\\")
print("Total: %d GB" % (total // (2**30)))
print("Used: %d GB" % (used // (2**30)))
print("Free: %d GB" % (free // (2**30)))
输出: Total: 931 GB
Used: 29 GB
Free: 902 G
...
最后两个字节是引导签名。 在从扇区0加载引导代码之前,BIOS应该检查这些字节是否具有值0x55然后是0xAA,因此这不是Linux问题。 https://support.microsoft.com/en-us/kb/149877 The last two bytes are the boot signature. The BIOS is supposed to check that these bytes have values 0x55 and then 0xAA before loading
...
你需要乘以柱面,头部和扇区的数量,所以你会得到块的数量,乘以它的512,你就得到了答案,我认为就是这样。 You need to multiplier the number of cylinders, heads and sectors, so you'll get the number of blocks, multiplier it for 512 and you got the answer, I think that is it...
好的,您正在尝试安装整个磁盘而不是单个分区,这就是您收到错误的原因。 简而言之,您需要的命令是: mount /dev/sdb1 /mnt/usb
文件/dev/sdb将整个磁盘引用为块文件。 这包括开始时的分区表,这就是它无法找到文件系统的原因。 文件/dev/sdb1引用第一个分区,这是您的文件系统所在的分区。 从您的fdisk输出的外观来看,这不是一个ntfs分区,因为这是一个Windows文件系统,并且该分区被标记为Linux(除非您专门设置不同的东西,否则很可能会有ext4)。 要添加
...