Computer >> Hướng Dẫn Máy Tính >  >> Hệ Thống >> Windows 10

Sử dụng Unified Write Filter (UWF) trên Windows 10

UWF (Unified Write Filter) là bộ lọc ghi hệ thống file đặc biệt trong Windows 10 cho phép bảo vệ file hệ thống và user trên ổ cục bộ khỏi bất kỳ thay đổi nào. Khi UWF bật, mọi thao tác ghi vào ổ được bảo vệ hoặc registry hệ thống bị chặn bởi driver UWF và đặt vào không gian ảo riêng (overlay). Sau khởi động lại Windows, tất cả thay đổi trên ổ bảo vệ không lưu, tức Windows luôn quay về trạng thái gốc khi UWF bật.

UWF hoạt động thế nào? Nó bảo vệ hệ thống file các phân vùng được chọn trên ổ cục bộ khỏi thay đổi bằng cách chuyển hướng minh bạch mọi thao tác ghi hệ thống file vào overlay ảo nơi lưu tất cả thay đổi.

Lưu ý. Trước đây, write filter chỉ có trong phiên bản Embedded, dùng trong ATM, POS, kiosk, terminal tự phục vụ, hệ thống công nghiệp, v.v. Giờ tính năng này có trong Windows 10 Enterprise (kể cả LTSB/LTSC) và Windows 10 Education. Mở thêm kịch bản dùng Windows trong doanh nghiệp và giáo dục (kiosk thông tin, phòng học, demo stand, v.v.).

Cách bật và cấu hình Unified Write Filter trên Windows 10

UWF là tính năng Windows riêng bật qua Control Panel → Programs and Features → Turn Windows Features On or Off → Device Lockdown → Unified Write Filter.

Tính năng UWF cũng cài bằng PowerShell:

Enable-WindowsOptionalFeature -Online -FeatureName "Client-UnifiedWriteFilter" –All

Hoặc DISM:

DISM.exe /Online /enable-Feature /FeatureName:client-UnifiedWriteFilter

Công cụ console uwfmgr.exe dùng quản lý cài đặt UWF.

Để bật UWF trên Windows 10, chạy lệnh và reboot:

uwfmgr.exe filter enable

Sau bật UWF, nó tự cấu hình lại hệ thống loại trừ thao tác ghi ổ không cần thiết (page file, restore point, file indexing, defrag bị tắt).

Để bật bảo vệ ghi cho ổ cụ thể, chạy:

uwfmgr.exe volume protect c:

Khởi động lại máy. Sau reboot, mọi thứ user ghi trên ổ trong phiên chỉ có hiệu lực cho đến reboot tiếp theo. Mọi thay đổi bị hủy.

Kiểm tra trạng thái UWF:

uwfmgr.exe get-config

Trong ví dụ thấy ổ hệ thống được bảo vệ, UWF bật (Volume state: Protected).

Cài đặt overlay hiện tại lưu dữ liệu tạm UWF hiển thị bằng:

uwfmgr overlay get-config

Bạn cấu hình tham số UWF overlay sau:

  • Type – loại overlay. Lưu dữ liệu trên disk (DISK) hoặc RAM;
  • Maximum size – dung lượng overlay tối đa;
  • Warning Threshold – dung lượng overlay, vượt qua sẽ cảnh báo;
  • Critical Threshold – dung lượng overlay, vượt qua báo lỗi UWF;
  • Freespace Passthrough – chỉ dùng chế độ disk overlay. Cho ghi dữ liệu vào bất kỳ không gian trống trên ổ, không phải file đặc biệt.

Mặc định overlay 1 GB RAM.

Thay đổi cài đặt overlay (nếu đủ RAM trống):

uwfmgr overlay set-size 8192
uwfmgr overlay set-criticalthreshold 8192
uwfmgr overlay set-warningthreshold 7168

Nếu cần overlay DISK, chạy:

uwfmgr overlay set-type Disk

Kích thước dữ liệu hiện tại trong overlay:

uwfmgr overlay get-consumption

Không gian trống còn lại:

uwfmgr overlay get-availablespace

Bảo trì Unified Write Filter trên Windows 10

Khi thực hiện bảo trì hệ thống (cài update, cập nhật signature antivirus), cần đưa thiết bị Windows vào chế độ UWF servicing đặc biệt:

uwfmgr servicing enable

Sau reboot, Windows boot dưới tài khoản cục bộ UWF-Servicing và tự cài Windows update (qua Windows Update hoặc WSUS approved), cập nhật signature antivirus. Nếu muốn, đăng nhập tài khoản UWF-Servicing (mật khẩu không biết, nhưng có thể reset).

Sau khi user UWF-Servicing tự đăng nhập, công cụ uwfservicingshell.exe chạy script bảo trì Windows 10. Không thể làm gì khác ở chế độ service.

Sau cài update, máy tự reboot về chế độ bình thường với UWF bật.

Cũng cài Windows update không vào Servicing mode. Dùng lệnh:

uwfmgr servicing update-windows
Unified Write Filter updated Windows result: REBOOT REQUIRED.

Thêm ngoại lệ Unified Write Filter trên Windows 10

Nếu cần ép file sửa đổi lưu xuống ổ khi UWF bật, chạy:

uwfmgr file commit C:\Labs\MyApp.exe

File này không bị xóa dù reboot Windows.

Để xóa hoàn toàn file với UWF bật:

uwfmgr file commit-delete C:\Labs\MyApp.exe

Lệnh UWF tương tự cho registry:

uwfmgr registry commit ...
uwfmgr registry commit-delete ...

Bạn thêm file, thư mục hoặc khóa registry cụ thể vào danh sách ngoại lệ UWF. Thay đổi trên các mục này ghi trực tiếp lên ổ, không vào overlay.

Thêm file/thư mục vào ngoại lệ:

Uwfmgr.exe file add-exclusion c:\labs

Hoặc:

Uwfmgr.exe file add-exclusion c:\labs\report.docx

Thêm ngoại lệ khóa registry:

Uwfmgr.exe registry add-exclusion “HKLM\Software\My_RegKey”

Phải reboot để áp dụng danh sách ngoại lệ mới.

Liệt kê ngoại lệ UWF:

uwfmgr file get-exclusions

Xóa file khỏi ngoại lệ:

uwfmgr file remove-exclusion c:\student\report.docx

Không thể thêm ngoại lệ cho một số file/thư mục hệ thống:

  • File registry trong \Windows\System32\config\;
  • Root của các volume;
  • \Windows, \Windows\System32, \Windows\System32\Drivers;
  • Pagefile.sys, swapfile.sys;
  • V.v.

Lưu ý. UWF không bảo vệ dữ liệu trên flash drive và USB ngoài. Việc bật write filter cho Removable disk type dường như không hỗ trợ ở mức phần mềm. Tuy nhiên, bạn có thể vượt qua hạn chế này với thủ thuật từ bài "Removable USB drive as fixed disk in Windows".

Để một số dịch vụ hoạt động đúng, phải thêm đường dẫn thư mục, file và khóa registry vào danh sách ngoại lệ. Tôi tổng hợp ngoại lệ điển hình cho một số subsystem Windows:

Ngoại lệ cho BITS:

  • % ALLUSERSPROFILE%\Microsoft\Network\Downloader
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\BITS\StateIndex

Ngoại lệ cho hoạt động đúng mạng không dây (ngoại lệ này cho kết nối Wi-Fi và lưu profile WLAN):

  • HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Wireless\GPTWirelessPolicy
  • C:\Windows\wlansvc\Policies
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\wlansvc
  • C:\ProgramData\Microsoft\wlansvc\Profiles\Interfaces\{<Interface GUID>}\{<Profile GUID>}.xml
  • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Wlansvc
  • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WwanSvc

Ngoại lệ cho hoạt động đúng mạng dây:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WiredL2\GP_Policy
  • C:\Windows\dot2svc\Policies
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\dot3svc
  • C:\ProgramData\Microsoft\dot3svc\Profiles\Interfaces\{<Interface GUID>}\{<Profile GUID>}.xml
  • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\dot3svc

Ngoại lệ cho Windows Defender

  • C:\Program Files\Windows Defender
  • C:\ProgramData\Microsoft\Windows Defender
  • C:\Windows\WindowsUpdate.log
  • C:\Windows\Temp\MpCmdRun.log
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender

Cách reset hoặc tắt UWF Filter

Reset cài đặt UWF về trạng thái ban đầu (khi bật filter):

uwfmgr filter reset-settings

Tắt hoàn toàn UWF (sau reboot mọi thay đổi trên ổ lưu lại):

uwfmgr.exe filter disable

Hoặc tắt filter cho volume cụ thể:

uwfmgr.exe volume unprotect E:

Quan trọng. Nếu Windows không boot do cài đặt UWF sai, tắt filter bằng boot từ media cài/boot và sửa registry offline:

  • Tắt autostart driver UWF đổi giá trị Start thành 4 trong khóa HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\uwfvol;
  • Xóa chuỗi uwfvol trong HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{71a27cdd-812a-11d0-bec7-08002be2092f}\Lower Filters

UWF với HORM (Hibernate Once/Resume Many) trên Windows 10

Từ Windows 10 1709, chế độ UWF khác xuất hiện — Hibernate Once/Resume Many (HORM). Chế độ này cho phép nhanh chóng lấy trạng thái Windows với app chạy và file mở. Mỗi lần boot, Windows ngay lập tức về trạng thái lưu trong file hibernation.

Hạn chế HORM trên Windows 10:

  • UWF phải bật cho tất cả ổ cục bộ (fixed);
  • Ngoại lệ UWF không hỗ trợ;
  • Overlay chỉ làm việc chế độ RAM (disk-overlay không hỗ trợ);
  • Hibernation và Fast Startup bị tắt.

Bật HORM:

uwfmgr filter enable-horm
Unified Write Filter enabled HORM. Please hibernate the system to use HORM functionality. The system must be hibernated at least once after run enable-horm command, or it may bring the system into corrupted state.

Cấu hình môi trường làm việc user (chạy app cần, mở file, v.v.). Sau đó cho máy vào hibernation:

shutdown /h

Đánh thức máy và reboot. Lúc reboot sau, Windows 10 ngay lập tức khởi động ở trạng thái lưu trong file hibernation.

Tắt HORM:

uwfmgr filter disable-horm

UWF cung cấp kịch bản thú vị:

  1. Cải thiện hiệu suất Windows (không ghi gì trên ổ, mọi thao tác ghi thực hiện trong bộ nhớ, như RAM disk);
  2. Giảm hao mòn SSD/CompactFlash do ít thao tác ghi;
  3. Thử nghiệm, test phần mềm thứ ba và nghiên cứu malware (mục đích này cũng dùng Windows 10 Sandbox).