This is an old revision of the document!


Windows Subsystem for Linux - Debian 10.3

Installation

  • Enable “Developer mode” in Settings –> Update & Security –> For developers
  • Press Windows key + R and run *optionalfeatures.exe. Enable Windows Subsystem for Linux. Restart the computer. * Open Windows Power Shell as Administrator, then run the following line and reboot:<code>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux</code> * Open the Microsoft Store and search for “Linux”. Choose and get Debian, as per 2020-03-10 this is Debian 10 Buster. * Open Debian from the start menu and complete installation. * Upgrade all packages:<code>sudo apt update sudo apt upgrade</code> * Install packages:<code>sudo apt install vim sudo apt install wget sudo apt install zip sudo apt install rsync</code> * Create /run/sshd folder:<code>sudo mkdir /run/sshd</code> * Create a shortcut to the executable on your desktop:<code>C:\Users\user\AppData\Local\Microsoft\WindowsApps\debian.exe</code> * The root file system can be found at a path similar to:<code>C:\Users\bco\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs</code> * Add Debian and Debian rootfs icons to the shortcuts ===== SSH Server ===== * Install packages:<code>sudo apt install openssh-server</code> * Follow the SSH Client and Server guide. SSH into your host and open port 22 in the Windows Firewall. ==== Start SSH Server at Windows boot time ==== * Open a bash command shell and allow <user> to run ssh as root, add the following line after %sudo:<code>sudo visudo %sudo ALL=(ALL:ALL) ALL <user> ALL=(root:root) NOPASSWD: /etc/init.d/ssh</code> * Open Windows Task Scheduler and click Create Basic Task… - General * Name : Start Bash SSH Server * Description: Start the WSL SSH Server via a bash command * Run only when user is logged on * Run with highest privileges - Trigger * Begin the task: At log on * Specific user: <user> * Enabled - Actions * Action: Start a program * Program/script: C:\Windows\System32\bash.exe * Add arguments (optional): -c “/usr/bin/sudo /etc/init.d/ssh start” - Conditions * Start the task only if the computer is on AC power - Settings * Uncheck Stop the task if it runs longer than: - Alternative Action when starting a non elevated script “startup” * Action: Start a program * Program/script: C:\Windows\System32\bash.exe * Add arguments (optional): -c “/home/user/startup” * Script “startup”:<code>#!/bin/bash sudo /etc/init.d/ssh start</code> ===== LAMP ===== * Apache 2.4 and PHP 7.4 * MariaDB 10.3 ===== Mounting encrypted drives ===== * WSL can mount encrypted drives, but they must be mounted at the time wsl or bash runs the first time after boot. * If you do not execute any tasks when the host boots up, then just make sure your encrypted drives are mounted when you run wsl or bash. * If you do execute WSL tasks when the host boots up, replace the Task Scheduler entry for the trigger and make it rund after the Mount script has executed:<code><QueryList> <Query Id=“0” Path=“Microsoft-Windows-TaskScheduler/Operational”> <Select Path=“Microsoft-Windows-TaskScheduler/Operational”>*[EventData[@Name='TaskSuccessEvent'][Data[@Name='TaskName']='\Mount']]</Select> </Query> </QueryList></code> * Remember to “Enable All Task History” under Actions tab. You might need to do this again after a Windows 10 major version upgrade**.