Mike Levin SEO

Future-proof your technology-skills with Linux, Python, vim & git... and me!

← The Two Maxwell's of Light / You Can't Take It With You
Windows Symbolic Link to Map Shared Folder Location to Local Folder →

Created Windows Shortcut To Start Linux Jupyter on LXD

by Mike Levin

Tuesday, September 20, 2022

Okay, I added LXD.lnk to the WSL2LXD repo. It’s very simple:

wt PowerShell -c "wsl -d Ubuntu-18.04"

This works because when the Ubuntu 18.04 .bash_login script is:


And this is a program in /usr/local/sbin on WSL:

        lxc jupyterstart 2>/dev/null
        sleep 1
lxc exec jupyter -- su --login ubuntu

And now this is actually using the alias feature of lxc which you can see when logged into just WSL with lxc alias list. Anyway, jupyerstart is an alias for:

exec jupyter -- su --login ubuntu -c /usr/local/sbin/jupyterstart

And now there’s one more /usr/local/sbin file in the picture, but this one is under LXD and just starts the Jupyter server:

cd ~/repos
screen -wipe >/dev/null 2>&1
if ! screen -list | grep -q "jupyter"; then
    screen -dmS jupyter /home/ubuntu/py310/bin/jupyter lab --ip --port 8888 --no-browser --ServerApp.password='[long hash deleted]'
echo "Visit http://localhost:8888"

Pshwew! There’s a lot of getting around API limitations going on here by use of sbin commands. There’s a temptation to make bash script one-liners and feed them on the command-line parameters of wsl and lxd, but that generally doesn’t work. If it’s not permission problems then it’s semicolon parsing. It turns out that dropping magic little sbin commands into place and calling them on the command-line seems to always work.