iTranslated by AI
[WSL] How to increase allocated disk space
When I tried to create a STAR index using the method introduced here, it previously succeeded, but now the same command results in an error.

Error screen
I thought it might be related to write permissions, but after looking into it, it seems to be due to disk write capacity.
https://github.com/alexdobin/STAR/issues/410
https://groups.google.com/g/rna-star/c/qkGJFlE5qh8
However, the drive where WSL is located still has plenty of free space.
Therefore, I will change the disk capacity allocated to WSL.
Procedure
1. Shut down WSL
Run wsl --shutdown in PowerShell.
(You can verify that all distributions have stopped using wsl -l -v.)
When Docker Desktop is running, wsl --shutdown might not finish properly. Right-click the Docker icon in the taskbar and exit it from the menu.
2. diskpart
Launch the Command Prompt with administrator privileges and type diskpart.
The prompt will change to "DISKPART> ".

3. Select the virtual disk file
Use the file path of the file named "ext4.vhdx". In my case, it was the following path:
select vdisk file="C:\Users\admin\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx"

4. Specify the disk allocation size
You can check the current disk allocation with the detail vdisk command.

Increase the upper limit of this virtual size.
It's stated that it's specified in MB. Change it from 1024 GB (1,024,000 MB) to 2,048,000 MB.
expand vdisk maximum=2048000
Checking the details again, the virtual size limit had increased. (It became 2,000 GB instead of 2,048 GB.)

5. Exit DiskPart
Exit DiskPart using exit.
exit

6. Configure the WSL side as well
I proceeded as introduced.
sudo mount -t devtmpfs none /dev

mount | grep ext4

In my case, it was "sdc", but this seems to change depending on the drive. It seems you should refer to the output of the previous command.
sudo resize2fs /dev/sdc 2048000M

This resolved the disk capacity error during STAR index creation.

I also tried compact vdisk, but it had no effect in my case.
https://qiita.com/siruku6/items/c91a40d460095013540d#5-diskpartを使う
[Countermeasures for when disk space is not freed even after deleting data in WSL]
Even after deleting data in WSL, for some reason, the disk capacity does not decrease. It seems that you need to manually optimize the virtual hard disk (VHD) after deleting the data.
1. Shut down WSL
2. Launch PowerShell as Administrator
3. Optimize the virtual hard disk
You will need the path to the virtual hard disk, so find it in advance. For example, it is in an obscure location like this:
"C:\Users<username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx"
Optimize-VHD -Path "C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx"
It proceeded like this and finished in a few minutes.

You should be able to confirm that the size of the "ext4.vhdx" file has decreased and the free space on the drive has increased.
Discussion