Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
win10:wsl [2022/02/05 15:54] – [Mounting encrypted drives] Bernard Condrauwin10:wsl [2025/11/08 13:33] (current) – [Osiris, Cassandra, Hera, Vulcan, Hercules, Poseidon, Iapetus] Bernard Condrau
Line 1: Line 1:
 ====== Windows Subsystem for Linux - Debian 10.3 ===== ====== Windows Subsystem for Linux - Debian 10.3 =====
 +===== Osiris, Cassandra, Hera, Vulcan, Hercules, Poseidon, Iapetus =====
 +This guide has been tested under Windows 10 / Debian 10 and Windows 11 / Debian 13.
 ===== Installation ===== ===== Installation =====
-  Enable "Developer mode" in //Settings --> Update & Security --> For developers// +  Enable "Developer mode" in //Settings --> System --> Advanced// (Win 11) or //Settings --> Update & Security --> For developers// (Win 10) 
-  Press Windows key + R and run **optionalfeatures.exe**. Enable //Windows Subsystem for Linux//. Restart the computer. +  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 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. +  - If you want to use WSL on Windows 11 Home you need to first install Hyper-V (see [[https://www.youtube.com/watch?v=8ONMJyIyN74&t=170s|How to Install and Enable Hyper V in Windows 11 Home]]). Create the following Windows batch file and run it as administrator:<file>pushd "%~dp0" 
-  Open //Debian// from the start menu and complete installation. +dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt 
-  Upgrade all packages:<code>sudo apt update+for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i" 
 +del hyper-v.txt 
 +Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL 
 +pause</file> 
 +  - Restart your computer 
 +  - Open the Microsoft Store and search for "Linux". Choose and get Debian, as per 2020-03-10Debian 10 Buster, 2025-11-7: Debian 13.0 Trixie
 +  Open //Debian// from the start menu and complete installation. 
 +  Upgrade all packages:<code>sudo apt update
 sudo apt upgrade</code> sudo apt upgrade</code>
-  Install packages:<code>sudo apt install vim+  Install packages:<code>sudo apt install vim
 sudo apt install wget sudo apt install wget
 sudo apt install zip sudo apt install zip
 sudo apt install rsync</code> sudo apt install rsync</code>
-  Create /run/sshd folder:<code>sudo mkdir /run/sshd</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> +  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> +  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 {{:win10:debian.ico?20|Debian}} and {{:win10:debianf.ico?20|Debian rootfs}} icons to the shortcuts+  Add {{:win10:debian.ico?20|Debian}} and {{:win10:debianf.ico?20|Debian rootfs}} icons to the shortcuts 
 + 
 +===== Files ===== 
 +  * WSL2 image file is located at ''C:\Users\<username>\AppData\Local\Packages\<distribution>\LocalState\ext4.vhdx'' (replace 'ext4' with the filesystem of your distribution) 
 +  * You can copy file ''ext4.vhdx'' to another location and open it with 7zip. 
 +  * To read files from an ext4.vhdx file, which is commonly used by Windows Subsystem for Linux (WSL) 2, you can utilize the wsl --mount command. This process involves mounting the VHDX file within Windows and then accessing its contents from within your WSL environment. See following steps to read files from ext4.vhdx using WSL. 
 +  * Terminate WSL Instances: Ensure all running WSL instances are shut down to prevent conflicts with the VHDX file.<file>wsl.exe --shutdown</file> 
 +  * Mount the VHDX in Windows (with Administrator privileges): Open PowerShell or Command Prompt as an administrator and use Mount-VHD to make the VHDX file accessible to Windows. Replace <pathToVHD> with the actual path to your ext4.vhdx file.<file>Mount-VHD -Path "<pathToVHD>"</file> 
 +  * Alternatively, you can use diskpart to mount the VHDX:<file>diskpart 
 +    select vdisk file="<pathToVHD>" 
 +    attach vdisk</file> 
 +  * Identify the Disk Path in Windows: After mounting, you need to find the disk path assigned by Windows. You can use Get-Disk in PowerShell or list disk in diskpart to identify the newly mounted disk. 
 +  * Mount the Disk in WSL: Open your WSL distribution (e.g., Ubuntu) and mount the disk path identified in the previous step. Replace <diskPath> with the actual disk path (e.g., /dev/sdb) and <mountPoint> with your desired mount point within WSL (e.g., /mnt/ext4).<file>sudo wsl --mount <diskPath> --bare 
 +sudo mkdir -p <mountPoint> 
 +sudo mount <diskPath> <mountPoint></file> 
 +  * Access Files within WSL: Once mounted, you can navigate to the <mountPoint> within your WSL environment and access the files stored on the ext4.vhdx.<file>cd <mountPoint> 
 +ls -l</file> 
 +  * Unmount and Detach (after use): When you are finished, unmount the disk within WSL and detach the VHDX from Windows.<file>sudo umount <mountPoint> 
 +wsl --unmount <diskPath></file> 
 +  * If you used Mount-VHD:<file>Dismount-VHD -Path "<pathToVHD>"</file> 
 +  * If you used diskpart:<file>diskpart 
 +select vdisk file="<pathToVHD>" 
 +detach vdisk</file> 
 +  * Alternative Method (for viewing only): For simply viewing the contents of an ext4.vhdx file without mounting, you can use tools like 7-Zip. 7-Zip can open and browse the contents of various disk image formats, including ext4.vhdx, allowing you to extract files without needing to mount the entire disk.
  
 ===== SSH Server ===== ===== SSH Server =====
Line 32: Line 64:
       * Run with highest privileges       * Run with highest privileges
     - Trigger     - Trigger
-      * Begin the task: At log on+      * 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: <user>       * Specific user: <user>
       * Enabled       * Enabled
Line 51: Line 84:
  
 ===== LAMP ===== ===== LAMP =====
-  * [[deb9:apache|Apache 2.4 and PHP 7.4]] +  * [[deb12:lamp|LAMP on Debian 12 (Apache 2.4, PHP 8.3, MariaDB 10.11)]] 
-  * [[deb9:mariadb|MariaDB 10.3]]+  * [[deb9:apache|Debian 9 - Apache 2.4 and PHP 7.4]] 
 +  * [[deb9:mariadb|Debian 9 - MariaDB 10.3]]
  
 ===== Mounting encrypted drives ===== ===== Mounting encrypted drives =====