CHKDSK.exe (check disk) là công cụ tích hợp Windows kinh điển để kiểm tra ổ cứng lỗi. Chkdsk cho phép kiểm tra ổ đĩa và hệ thống file lỗi vật lý và logic, tìm bad sector và sửa vấn đề tìm thấy. Trong bài này, chúng ta sẽ xem chi tiết dùng chkdsk trong Windows 10, cũng như cách kiểm tra đĩa dùng cmdlet PowerShell Repair-Volume.
Chkdsk trong Windows 10 cho phép kiểm tra và sửa ổ cứng với hệ thống file NTFS và FAT32. Chkdsk không áp dụng cho volume ReFS vì chúng dùng công nghệ toàn vẹn dữ liệu khác.
Cách Kiểm Tra Đĩa Lỗi Dùng CHKDSK Trên Windows 10?
Để kiểm tra ổ cứng lỗi, chạy command prompt quyền cao (administrator). Sau đó chạy lệnh:
chkdsk E: /F /R
Lệnh này sẽ bắt đầu kiểm tra ổ E:\, lỗi tìm thấy sẽ tự động sửa (/F), nếu có bad sector, sẽ cố gắng khôi phục dữ liệu (/R). Kiểm tra đĩa đầy đủ có thể mất nhiều thời gian tùy dung lượng lưu trữ và số file.
Công cụ chkdsk thực hiện 4 giai đoạn tuần tự kiểm tra metadata volume:
- Giai đoạn 1 – verifying files;
- Giai đoạn 2 – verifying indexes;
- Giai đoạn 3 – verifying security descriptors;
- Giai đoạn 4 – verifying Usn Journal và sector.
Sau khi hoàn tất kiểm tra đĩa, bạn sẽ thấy thống kê chi tiết ổ đĩa, thông tin về bad sector và file, cũng như các bước khôi phục dữ liệu.
Nếu chkdsk không tìm thấy vấn đề, thông báo sau xuất hiện:
Windows has scanned the file system and found no problems. No further action is required.

Bạn không thể thực hiện quét online và sửa lỗi trên ổ hệ thống (C:\). Khi chạy lệnh chkdsk C: / F / R, bạn sẽ thấy đĩa bị khóa và chỉ có thể kiểm tra ở lần khởi động Windows tiếp theo:
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).

Nếu muốn kiểm tra đĩa ở lần boot tiếp theo, nhấn Y -> Enter. Thông báo "This volume will be checked the next time the system restarts" xuất hiện.
Bây giờ, nếu bạn restart Windows, kiểm tra đĩa sẽ bắt đầu. Bạn cần đợi đến khi kết thúc.
Nếu muốn kiểm tra ổ đĩa lỗi offline (bỏ qua kiểm tra online), dùng tùy chọn offlinescanandfix:
chkdsk E: /f /offlinescanandfix
Khi dùng offlinescanandfix cho ổ hệ thống, bạn sẽ được nhắc lên lịch quét ổ ở lần reboot tiếp theo.
Tốc độ kiểm tra đĩa offline trong Windows 10 tăng đáng kể so với phiên bản OS trước.
/X là tùy chọn chkdsk hữu ích khác. Nó cho phép unmount volume trước khi kiểm tra bằng cách ép đóng tất cả file descriptor mở.
Cũng lưu ý tùy chọn chkdsk mới – /spotfix. Tham số này chỉ áp dụng cho volume NTFS. Tham số spotfix có thể giảm đáng kể thời gian kiểm tra đĩa offline từ giờ xuống giây. Thay vì quét toàn bộ ổ đĩa, nó chỉ tìm và sửa lỗi đã ghi trước trong file $corrupt (điền trong kiểm tra đĩa bình thường). Trong trường hợp này, chkdsk sửa lỗi ngay lập tức mà không lãng phí thời gian quét toàn bộ ổ. Điều này đặc biệt hữu ích khi kiểm tra volume lớn.
Không khuyến khích hủy/ngắt lệnh chkdsk. Tuy nhiên, nếu bạn kill thủ công process chkdsk.exe, bạn sẽ không hỏng volume (nó sẽ không hỏng hơn trạng thái ban đầu). Trong mọi trường hợp, khuyến nghị chạy quét đĩa đầy đủ sau một thời gian.
Trong Windows 10, bảo trì đĩa (kiểm tra và defragment) được thực hiện tự động theo lịch trình hoặc khi máy tính rảnh. Bạn có thể tìm thông tin trạng thái kiểm tra đĩa tự động trong Control Panel -> System and Security -> Security and Maintenance -> Drive status. Ảnh chụp màn hình hiển thị trạng thái ổ đĩa "All drives are working properly".

Bạn có thể tìm task kiểm tra đĩa (tên ProactiveScan), chạy như một phần của Windows 10 Automatic Maintenance, trong Task Scheduler -> Microsoft -> Windows -> Chkdsk.
Cũng, trong các build Windows 10 hiện đại, công cụ chẩn đoán lưu trữ StorDiag.exe (Storage Diagnostic Tool) đã được thêm. Tiện ích này thực hiện một số thao tác kiểm tra đĩa cùng lúc (chkdsk, fsutil và fltmc). Log chẩn đoán có thể lưu dưới dạng ETW trace. Ví dụ:
stordiag.exe -collectEtw -checkfsconsistency -out %userprofile%\desktop
Kiểm Tra Lỗi Ổ Đĩa Với PowerShell
PowerShell 4.0 giới thiệu cmdlet kiểm tra đĩa riêng Repair-Volume. Cmdlet này là thay thế PowerShell cho lệnh chkdsk.
Để thực hiện kiểm tra online ổ cứng lỗi từ PowerShell, chạy lệnh:
Repair-Volume –driveletter C –scan
Nếu cần kiểm tra đĩa offline và tự động sửa lỗi, dùng tham số offlinescanandfix:
Repair-Volume –driveletter E –offlinescanandfix
Nếu không tìm thấy lỗi trên đĩa, bạn sẽ thấy thông báo NoErrorsFound.

Nó cũng hỗ trợ sửa lỗi nhanh dùng tham số spotfix (chỉ sửa lỗi tìm thấy trong quét online):
Repair-volume –driveletter E –spotfix
Bạn có thể kiểm tra nhiều ổ cục bộ cùng lúc:
Repair-Volume -DriveLetter EHI –SpotFix
Cmdlet Repair-Volume hỗ trợ CIM session cho phép quét ổ đĩa trên máy tính từ xa:
Repair-Volume –driverletter c -scan –cimsession ny-fs01,ny-fs02,ny-dc01
Bạn cũng có thể kiểm tra trạng thái SMART ổ cứng dùng cmdlet từ module Storage PowerShell:
Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType,SpindleSpeed, HealthStatus, OperationalStatus -AutoSize

Xem Kết Quả Kiểm Tra Đĩa (CHKDSK) Trong Windows 10
Khi thực hiện kiểm tra đĩa online, bạn thấy thống kê chkdsk đầy đủ trong console cli. Tuy nhiên, nếu bạn lên lịch kiểm tra đĩa với tùy chọn offlinescanandfix, bạn sẽ không thấy báo cáo tóm tắt chkdsk trên màn hình boot Windows 10. Màn hình boot Windows 10 chỉ hiển thị phần trăm tổng thể hoàn thành kiểm tra đĩa.
Trong Windows 7 và các phiên bản Windows trước, thông tin chi tiết về hành động chkdsk hiển thị trực tiếp trên màn hình boot.

Trong Windows 10 bạn chỉ có thể xem kết quả kiểm tra đĩa tự động trong Windows Event Viewer.
Mở Windows Event Viewer bằng cách gõ event trong thanh tìm kiếm và chọn ứng dụng Event Viewer (hoặc chạy lệnh Eventvwr.msc).

Trong cửa sổ tiếp theo, đi đến Windows Logs -> Application.

Chuột phải Application và chọn menu Find. Trong thanh tìm kiếm, gõ chkdsk và nhấn Find next.
Bạn có thể tìm theo event source. Để tìm sự kiện kiểm tra đĩa khi khởi động Windows, bạn cần bật filter theo sự kiện từ source Wininit. Đối với sự kiện check disk do người dùng khởi tạo, xem source Chkdsk.

Sự kiện đầu tiên tìm thấy với Event ID 1001 và source Wininit phải hiển thị. Trong tab General, log chi tiết với kết quả kiểm tra đĩa mới nhất sẽ hiển thị.

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.
Bạn có thể lấy thông tin từ sự kiện kiểm tra đĩa dùng PowerShell. Lệnh sau sẽ xuất 5 kết quả kiểm tra đĩa gần nhất từ event log và lưu vào desktop hiện tại dưới dạng file text 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"
File này có thể mở trong bất kỳ trình soạn thảo văn bản nào.

Vậy chúng ta đã có log kiểm tra đĩa thực hiện khi khởi động Windows 10.