====== Windows Subsystem for Linux - Debian 10.3 ===== ===== Cassandra, Hera, Vulcan, Hercules, Poseidon, Iapetus ===== ===== 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:Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux * 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:sudo apt update sudo apt upgrade * Install packages:sudo apt install vim sudo apt install wget sudo apt install zip sudo apt install rsync * Create /run/sshd folder:sudo mkdir /run/sshd * Create a shortcut to the executable on your desktop:C:\Users\user\AppData\Local\Microsoft\WindowsApps\debian.exe * The root file system can be found at a path similar to:C:\Users\bco\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs * Add {{:win10:debian.ico?20|Debian}} and {{:win10:debianf.ico?20|Debian rootfs}} icons to the shortcuts ===== SSH Server ===== * Install packages:sudo apt install openssh-server * Follow the [[deb9:ssh|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 to run ssh as root, add the following line after %sudo:sudo visudo %sudo ALL=(ALL:ALL) ALL ALL=(root:root) NOPASSWD: /etc/init.d/ssh * 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 [OR] On an event * (if you mount VeraCrypt volumes during boot it's better to use //On an event// and begin the task when the volumes are mounted) * Specific 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":#!/bin/bash sudo /etc/init.d/ssh start ===== LAMP ===== * [[deb12:lamp|LAMP on Debian 12 (Apache 2.4, PHP 8.3, MariaDB 10.11)]] * [[deb9:apache|Debian 9 - Apache 2.4 and PHP 7.4]] * [[deb9:mariadb|Debian 9 - 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: * Remember to "Enable All Task History" under Actions tab. **You might need to do this again after a Windows 10 major version upgrade**. ===== Mounting external drives ===== mkdir /mnt/f mount -t drvfs f: /mnt/f ===== Links ===== * [[https://docs.microsoft.com/en-us/windows/wsl/install-win10|Windows Subsystem for Linux Installation Guide for Windows 10]] * [[https://www.petri.com/bash-out-of-beta-in-windows-10|How Does the Windows 10 Subsystem for Linux Work and What Is It For?]] * [[https://devblogs.microsoft.com/commandline/background-task-support-in-wsl/|Background Task Support in WSL]] * [[https://www.illuminiastudios.com/dev-diaries/ssh-on-windows-subsystem-for-linux/|SSH on Windows Subsystem for Linux (WSL)]] * [[https://thedatafrog.com/en/backup-rsync-windows-wsl/|Backup with rsync on Windows (WSL)]] * [[https://medium.com/faun/docker-running-seamlessly-in-windows-subsystem-linux-6ef8412377aa|Docker Running Seamlessly in Windows Subsystem Linux]]