Before shrinking a WSL2 virtual disk, you need to ensure that WSL2 is not running.
You can check if it’s running with the command wsl.exe --list --verbose in PowerShell:
PS C:\Users\valorin> wsl.exe --list --verbose
 NAME STATE VERSION| #!/bin/bash | |
| #install oh my zsh | |
| sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
| #install zsh-autosuggestions and zsh-syntax-highlighting | |
| git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
| git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
| omz plugin enable zsh-autosuggestions zsh-syntax-highlighting sudo git ssh-agent | 
| [/layers/paketo-buildpacks_native-image/native-image/ru.diasoft.micro.Application:165] setup: 512.83 ms, 3.66 GB | |
| [INFO] [creator] Error: The class sun.instrument.InstrumentationImpl has already been initialized (from file:///workspace/META-INF/native-image/ru.diasoft.micro/dqpmsgb/native-image.properties with 'sun.instrument.InstrumentationImpl'); it is too late to register sun.instrument.InstrumentationImpl for build-time initialization. To see why sun.instrument.InstrumentationImpl got initialized use --trace-class-initialization=sun.instrument.InstrumentationImpl | |
| [INFO] [creator] com.oracle.svm.core.util.UserError$UserException: The class sun.instrument.InstrumentationImpl has already been initialized (from file:///workspace/META-INF/native-image/ru.diasoft.micro/dqpmsgb/native-image.properties with 'sun.instrument.InstrumentationImpl'); it is too late to register sun.instrument.InstrumentationImpl for build-time initialization. To see why sun.instrument.InstrumentationImpl got | 
| --- | |
| version: '3.5' | |
| networks: | |
| default: | |
| name: kafka-net | |
| services: | |
| zookeeper: | |
| image: confluentinc/cp-zookeeper:4.1.1 | |
| hostname: zookeeper |