bughelp wanted
Repository metrics
- Stars
- (0 stars)
- PR merge metrics
- (PR metrics pending)
Description
Windows Subsystem for Linux, WSL 2
Surge in Disk IO, stuck in a freeze response
Sometimes (in the shell or vim) the system suffers not responsiveness for a few seconds, and it is the point when the IO of the disk that wsl was installed goes to the peak. (Apr.11,2025)
This issue is likely caused by high disk I/O operations in your WSL environment, which can lead to temporary unresponsiveness. Here are some common reasons and solutions:
- Windows File System Access
- WSL2 has slower performance when accessing files in the Windows file system () compared to the Linux file system. If your project or files are stored in , this could be the bottleneck.
- Solution: Move your project files to the Linux file system (e.g., ) for faster access.
- Resource Allocation
- WSL2 uses virtualized resources, and if the disk or memory allocation is insufficient, it can cause peak loads
- Solution: Configure resource limits in the file. Create or edit with the following:
# ~/.wslconfig
[wsl2]
memory=8GB
processors=4
swap=2GB
kernelCommandLine=sysctl.vm.swappiness=10
Save the file and restart WSL with: wsl --shutdown
- Background Processes
- Background processes like Docker containers or heavy builds can spike disk usage.
- Solution: Monitor running processes using
htoporiotopin WSL to identify the culprit.
- Disk Fragmentation
- If the disk where WSL is installed is heavily fragmented, it can slow down I/O operations.
- Solution: Run disk optimization tools in Windows to defragment the disk. ⇒ SSDがexFATのフォーマットのため、ディスク最適化は不可。NTFSに変えるべきか?
- WSL Version or Updates
- Some WSL versions or updates may introduce performance issues.
- Solution: Ensure you are using the latest version of WSL. Update it with:
wsl --update
- Check Disk Usage
- Use tools like
df -hordu -shin WSL to check disk usage and ensure you have sufficient free space.
Running WSL2 on an exFAT-formatted SSD can contribute to IO peak issues. Here's why: Why exFAT Might Be the Cause
- Lack of Journaling: Unlike NTFS, exFAT does not support journaling, which can lead to slower performance during heavy IO operations.
- Optimization for Flash Storage: exFAT is designed for removable storage like USB drives and SD cards, not for high-performance internal drives.
- TRIM Support: NTFS has better TRIM support for SSDs, which helps maintain performance over time. exFAT's TRIM support is less robust.
Why NTFS is Better for WSL2
- Performance: NTFS is optimized for internal drives and handles random read/write operations more efficiently
- Compatibility: NTFS integrates better with Windows features, including WSL2, and supports advanced file system features like compression and encryption.
- Reliability: NTFS is more reliable for sustained workloads due to its journaling capabilities.
Should You Reformat to NTFS? If your SSD is primarily used for WSL2 and Windows, reformatting to NTFS is highly recommended.
対策
- SSDのD:からext4.vhdxファイルのバックアップを取り、D:ドライブをNTFSでフォーマット。ext4.vhdxファイルを元の位置に戻してUnbuntuを再起動。(Apr.11,2025) ⇒ 停滞の発生頻度が減ったが完全には治ってない。
- D:ドライブにもsystem paging fileを指定(Win+R: sysdm.cpl → System Properties → Advanced → Performance)