CHKDSK:如何在Windows 10中检查和修复硬盘驱动器错误?

时间:2020-01-09 10:47:00  来源:igfitidea点击:

CHKDSK.exe(检查磁盘)是经典的内置Windows工具,用于检查硬盘驱动器是否存在错误。 chkdsk允许我们检查磁盘和文件系统是否存在物理和逻辑错误,查找坏扇区并修复发现的问题。在本文中,我们将详细介绍在Windows 10中使用chkdsk工具的细节,以及使用Repair-VolumePowerShell cmdlet检查磁盘的方法。

Windows 10中的chkdsk允许我们检查和修复具有NTFS和FAT32文件系统的硬盘。 Chkdsk不适用于ReFS卷,因为它们使用不同的数据完整性技术。

如何在Windows 10上使用CHKDSK检查磁盘中的错误?

要检查硬盘驱动器是否有错误,请运行提升权限的命令提示符(具有管理员权限)。然后,运行命令:

chkdsk E: /F /R

该命令将开始检查E:\驱动器,发现的错误将自动修复(/ F),如果扇区损坏,将尝试恢复数据(/ R)。全盘检查可能需要很长时间,具体取决于存储容量和文件数量。

chkdsk工具执行四个顺序遍历以检查卷元数据:

  • 第一阶段验证文件;
  • 第二阶段验证指标;
  • 第三阶段验证安全描述符;
  • 第4阶段,验证Usn期刊和行业。

完成磁盘检查后,我们将看到详细的磁盘统计信息,有关坏扇区和文件的信息,以及恢复数据所采取的步骤。

如果chkdsk实用程序没有发现问题,将显示以下消息:

Windows has scanned the file system and found no problems.No further action is required.

我们将无法执行在线扫描并修复系统驱动器(C:\)上的错误。当我们运行

chkdsk C:/F/R

命令,我们将看到该磁盘已锁定,并且只能在下次Windows重新启动时进行检查:

无法锁定当前驱动器。Chkdsk无法运行,因为另一个进程正在使用该卷。是否计划在下次系统重新启动时检查该卷?(是/否)。
Cannot lock current drive. Chkdsk cannot run because the volume is in use by another process.  Would you like to schedule this volume to be checked the next time the system restarts? (Y/N).

如果要在下次启动时检查磁盘,请按Y-> Enter

。出现消息,下次系统重启时将检查该卷。

现在,如果我们重新启动Windows,将开始磁盘检查。我们需要等待直到结束。

如果要离线检查驱动器是否有错误(跳过在线检查),请使用" offlinescanandfix"选项:

chkdsk E: /f /offlinescanandfix

当对系统驱动器使用offlinescanandfix选项时,系统将提示我们安排在下次重新引导时进行驱动器扫描。

与以前的OS版本相比,Windows 10中的脱机磁盘检查速度已大大提高。

/ X是另一个有用的chkdsk选项。它允许我们通过强制关闭所有打开的文件描述符来卸载卷,然后再进行检查。

还要注意新的chkdsk选项

/spotfix

。此参数仅适用于NTFS卷。 spotfix参数可以将脱机磁盘检查时间从几小时减少到几秒钟。它不会搜索并修复先前记录在$corrupt文件中的错误,而不是对整个驱动器进行扫描(在正常磁盘检查期间填充)。在这种情况下,chkdsk可以立即修复错误,而不会浪费时间扫描整个驱动器。这在检查大容量时特别有用。

不建议取消/中断chkdsk命令。但是,如果我们手动终止chkdsk.exe进程,则不会损坏该卷(该损坏不会超过原始损坏)。无论如何,建议过一会儿再进行全盘扫描。

在Windows 10中,磁盘维护(检查和碎片整理)将按计划或者在计算机空闲时自动执行。我们可以在"控制面板"->"系统和安全性"->"安全性和维护"->"驱动器状态"中找到有关自动磁盘检查状态的信息。屏幕截图显示了驱动器状态

All drives are working properly

我们可以在任务计划程序-> Microsoft-> Windows-> Chkdsk中找到作为Windows 10自动维护的一部分运行的磁盘检查任务(名为" ProactiveScan")。

同样,在现代Windows 10版本中,添加了存储诊断工具StorDiag.exe(存储诊断工具)。该实用程序一次执行多个磁盘检查操作(

chkdsk

fsutil

fltmc

)。诊断日志可以另存为ETW跟踪。例如:

stordiag.exe -collectEtw -checkfsconsistency -out %userprofile%\desktop

使用PowerShell检查驱动器错误

PowerShell 4.0引入了单独的"修复卷"磁盘检查cmdlet。此cmdlet是chkdsk命令的PowerShell替换。

要从PowerShell在线检查硬盘驱动器是否有错误,请运行以下命令:

Repair-Volume –driveletter C –scan

如果我们需要执行离线磁盘检查并自动修复错误,请使用offlinescanandfix参数:

Repair-Volume –driveletter E –offlinescanandfix

如果在磁盘上未发现错误,我们将看到一个

NoErrorsFound

信息。

它还支持使用spotfix参数进行快速错误修复(仅修复在线扫描期间发现的错误):

Repair-volume –driveletter E –spotfix

我们可以一次检查多个本地驱动器:

Repair-Volume -DriveLetter EHI –SpotFix

Repair-Volume cmdlet支持CIM会话,使我们可以扫描远程计算机上的驱动器:

Repair-Volume –driverletter c -scan –cimsession ny-fs01,ny-fs02,ny-dc01

我们还可以使用Storage PowerShell模块中的cmdlet检查硬盘驱动器的SMART状态:

Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType,SpindleSpeed, HealthStatus, OperationalStatus -AutoSize

在Windows 10中查看检查磁盘(CHKDSK)结果

执行联机磁盘检查时,我们可以在cli控制台中查看完整的chkdsk统计信息。但是,如果计划使用offlinescanandfix选项进行磁盘检查,则Windows引导屏幕上不会显示chkdsk摘要报告。 Windows 10引导屏幕仅显示已完成磁盘检查的总体百分比。

在Windows 7和早期Windows版本中,有关chkdsk操作的详细信息直接显示在启动屏幕上。

在Windows 10中,我们只能在Windows Event Viewer中查看自动硬盘检查的结果。

通过在搜索栏中键入"事件"来打开Windows事件查看器,然后选择"事件查看器"应用程序(或者通过运行

Eventvwr.msc

命令)。

在下一个窗口中,转到" Windows日志"->"应用程序"。

右键单击"应用程序",然后选择"查找"菜单项。在搜索栏中,键入" chkdsk",然后单击"查找下一个"。

我们可以按事件源进行搜索。要在Windows启动时搜索磁盘检查事件,我们需要启用" Wininit"源中的事件过滤器。有关用户启动的检查磁盘事件,请参见Chkdsk源。

必须显示第一个带有事件ID 1001和源Wininit的事件。在"常规"标签中,将显示详细的日志以及最新磁盘检查的结果。

Checking file system on C:
The type of the file system is NTFS.
A disk check has been scheduled.
Windows will now check the disk.
Stage 1: Examining basic file system structure ...
122280 file records processed.                                                         File verification completed.
4817 large file records processed.                                     0 bad file records processed.
Stage 2: Examining file name linkage ...
184654 index entries processed.                                                       Index verification completed.
0 unindexed files scanned.                                           0 unindexed files recovered to lost and found.
Stage 3: Examining security descriptors ...
Cleaning up 788 unused index entries from index $SII of file 0x9.
Cleaning up 788 unused index entries from index $SDH of file 0x9.
Cleaning up 788 unused security descriptors.
Security descriptor verification completed.
27477 data files processed.                                           CHKDSK is verifying Usn Journal...
36724460 USN bytes processed.                                                          Usn Journal verification completed.
Stage 4: Looking for bad clusters in user file data ...
12280 files processed.                                                               File data verification completed.
Stage 5: Looking for bad, free clusters ...
6433211 free clusters processed.                                                       Free space verification is complete.
CHKDSK discovered free space marked as allocated in the volume bitmap.
Windows has made corrections to the file system.
No further action is required.
41423341 KB total disk space.
15155466 KB in 90632 files.
75328 KB in 27779 indexes.
0 KB in bad sectors.
223839 KB in use by the system.
55762 KB occupied by the log file.
25979887 KB available on disk.
4096 bytes in each allocation unit.
10354722 total allocation units on disk.
6493022 allocation units available on disk.
Internal Info:
00 f9 01 00 88 cd 01 00 a9 dd 03 00 00 00 00 00 ................
ad 00 00 00 66 00 00 00 00 00 00 00 00 00 00 00 ....f...........
Windows has finished checking your disk.
Please wait while your computer restarts.

我们可以使用PowerShell从检查磁盘事件中获取信息。以下命令将从事件日志中导出5个最新的磁盘检查结果,并将它们保存为文本文件CHKDSK_SCANS.txt到当前桌面。

Get-EventLog -LogName Application -Source chkdsk | Select-Object -Last 5 -Property TimeGenerated,Message | Format-Table -Wrap| out-file "$env:userprofile\Desktop\CHKDSK_SCANS.txt"

可以在任何文本编辑器中打开此文件。

因此,我们在Windows 10启动期间执行了磁盘检查日志。