• Dataflex
  • Postgresql
  • Windows
  • Wordpress
wsl

Windows Subsystem for Linux

How to compact an overgrown disk

Overview

Overtime a WSL2 partition may grow and not be reclaimed. The following will fix that.

Process

wsl --list
wsl --terminate Debian
diskpart
select vdisk file="C:\Users\joseph\AppData\Local\Packages\Debian.16571368D6CFF_kd1vv0z0vy70w\LocalState\ext4.vhdx"
compact vdisk

WSL2 and SSH Keys between sessions

The Problem

ssh-agent is a thing we normally take for granted when using SSH on linux. We add the key, then it’s there until we restart.

When switching to WSL2 we quickly find that isn’t the case. We might first try eval $(ssh-agent -s) but that is lost every time we open a new window or tmux session. Another option is to stop using encrypted SSH keys. For those of us who prefer to keep our keys encrypted, there is a better way. We can use the keychain package to persist our SSH keys between windows and sessions.

The keychain package

Install keychain

sudo apt-get install keychain Edit your ~/.bashrc, ~/.zshrc or your choice of shell, and add the following to the bottom of your file.

# Store SSH key between sessions
/usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa
source $HOME/.keychain/$HOST-sh

This will prompt you for the key on startup if it doesn’t already exist. Adjust to suit your keys.

Get In Touch

Why partner with Digitize?

At Digitize, we are a focused team that invest constantly in improving so that we can provide the best capabilities to our clients. Our processes and teams are built around being flexible so we can deliver tailored solutions instead of trying to make existing solutions fit.

Each client has a dedicated account manager that will ensure you are always getting the best service possible.