Remote desktop
Remote desktop can be used to not only work on the remote computer, but also copy clipboard and normal files between the remote computer and your local computer
Change settings in the connection
Remote Desktop Menu
Select “More” in Local Resources
Enable Local Discs
Locate your local drives
File Explorer Sidebar
File Explorer Sidebar - detail
WSL2 current setup: Name, volumes, environments
The WSL2 for bioinformatics is available as “Ubuntu” from the Start menu
The NAS is mounted automatically when you log in to keep the C:\ drive occupation minimal
Environments
- ‘bioinfo’ activated by ‘conda activate bioinfo’ contains the tools from the biostar handbook 2nd Edition for ChIPseq
 - ‘py2’ activated by ‘conda activate py2’ contains the python version 2.7 to run the MACS tool
 
WSL2 basic interaction: get info from powershell
Check for instances human readible
wsl --list --verbose
Get the GUID identification numbers:
Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" | ForEach-Object {
    $name = (Get-ItemProperty $_.PSPath).DistributionName
    [PSCustomObject]@{
        Name = $name
        Path = $_.Name
    }
}
Use the {…} part = GUID to Find the BasePath to the distro:
Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss\<GUID>"
WSL2 basic interaction: start stop WSL2 from powershell
Start:
wsl -d Ubuntu
Stop Specfic distro:
wsl --terminate Ubuntu
Stop all WSL linked processes:
wsl --shutdown
WSL2 managment: WSL2 eating up too much space
The Ubuntu instance filled 175GB of space when trying to convert 16GB sra files to fastq using fasterq-dump
The issue seems to stem from a virtual disk of Ubuntu WSL2 instance not shrinking automatically
Shrink the volume manually
- Enable the Hyper-V stuff using <Win>+<R>
 - type ‘optionalfeatures’
 - Find Hyper V and tick it active
 - Shutdown 
wsl --shutdown - Find a path to your ext4 virtual disk (Leica one is at: “C:\WSL\Ubutnu_01\ext4.vhdx”)
 - Compress in powershell run as administrator
 
Optimize-VHD -Path "C:\WSL\Ubuntu_01\ext4.vhdx" -Mode Full
Note: Shrunk from 175GB to 50GB when tried first
WSL2 managment: Put a new instance on an SSD
- in powershell: 
wsl --export Ubuntu E:\ubuntu_backup03.tarNote: Ubuntu is my distribution name, yours can be different - In case you want to transfer the instance unregister the old vesrsion 
wsl --unregister Ubuntu, in case you want to make new one no need to do it wsl --import Ubuntu_biouser_new G:\WSL\ E:\ubuntu_backup03.tar --version 2- For the speed, nee do to this on an SSD, placed new 256GB SSD in the lowest SATA slot in Leica Comp
 
WSL2 managment: Restrict memory CPU and SWAP (not tested yet)
C:\Users\<YourUsername>\.wslconfig
[wsl2]
memory=4GB
processors=4
swap=0
WSL2 managment: Automatic mounting of NAS
1. Install cifs-utils
sudo apt update
sudo apt install cifs-utils
2. Check presence of the network drive
When you map network drive in windows the server name and folder is specified as: \\server\folder
ping server
get the IP-address in format: IIII.JJJJ.KKKK.LLLL
3. Mount manually
sudo mount -t cifs //IP-address/folder /mnt/share \
  -o user=user,password=password,uid=$(id -u),gid=$(id -g),vers=2.1
set user and password to real username and real password
4. Auto-mount credentials
vim ~/.smbcredentials
in there:
username=username
password=password
“secure” it:
chmod 600 ~/.smbcredentials
5. Auto-mount script
mkdir -p ~/.scripts
vim ~/.scripts/mount-share.sh
Paste inside:
#!/bin/bash
MOUNTPOINT="/mnt/share"
SHARE="//IP-address/folder"
if ! mountpoint -q "$MOUNTPOINT"; then
  sudo mount -t cifs $SHARE $MOUNTPOINT \
    -o credentials=$HOME/.smbcredentials,uid=$(id -u),gid=$(id -g),vers=2.1
fi
6. Auto-mount execution when .bashrc is sourced
Make script executable:
chmod +x ~/.scripts/mount-share.sh
Add to .bashrc
echo "bash ~/.scripts/mount-share.sh &" >> ~/.bashrc
7. Mount the drive with an automatic log-in
Change the permissions:
sudo visudo
Add following to the end of the file:
# do an automatic mount of the NAS
<user-name> ALL=(ALL) NOPASSWD: /sbin/mount.cifs, /bin/mount