注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Windows Subsystem for Linux"

From Funtoo
Jump to navigation Jump to search
(note that wsl uses bash_profile instead of bashrc)
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Windows Subsystem for Linux==
=== Introduction ===


To install WSL 2 on Windows 10 you need the following things:
Windows Subsystem for Linux provides support for running Funtoo Linux under Windows 10 and Windows 11. The latest version is WSL 2, which provides full system call compatibility, and improvement over the original WSL.


*Any version of Windows 10 such as: Professional, Home or Home Single Language with the following build numbers:
=== Requirements ===
Windows 10 May 2020 (2004), Windows 10 May 2019 (1903), or Windows 10 November 2019 (1909) or later.
Technically you can install WSL 2 on an “insider” build of Windows 10 build 18917 or later.


*A computer with  Virtualization support active on BIOS and RAM memory with at least 4GB. For best performance 8 GB.
To install WSL 2 on Windows, you need the following things:


*A processor (CPU) that supports SLAT (Second Level Address Translation):
* Windows 11 (any version, including Home), or:
Intel’s SLAT technology is represented as EPT (Extended Page Table).
* Windows 10 (any version, including Home) builds 18917 or higher
This technology is available in processors with virtualization support: core i7, i5, i3, Pentium G6950 and other appropriate Xeons.
Technically you can install WSL 2 on an “insider” build of Windows 10 build 18917 or later.
It is not available in Core 2 Duo or Core Quad (socket 775) based or other earlier Intel processors.


AMD’s SLAT technology is represented as RVI (Rapid Virtualization Indexing) technology, in their third generation Opteron processors codenamed Barcelona.
=== Installation ===


===update===
To initially set up WSL 2, run a PowerShell prompt as an administrator and type:
WSL 2 is only available in Windows 10 builds 18917 or higher, upgrade to a WSL 2 compatible version:


*https://www.microsoft.com/en-us/software-download/windows10
{{console|body=
%PowerShell>% ##i##wsl --install
}}


===configure===
After this command completes, and you reboot your system, it is then recommended to install Windows Terminal, which is available from this link -- this is actually a Microsoft Learn site describing Windows Terminal, but it does provide a link to the Microsoft Store page for Windows Terminal:


In the Windows search box search for "turn windows features on or off"
https://learn.microsoft.com/en-us/windows/terminal/


scroll down and tick:
Start Windows Terminal. You can now use {{c|wget}} under PowerShell to download the stage3 of your choice:


*virtual machine platform
{{console|body=
%PowerShell>% ##i##wget -Uri https://build.funtoo.org/next/x86-64bit/amd64-zen3/2023-09-25/stage3-amd64-zen3-next-2023-09-25.tar.xz -OutFile stage3.tar.xz
}}


*windows subsystem for linux
Once the download completes, you will need to decompress it. This can be done by directly downloading the .exe for Windows, available from https://7-zip.org/a/7zr.exe, and running the following command:


===install WSL kernel===
{{console|body=
install the WSL 2 kernel from this link
%PowerShell>% ##i##.\Downloads\7zr.exe x stage3.tar.xz
}}


*https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel
Now run the following command in PowerShell -- you do not need to be administrator to run this as long as you have previously installed WSL 2. The arguments specify that we want to import a distribution named "funtoo", which will be installed to the {{f|funtoo}} directory, using {{f|stage3.tar}} as a source.


*Try to use your computers specific subarch stage3:
{{console|body=
https://www.funtoo.org/Subarches
%PowerShell>%##i## wsl.exe --import "funtoo" funtoo stage3.tar --version 2
Import in progress, this may take a few minutes.
The operation completed successfully.
%PowerShell>%
}}


*if you're running 64 bit windows, and unsure about your subarch you can use this stage3:
When this command completes, Funtoo Linux has been
https://www.funtoo.org/Generic_64


*if you're adventurous you can use ffs stages
The {{c|wsl -d}} command ({{c|-d}} stands for "distribution") is an oddly-named command which will start the named imported distribution (in our case, Funtoo Linux) if it is not started, and then provide a direct root console to Funtoo Linux. Alternatively, simply typing {{c|wsl}} and hitting Enter also curiously has this same behavior:
https://area31.host.funtoo.org/ffs/


===decompress tarball===
{{console|body=
*use 7zip to convert the .tar.xz to .tar:
%PowerShell>%##i## wsl -d funtoo
https://www.7-zip.org/download.html
#
}}


===install===
You are now running Funtoo under Windows 11. However, Funtoo is not fully set up. We will want to configure WSL 2 to start the {{c|default}} runlevel when Funtoo is started. To do this, we create a {{f|/etc/wsl.conf}} file inside your Funtoo installation as follows:
*search for power shell, right click it's icon and select run as administrator:


{{console|body=
{{console|body=
###i## wsl.exe --import "funtoo" "C:\funtoo" "C:\Users\$MYUSER\Downloads\gnome-stage3-amd64-piledriver-1.4-release-std-2020-12-16.tar" --version 2
# ##i##nano /etc/wsl.conf
}}
}}


{{console|body=
Add the following contents to this file:
###i## wsl -d funtoo
 
{{file|name=/etc/wsl.conf|desc=wsl.conf file|body=
[boot]
systemd=false
command = "/sbin/openrc default"
}}
}}


you are now running funtoo under windows.
Now, it is necessary to stop and restart Funtoo to have this setting take effect. However, OpenRC is not working yet, so you will need to do this from the PowerShell command prompt:


{{console|body=
{{console|body=
###i## ego sync
# ##i##exit
###i## emerge -C debian-sources
%PowerShell>%##i## wsl -t funtoo
###i## emerge -avuND @world
%PowerShell>%##i## wsl -d funtoo
#
}}
}}


wsl behaves similar to a chroot instance regarding init.
The above command terminates the existing Funtoo VM, and then re-starts and re-enters it. At this point, you should see OpenRC functioning properly:


{{console|body=
{{console|body=
###i## mkdir /run/openrc
# ##i##rc-status
###i## touch /run/openrc/softlevel
Runlevel: default
###i## rc
netmount                                                                                                ##c##[  ##g##started##!g## ]
sshd                                                                                                    ##c##[  ##g##started##!g## ]
udev-postmount                                                                                          ##c####g##started##!g## ]
local                                                                                                  ##c####g##started##!g## ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
Dynamic Runlevel: manual
}}
}}


*gwsl in the microsoft store can run graphical applications that are installed.
As you can see, {{c|sshd}} is running which will allow you to locally "ssh" into the Funtoo VM if you like, and it also demonstrates
that other services can be added to the default runlevel that you might want to start. You can now start using Funtoo Linux as you normally would,
with the exception that the {{c|reboot}} and {{c|shutdown}} commands will not work.


Xming uses ssh x11 forwarding to render x11 under windows:
{{console|body=
*http://www.geo.mtu.edu/geoschem/docs/putty_install.html
###i## ego sync
###i## emerge -C debian-sources
###i## emerge -avuND @world
}}


=== bash_profile ===
=== bash_profile ===

Latest revision as of 21:30, November 25, 2023

Introduction

Windows Subsystem for Linux provides support for running Funtoo Linux under Windows 10 and Windows 11. The latest version is WSL 2, which provides full system call compatibility, and improvement over the original WSL.

Requirements

To install WSL 2 on Windows, you need the following things:

  • Windows 11 (any version, including Home), or:
  • Windows 10 (any version, including Home) builds 18917 or higher

Technically you can install WSL 2 on an “insider” build of Windows 10 build 18917 or later.

Installation

To initially set up WSL 2, run a PowerShell prompt as an administrator and type:

PowerShell> # wsl --install

After this command completes, and you reboot your system, it is then recommended to install Windows Terminal, which is available from this link -- this is actually a Microsoft Learn site describing Windows Terminal, but it does provide a link to the Microsoft Store page for Windows Terminal:

https://learn.microsoft.com/en-us/windows/terminal/

Start Windows Terminal. You can now use wget under PowerShell to download the stage3 of your choice:

PowerShell> # wget -Uri https://build.funtoo.org/next/x86-64bit/amd64-zen3/2023-09-25/stage3-amd64-zen3-next-2023-09-25.tar.xz -OutFile stage3.tar.xz

Once the download completes, you will need to decompress it. This can be done by directly downloading the .exe for Windows, available from https://7-zip.org/a/7zr.exe, and running the following command:

PowerShell> # .\Downloads\7zr.exe x stage3.tar.xz

Now run the following command in PowerShell -- you do not need to be administrator to run this as long as you have previously installed WSL 2. The arguments specify that we want to import a distribution named "funtoo", which will be installed to the funtoo directory, using stage3.tar as a source.

PowerShell> # wsl.exe --import "funtoo" funtoo stage3.tar --version 2
Import in progress, this may take a few minutes.
The operation completed successfully.
PowerShell> #

When this command completes, Funtoo Linux has been

The wsl -d command (-d stands for "distribution") is an oddly-named command which will start the named imported distribution (in our case, Funtoo Linux) if it is not started, and then provide a direct root console to Funtoo Linux. Alternatively, simply typing wsl and hitting Enter also curiously has this same behavior:

PowerShell> # wsl -d funtoo
root #

You are now running Funtoo under Windows 11. However, Funtoo is not fully set up. We will want to configure WSL 2 to start the default runlevel when Funtoo is started. To do this, we create a /etc/wsl.conf file inside your Funtoo installation as follows:

root # nano /etc/wsl.conf

Add the following contents to this file:

   /etc/wsl.conf - wsl.conf file
[boot]
systemd=false
command = "/sbin/openrc default"

Now, it is necessary to stop and restart Funtoo to have this setting take effect. However, OpenRC is not working yet, so you will need to do this from the PowerShell command prompt:

root # exit
PowerShell> # wsl -t funtoo
PowerShell> # wsl -d funtoo
root #

The above command terminates the existing Funtoo VM, and then re-starts and re-enters it. At this point, you should see OpenRC functioning properly:

root # rc-status
Runlevel: default
 netmount                                                                                                [  started ]
 sshd                                                                                                    [  started ]
 udev-postmount                                                                                          [  started ]
 local                                                                                                   [  started ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
Dynamic Runlevel: manual

As you can see, sshd is running which will allow you to locally "ssh" into the Funtoo VM if you like, and it also demonstrates that other services can be added to the default runlevel that you might want to start. You can now start using Funtoo Linux as you normally would, with the exception that the reboot and shutdown commands will not work.

root # ego sync
root # emerge -C debian-sources
root # emerge -avuND @world

bash_profile

instead of putting goodies to be executed at start in .bashrc, you should place them in .bash_profile

uninstall

  • in powershell:
root # wsl.exe --unregister funtoo