Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Installing Gentoo
  • Search

Gentoo on WSL 2: much easier than on WSL 1

Having problems with the Gentoo Handbook? If you're still working your way through it, or just need some info before you start your install, this is the place. All other questions go elsewhere.
Post Reply
Advanced search
12 posts • Page 1 of 1
Author
Message
salfter
Tux's lil' helper
Tux's lil' helper
Posts: 89
Joined: Thu Jan 02, 2003 6:20 am
Contact:
Contact salfter
Website

Gentoo on WSL 2: much easier than on WSL 1

  • Quote

Post by salfter » Tue Jul 21, 2020 12:12 am

I've had Gentoo running on WSL 1 for a while now, but it was a bit of a pain to set up. IIRC, if you wanted a distro not in the Microsoft Store (such as Gentoo), you had to basically bundle it up as a UWP app for installation. It took several tries to get it right.

With WSL 2 (included with Win10 v2004), it's gotten much better. What follows is a summary of the steps I followed:
  1. Make sure hardware virtualization is enabled in BIOS. (For my Ryzen 7 3800X on an MSI X570-A Pro, I had to go looking under the CPU overclocking settings for SVM, and enable that.)
  2. Log into Windows and open an administrator PowerShell prompt.
  3. Make sure WSL is installed:

    Code: Select all

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
  4. Reboot and log into Windows again. Set the default WSL version to 2:

    Code: Select all

    wsl --set-default-version 2
  5. Grab a Gentoo stage3 AMD64 tarball (nomultilib recommended) from your favorite mirror. Uncompress it, but leave it in tar format.
  6. Import the tarball into WSL:

    Code: Select all

    wsl --import gentoo C:\Users\salfter\gentoo\ C:\Users\salfter\Downloads\stage3-amd64-nomultilib-20200624T214505Z.tar --version 2
    The first path is to an empty directory where the distro's virtual disk will be stored; the second is to the tarball you downloaded. If you want a name other than "gentoo," it's right after --import. If you're prompted to update the WSL kernel, download it from https://docs.microsoft.com/en-us/window ... sl2-kernel and install it, then repeat the import command.
  7. Chroot into your new installation...you'll be logged in as root:

    Code: Select all

    wsl -d gentoo
  8. Complete this minimal list of commands to set up a normal user for yourself:

    Code: Select all

    emaint sync -a
    emerge sudo
    useradd -mc "Your Name Here" -G wheel your_user_name
    passwd your_user_name
  9. Use visudo to enable sudo for the wheel group (whether with or without passwords is up to you).
  10. Exit Gentoo back to PowerShell, then exit PowerShell and launch the Registry Editor.
  11. In Regedit, dig down through HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{some GUID here} for a key with "gentoo" as the DistributionName. Set DefaultUid to 1000 (0x3e8).
  12. Pick a WSL-compatible terminal and install it. I've been using wsltty (https://github.com/mintty/wsltty).
Your start menu should now have a "gentoo Terminal" entry at the top. Run it and you'll be dumped into a bash prompt, customizable like any other Gentoo system.

Update: (2 Sep 21) I've had a couple of installations fail to start up recently. One is my home workstation, which I hadn't been motivated to fix as it's booted into Gentoo probably 99%+ of the time. This morning, though, my work computer (which is only set up to boot into Windows) did the same thing: click the Gentoo Terminal that's pinned to the taskbar, a window pops up...and then it disappears. I went looking, and the fix is here: pop open an administrative command prompt, issue

Code: Select all

netsh winsock reset
, and reboot.
Last edited by salfter on Thu Sep 02, 2021 3:26 pm, edited 1 time in total.
Top
Chili0_
Tux's lil' helper
Tux's lil' helper
Posts: 80
Joined: Mon Oct 09, 2017 9:24 am

  • Quote

Post by Chili0_ » Fri Nov 20, 2020 11:07 am

I always got "Access Denied" in the following, and already granted the full control permissions to directory C:\GentooWSL, my Windows OS version is 2004 19041.630, meanwhile if I install Ubuntu from Application Store, Ubuntu works good.

Code: Select all

PS C:\> wsl --import Gentoo C:\GentooWSL\ D:\stage3-amd64-nomultilib-20201118T214503Z.tar --version 2
[b]Access denied[/b]
Any idea ?
Top
salfter
Tux's lil' helper
Tux's lil' helper
Posts: 89
Joined: Thu Jan 02, 2003 6:20 am
Contact:
Contact salfter
Website

  • Quote

Post by salfter » Fri Nov 20, 2020 3:46 pm

Chili0_ wrote:Access Denied
Are you running that as an administrator? Hit the Windows key, start typing in "powershell," and when it comes up, right-click and select "Run as administrator." If you're not doing that, you're going to run into problems.
Top
Phoenix591
Guru
Guru
Posts: 504
Joined: Mon Sep 17, 2007 3:52 am

  • Quote

Post by Phoenix591 » Sat Nov 21, 2020 8:07 am

its not super hard to do it up in a uwp distribution launcher, where all you need is to do is grab a stage 3 compile and go (with visual studio 2019, and in visual studio grab the windows sdk and universal windows platform tools. Deploy solution compiles and installs it)
Top
Chili0_
Tux's lil' helper
Tux's lil' helper
Posts: 80
Joined: Mon Oct 09, 2017 9:24 am

  • Quote

Post by Chili0_ » Sat Nov 21, 2020 11:43 am

salfter wrote:
Chili0_ wrote:Access Denied
Are you running that as an administrator? Hit the Windows key, start typing in "powershell," and when it comes up, right-click and select "Run as administrator." If you're not doing that, you're going to run into problems.
Yes, I've tried "Run as admistrator", got "Access Denied".
Top
Chili0_
Tux's lil' helper
Tux's lil' helper
Posts: 80
Joined: Mon Oct 09, 2017 9:24 am

  • Quote

Post by Chili0_ » Sat Nov 21, 2020 11:49 am

Phoenix591 wrote:its not super hard to do it up in a uwp distribution launcher, where all you need is to do is grab a stage 3 compile and go (with visual studio 2019, and in visual studio grab the windows sdk and universal windows platform tools. Deploy solution compiles and installs it)
Thanks, if there is no other way, it seems this should be a solution, but WSL version 2 should have the easy way.
Top
Chili0_
Tux's lil' helper
Tux's lil' helper
Posts: 80
Joined: Mon Oct 09, 2017 9:24 am

  • Quote

Post by Chili0_ » Mon Nov 23, 2020 4:01 am

Here is my way finally,

1. Download Launch.exe from https://github.com/yuk7/wsldl , rename Launch.exe to gentoo.exe

2. Download Stage3 from https://bouncer.gentoo.org/fetch/root/a ... 03Z.tar.xz
(1) repackage stage3-amd64-nomultilib-20201122T214503Z.tar.xz to gz file with specific name roofs.tar.gz
(2) put rootfs.tar.gz and gentoo.exe in to same directory
(3) under a windows terminal, change to the above folder, run gentoo (will install gentoo linux)

3. start the installed Gentoo linux by just run the gentoo.exe in a terminal

4. run wsl --set-default-version gentoo 2 to convert gentoo from wsl 1 to wsl 2.
Top
JonathanVQP
n00b
n00b
User avatar
Posts: 58
Joined: Mon Nov 30, 2020 5:06 am

  • Quote

Post by JonathanVQP » Fri Jul 02, 2021 7:41 pm

This works great! Has anyone had a chance to install and run any gui like KDE or Gnome in Gentoo in WSL2? KDE and Gnome and other DE works in other WSL2 linux distros like Ubuntu, Debian, Kali-Linux, etc... but I haven't had a chance to emerge KDE in Gentoo WSL2 to see if it works.
Top
George528
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Thu May 27, 2021 2:23 pm

  • Quote

Post by George528 » Sat Jul 03, 2021 11:16 am

Sorry for posting this one year later, but i don't want to start another thread for a small question like mine

Quesiton: Can i just copy-paste my gentoo filesystem in wsl? i have an already build version of it, so i dont want build it from scratch again.
Top
JonathanVQP
n00b
n00b
User avatar
Posts: 58
Joined: Mon Nov 30, 2020 5:06 am

  • Quote

Post by JonathanVQP » Sat Jul 03, 2021 7:01 pm

George528:

The answer depends on where your Gentoo installation is located. If it is on another partition, quite possibly yes. If it is in VM image like Virtual Box or VMware then no (as far as I know). What's great about the WSL2 feature is that it can import and export Linux distros only if they are in tar format. There are numerous videos and searches on how to convert a Linux partition into tar format. Once it is in tar format, you can just do a WSL --import .... and voila, you have Gentoo in WSL2 in Windows 10 (which I am currently doing right now).

Just to let you know, Gentoo in WSL2 has some differences. WSL2 has it own kernel so you don't need to emerge and compile a Gentoo kernel. However some packages require a Gentoo kernel installed in /usr/src/linux. Also, unlike the pre-existing distros in the Windows Store for WSL2 (Ubuntu, Debian, etc...), I am still trying to figure out how to have KDE or Gnome to display since there is no video card emulated in WSL2 for Gentoo (I am still trying to figure that out...).

There are a lot of neat features with WSL2 and running Gentoo in it is an added bonus!

Jonathan
Top
George528
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Thu May 27, 2021 2:23 pm

  • Quote

Post by George528 » Sat Jul 03, 2021 7:25 pm

JonathanVQP wrote:George528:

The answer depends on where your Gentoo installation is located. If it is on another partition, quite possibly yes. If it is in VM image like Virtual Box or VMware then no (as far as I know). What's great about the WSL2 feature is that it can import and export Linux distros only if they are in tar format. There are numerous videos and searches on how to convert a Linux partition into tar format. Once it is in tar format, you can just do a WSL --import .... and voila, you have Gentoo in WSL2 in Windows 10 (which I am currently doing right now).

Just to let you know, Gentoo in WSL2 has some differences. WSL2 has it own kernel so you don't need to emerge and compile a Gentoo kernel. However some packages require a Gentoo kernel installed in /usr/src/linux. Also, unlike the pre-existing distros in the Windows Store for WSL2 (Ubuntu, Debian, etc...), I am still trying to figure out how to have KDE or Gnome to display since there is no video card emulated in WSL2 for Gentoo (I am still trying to figure that out...).

There are a lot of neat features with WSL2 and running Gentoo in it is an added bonus!

Jonathan
thanks for the long reply, and replying on this one year old thread in the first place. Indeed running gentoo in wsl is a good thing, but without the video card emulation... thats unfortunate. Aren't we allowed to modify wsl kernel in any way? maybe replicate what other distros with video card support does?
Top
JonathanVQP
n00b
n00b
User avatar
Posts: 58
Joined: Mon Nov 30, 2020 5:06 am

  • Quote

Post by JonathanVQP » Mon Jul 05, 2021 5:32 am

George528:

As of today, I am able to emerge and run XFCe, LXDe, and LXQt desktop environments in Gentoo WSL2. I tell ya, the more I work and tinker around with WSL2, the more I like it!! Since the above DE are lightweight, they don't bog down the memory footprint of WSL2 so they run pretty fast without additional graphics modifications. I can get 1920x1080 resolution and it runs great as if it is native and part of Windows 10. After I create the Gentoo WSL2 distro image, I can export and make a backup which is also awesome! WSL2 is very powerful and Windows 11 has made it even better!!!!

As to your other question about modifying the WSL2 kernel, I see there is a video on how to do that. As to modifying the Gentoo Kernel to work with WSL2, this is my next project and I will let you know how that progresses.
Top
Post Reply

12 posts • Page 1 of 1

Return to “Installing Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic