#my vbox.autofs file
!cat /etc/vbox.autofs
janus -fstype=drvfs,uid=1000,gid=1000 :Z:
December 14, 2022
As an example from T15Gen2, corporate mastered.
This procedure needs admin rights on 2 steps (install nvidia drivers, activate wsl)
And if based on WSL from Windows store (wsl --version
>=1.0), lots of new features such as systemd, snap, integrated display, etc. Detailed in WSL2 from Windows Store
Just install Windows Terminal
from Windows Store at https://aka.ms/terminal
To get drivers in link to cuda versions:
https://developer.nvidia.com/cuda-toolkit-archive
(Jan-18 23: cuda 11.7.1 using cuda_11.7.1_516.94_windows.exe
)
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 516.94 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... On | 00000000:01:00.0 On | N/A |
| N/A 54C P8 18W / N/A | 274MiB / 16384MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
Download from https://cloud-images.ubuntu.com/daily/server/wsl/
This address may change (search for « cloud wsl ubuntu images »)
(Dec-22: this file ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz
)
as admin, install the driver
as admin, open windows terminal, and run
I am closely following new updates from WSL and WSLg at https://github.com/microsoft/WSL/releases
To know which version we use, run wsl --version
in Powershell.
And to upgrade to the latest version, run wsl --update --pre-release
following instructions from install ubuntu 22.04 on WSL # Automatic setup.
And here are the steps
Create 2 folders: C:\wsl\Ubuntu-22.04\download
, C:\wsl\Ubuntu-22.04\instance
Move ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz
in C:\wsl\Ubuntu-22.04\download
Copy scripts setup_wsl_root.sh
and setup_wsl_user.sh
to C:\wsl\Ubuntu-22.04\download
Copy wsl-vpnkit
to C:\wsl\Ubuntu-22.04\download
(see https://dev.michelin.com/wsl2/fundamentals for more details)
Install wsl-vpnkit from Windows Terminal:
wsl --import wsl-vpnkit $env:USERPROFILE\wsl-vpnkit C:\wsl\ubuntu-22.04\download\wsl-vpnkit.tar.gz
wsl -d wsl-vpnkit
wsl -d wsl-vpnkit service wsl-vpnkit start
If wsl-vpnkit stopped unexpectedly, check logs with wsl.exe -d wsl-vpnkit --cd /app tail -f /var/log/wsl-vpnkit.log
. If “cannot connect to host: fork/exec ./wsl-vpnkit/wsl-gvproxy.exe: exec format error” appears, apply this solution:
sudo sh -c 'echo :WSLInterop:M::MZ::/init:PF > /usr/lib/binfmt.d/WSLInterop.conf'
sudo systemctl unmask systemd-binfmt.service
sudo systemctl restart systemd-binfmt
sudo systemctl mask systemd-binfmt.service
More details at logbook Aug 23
Install ubuntu-lts from Windows Terminal:
wsl --import ubuntu-22.04 C:\wsl\ubuntu-22.04\instance C:\wsl\ubuntu-22.04\download\ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz
# close windows terminal / launch it (ubuntu-22.04 entry should be added within it)
wsl -d ubuntu-22.04 # or launch from Windows Terminal menu
cd
cp /mnt/c/wsl/Ubuntu-22.04/download/setup_wsl_* ~/
chmod +x setup_wsl_root.sh
./setup_wsl_root.sh
Provide username, password and quit session with Ctrl-D
From Windows Terminal, stop wsl with wsl -t ubuntu-22.04
, a new profile for ubuntu-22.04 should have been automatically created in Windows Terminal
Start ubuntu-22.04
by clicking the profile in Windows Terminal
Should start with something like
Step 2: accept default entries (type enter). Add the generated key to gitlab > preferences > SSH keys. And then resume.
At that stage this is a fully operating image of ubuntu (internet, apt)
If running wsl version > 1.0, you can activate systemd
Modify /etc/wsl.conf
with
And restart wsl image (wsl -t ubuntu-22.04
)
Test that it works by running
I have explained how and why to do this step at keep dotfiles in git
wget --no-check-certificate --content-disposition -O - https://raw.githubusercontent.com/castorfou/blog/master/files/setup_wsl_00_config_files_in_git.sh | bash
source ~/.bashrc
TODO: take branch name as a parameter. Meanwhile download the script and update branch name to something new
This is explained at git-credential-manager repo
wget --no-check-certificate --content-disposition -O - https://raw.githubusercontent.com/castorfou/blog/master/files/setup_wsl_06_git_credential_manager.sh | bash
You need to create a personal access token in github.
And when pushing to a github repo, use this token as the password
Because I keep secured data within my secured disks mounted in windows (Z:, Y:, …)
wget --no-check-certificate --content-disposition -O - https://raw.githubusercontent.com/castorfou/blog/master/files/setup_wsl_01_automount_secured_vbox.sh | bash
Modify /etc/vbox.autofs
to match your actual mounted disks. sudo service autofs start
to start the service.
if it fails, check that kernel is at least v5. uname -a
. If not maybe in WSL 1 insted of WSL 2? (sudo automount -f -v
should provide more information)
if systemd
is activated, we can manage services with journalctl
#restart autofs
sudo systemctl restart autofs.service
#read logs for autofs (-r: display last entries first)
#to use it as user, add your user to adm group
#sudo usermod -a -G adm <your_username>
journalctl -r -u autofs
#print warning
journalctl -r -p warning
other examples with journalctl:
https://www.geeksforgeeks.org/journalctl-command-in-linux-with-examples/
Give a look to script sources
# install miniconda
wget --no-check-certificate --content-disposition -O - https://raw.githubusercontent.com/castorfou/blog/master/files/setup_wsl_02_install_python_conda_part1.sh | bash
source ~/.bashrc
# install mamba
wget --no-check-certificate --content-disposition -O - https://raw.githubusercontent.com/castorfou/blog/master/files/setup_wsl_02_install_python_conda_part2.sh | bash
source ~/.bashrc
# install certificates for Python
wget --no-check-certificate --content-disposition -O - https://raw.githubusercontent.com/castorfou/blog/master/files/setup_wsl_02_install_python_conda_part3.sh | bash
source ~/.bashrc
# create base_jupyter environment
wget --no-check-certificate --content-disposition -O - https://raw.githubusercontent.com/castorfou/blog/master/files/setup_wsl_02_install_python_conda_part4.sh | bash
source ~/.bashrc
Give a look to script sources
In order to preserve base environment, I won’t install anything in it.
I will create a base_jupyter_v4
env with what is needed for running jupyter lab. And create a jupyterlab service to automatically start jupyter lab with my distro (and stop/restart it)
base_jupyter_v4
mamba remove --name base_jupyter_v4 --all
mamba create -n base_jupyter_v4 --override-channels --strict-channel-priority -c conda-forge -c nodefaults jupyterlab ipywidgets tqdm nb_conda_kernels python==3.11 --yes
mamba activate base_jupyter_v4
clean directories: .jupyter and .local/share/jupyter
and launch with jupyter lab
mamba install -y -c conda-forge -c plotly jupyter-dash
mamba install -y -c conda-forge jupyterlab_execute_time pyviz_comms
# for nbdev
pip install jupyterlab-quarto
#in case of jupyterlab new version
mamba update --strict-channel-priority -c conda-forge -c nodefaults jupyterlab
From security in jupyter server
If a generated token doesn’t work well for you, you can set a password for your notebook.
jupyter notebook password
will prompt you for a password, and store the hashed password in yourjupyter_notebook_config.json
.
I now use service as user (you may have to activate it by calling loginctl enable-linger guillaume
)
Service files are in ~/.config/systemd/user
And here is jupyter.service
[Unit]
Description=Jupyter Notebook
After=network.target
[Service]
Type=simple
PIDFile=/run/jupyter.pid
1Environment="LD_LIBRARY_PATH=/usr/lib/wsl/lib"
ExecStart=/home/guillaume/bin/jupyterlab
#User=guillaume
#Group=guillaume
Restart=always
RestartSec=10
[Install]
WantedBy=default.target
#!/bin/bash
cd ~
source ~/miniconda/etc/profile.d/conda.sh
conda activate base_jupyter_v4
export BROWSER=chrome.exe
jupyter lab
Then enable this service
chmod +x /home/guillaume/bin/jupyterlab
systemctl --user daemon-reload
systemctl --user enable jupyter.service
systemctl --user start jupyter.service
and to monitor logs of this service
Just pointing to http://localhost:8888/lab
If a generated token doesn’t work well for you, you can set a password for your server.
jupyter server password
will prompt you for a password, and store the hashed password in your jupyter_server_config.json
.
In case of update detected in jupyter lab version.
Here is my procedure.
following https://medium.com/@satriajanaka09/setup-zsh-oh-my-zsh-powerlevel10k-on-ubuntu-20-04-c4a4052508fd
Install zsh
Some settings to be set to start wsl-vpnkit
with my user with zsh.
Here I have to restart ubuntu and wsl-vpnkit
. (from powershell wsl --shutdown
) and check network is fine (e.g. wget https://wwww.google.com
)
Install oh-my-zsh
Switch to other theme - agnoster Change ZSH_THEME=“agnoster” And apply change exec zsh
Install fonts
Load bash aliases
Update PATH and other variables
tee -a ~/.zshrc << EOF
export OPENSSL_CONF=/etc/ssl/openssl.cnf
sudo /usr/sbin/service autofs start
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
export SSL_CERT_FILE=/home/guillaume/miniconda/lib/python3.9/site-packages/certifi/cacert.pem
export BROWSER='chrome.exe'
export PATH=$PATH:"/mnt/c/Program Files/Google/Chrome/Application:/home/guillaume/miniconda/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files (x86)/Java/jre8/bin:/mnt/c/ProgramData/Oracle/Java/javapath:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files/SafeNet/Authentication/SAC/x64:/mnt/c/Program Files/SafeNet/Authentication/SAC/x32:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Users/f279814/AppData/Local/Microsoft/WindowsApps:/snap/bin:/home/guillaume/bin"
export PATH=$PATH:"/mnt/c/Users/f279814/AppData/Local/Programs/Microsoft VS Code/bin"
export GPG_TTY=$(tty)
export DISPLAY=:0
# Could not load library libcudnn_cnn_infer.so.8. Error: libcuda.so: cannot open shared object file: No such file or directory
export LD_LIBRARY_PATH=/usr/lib/wsl/lib
EOF
Double check PATH env
Install power10klevel
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
and update in .zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"
Install fonts for power10klevel https://github.com/romkatv/powerlevel10k#manual-font-installation
Could need installation of font-manager sudo apt install font-manager
And install them in windows as well to have it properly rendered in Windows Terminal https://sicse.dev/blog/wsl-2-prompt-powerlevel10k-theme
Manually configure or get a version from dotfiles
Install plugins
#zsh autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
#zsh syntax highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
and in .zshrc
plugins=(git zsh-autosuggestions zsh-syntax-highlighting python history)
based on wsl version >= 1.0.
Upgrade snap
Check it is running
And install firefox
sudo snap install firefox
# due to a bug when opening settings
# https://answers.launchpad.net/ubuntu/+question/701403https://answers.launchpad.net/ubuntu/+question/701403
sudo apt install xdg-desktop-portal-gtk
To allow external websites, import this certificate /usr/local/share/ca-certificates/cert_M_X5C_sase-mob-sslfwd-trust-ca.crt
in the certificate manager
And install nautilus
I like this text editor even if it is not exactly opensource.
I may even buy a license later.
Anyway I will use the snap version
and because of this issue from WSLg WSL some icons in taskbar for linux applications are defaulting to Tux, I add this
cd /var/lib/snapd/desktop/applications
sudo ln -s sublime-text_subl.desktop sublime_text.desktop
cd ~/bin
touch sublime_text
chmod +x sublime_text
tee sublime_text << EOF
#!/bin/bash
env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/sublime-text_subl.desktop /snap/bin/sublime-text.subl --launch-or-new-window
EOF
Launching sublime_text
in command line should open sublime_text with matching icon in taskbar. The same when right clicking a text file in nautilus and editing with sublime text.
sudo add-apt-repository univ
sudo apt-get -y install gnome-tweaks
sudo apt-get -y install yaru-theme-gtk
sudo apt-get -y install yaru-theme-icon
And impact on nautilus is directly visible
tilix is a terminal with split windows integrated (as with tmux or screen or vi)
use zsh / powerlevel10k fonts sandwich > Preferences > Profiles / Default > Text Appearance / Custom Font > MesloLGS NF Regular
update Copy/Paste shortcuts sandwich > Preferences > Shortcuts > Copy (Ctrl-C) and Paste (Ctrl-V) as for other terminals, interrupt is now Shift-Ctrl-C
vte config as explained in https://gnunn1.github.io/tilix-web/manual/vteconfig/ add this in .zshrc
and create this symlink
And install gimp
snap find zotero
Name Version Publisher Notes Summary
zotero-snap 6.0.18 extraymond - Zotero helps you collect, organize, cite, and share research.
qnotero 2.3.1 ealbiter - Standalone sidekick to Zotero reference manager.
zotviewer 1.5.0 fvalle - Zotero Visualizer
sudo snap install zotero-snap
zotero-snap 6.0.18 from extraymond installed
and there is something to do to activate sync: https://github.com/extraymond/zotero-snap/issues/29
for the moment I don’t recommend to do it in the main distro.
It is just as a test. Lots of stuffs don’t work as expected.
from powershell
wsl --import ubuntu-x11 C:\wsl\Ubuntu-22.04_X11\instance C:\wsl\Ubuntu-22.04_X11\download\ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz
wsl -d ubuntu-x11
cd
cp /mnt/c/wsl/Ubuntu-22.04_X11/download/setup_wsl_* ~/
chmod +x setup_wsl_root.sh
./setup_wsl_root.sh
from powershell
start ubuntu-x11 from windows terminal menu
and enter informations requested (ssh keys (paste to gitlab), update certificates (enter password)). Other steps are automatic.
Other steps: - activate systemd (by modifying /etc/wsl.conf) - restart
Here we have a fully working distro. And we will test what is suggested at : https://askubuntu.com/a/1445415
sudo apt install ubuntu-desktop acpi-support-
sudo systemctl stop gdm.service
sudo systemctl disable gdm.service
sudo systemctl is-enabled rc-local.service
(if static it means it has be activated)
sudo systemctl enable rc-local.service
#create rc.local file
sudo vi /etc/rc.local
#!/bin/sh -e
mount -o rw,remount /tmp/.X11-unix/
chmod +t /tmp/.X11-unix
chmod o+rw /dev/dri/renderD128
/usr/libexec/at-spi-bus-launcher --launch-immediately &
exit 0
#save & exit
sudo chmod 700 /etc/rc.local
sudo usermod -a -G adm guillaume
XDG_SESSION_TYPE=x11 gnome-session --disable-acceleration-check --session=ubuntu --systemd-service > /dev/null 2>&1
(this can be added to .bashrc or as a service)and then
MUTTER_DEBUG_DUMMY_MODE_SPECS=1920x1080 gnome-shell --nested --no-x11 2> /dev/null &
Then we can start it by running gnomeshell.sh