GithubHelp home page GithubHelp logo

vpraharsha03 / gentoowsl2 Goto Github PK

View Code? Open in Web Editor NEW
52.0 5.0 3.0 115 KB

Install Gentoo as a WSL2 instance (for Windows 10 1903 64bit or later). Minimal setup and configuration. Releases are automated with CircleCI

Home Page: https://git.io/gentoowsl2

License: MIT License

Shell 100.00%
wsl2 gentoo windows-10 windows-subsystem-linux windows-terminal

gentoowsl2's Introduction

GentooWSL2

GentooWSL2

Gentoo Linux on WSL2 (Windows 10 1903 or later) based on wsldl

License

Requirements

  • Windows 10 1903 x64 (KB4566116 update required on 1903/09) or later.
  • Windows Subsystem for Linux feature is enabled.

Why WSL2?

The main reason for choosing WSL2 is because of it's improved file system performance. For the best overall experience it is recommended to use WSL2 with it's local EXT4 filesystem. Portage and it's related operations work perfectly on WSL2 for the fact that WSL2 uses a real linux kernel. However it is possible to set up Gentoo on WSL1, but there are certain caveats of doing so.

Initial Setup (Installing Gentoo userspace)

1. Download installer zip

2. Extract all files in zip file to same directory

3. Run Gentoo.exe to Extract rootfs and Register to WSL

Exe filename is used as the instance name to register. If you rename it, you can register with a different name and have multiple installs.

Setting up Gentoo in WSL:

Make changes to the portage environment accordingly (/etc/portage/make.conf file):

  • Adjust CPU configuration and COMMON_FLAGS to match your PC architecture.
  • Adjust MAKEOPTS to the number of CPU cores (+1) to make the compilation faster

To finish the Gentoo installation a new snapshot of the ebuild repository should be downloaded. A recompilation of the compiler ensures that GCC is on the most recent stable version. After updating GCC a recompilation of all programs / libraries ensures that the set optimizations take effect.

#!/bin/bash
set -e -x

# Download a snapshot of all official ebuilds
emerge-webrsync

# Upgrade the compiler and the required libtool library
emerge --oneshot --deep sys-devel/gcc
emerge --oneshot --usepkg=n sys-devel/libtool

# Update all packages with the newly built compiler
# This will take a long time, ~1-5 hours
emerge --oneshot --emptytree --deep @world
emerge --oneshot --deep @preserved-rebuild
emerge --ask --depclean

Finalizing:

Enabling overlays for portage:

Portage overlays provide a method to add additional package sources to portage. Eselect provides an easy integration of overlays into portage. To install Eselect:

emerge --ask app-eselect/eselect-repository

Finally, synchronize emerge:

emerge --sync

Using Git for portage sync:

Sync via git which is fast, secure and up-to-date

emerge --ask dev-vcs/git

Make changes in portage config file under /etc/portage/repos.conf/gentoo.conf that holds the configuration for the main gentoo repository:

Replace,

sync-type = rsync
sync-uri = rsync://rsync.de.gentoo.org/gentoo-portage/

with

sync-type = git
sync-uri = https://github.com/gentoo-mirror/gentoo.git

Finally,

rm -r /var/db/repos/gentoo # delete the old rsync-managed repository
emerge --sync

Subsequent syncs should be now faster.

Setting up Locales

  1. Open /etc/locale.gen file and add the locales you need. For example
en_US.UTF-8 UTF-8
en_US ISO-8859-1
  1. Run locale-gen to generate the locales.
  2. Run eselect locale list to view the locales
  3. Run eselect locale set 1 to set the locale
  4. Run env-update

Setting up users

  1. Create a new user with the following command: (replace username with your desired username)
useradd -m -G wheel,audio,video,portage,usb,cdrom -s /bin/bash username
  1. Set the password for the user
passwd username
  1. Set the password for the root user
passwd root
  1. Set the default user to the new user in WSL2
# /etc/wsl.conf
[user]
default=username

Setting up sudo

emerge --ask app-admin/sudo

Uncomment # %wheel ALL=(ALL) ALL line in /etc/sudoers using visudo to allow users added to wheel group to have priviliges.

Limit WSL2 resource usage:

Create a global configuration for all installed WSL2 Linux disributions, named .wslconfig in your user profile folder. This is necessary to set a maximum size limit of the RAM WSL will use. Sometimes, Linux Kernel may use free memory as cache and will eat away RAM of host.

[wsl2]
#kernel=
memory=4GB # Limit VM memory
#processors=
#swap=
#swapFile=
localhostForwarding=true
EOF

Restart WSL from Powershell with admin rights

Restart-Service LxssManager

How-to-Use(for Installed Instance)

exe Usage

Usage :
    <no args>
      - Open a new shell with your default settings.

    run <command line>
      - Run the given command line in that distro. Inherit current directory.

    runp <command line (includes windows path)>
      - Run the path translated command line in that distro.

    config [setting [value]]
      - `--default-user <user>`: Set the default user for this distro to <user>
      - `--default-uid <uid>`: Set the default user uid for this distro to <uid>
      - `--append-path <on|off>`: Switch of Append Windows PATH to $PATH
      - `--mount-drive <on|off>`: Switch of Mount drives
      - `--default-term <default|wt|flute>`: Set default terminal window

    get [setting]
      - `--default-uid`: Get the default user uid in this distro
      - `--append-path`: Get on/off status of Append Windows PATH to $PATH
      - `--mount-drive`: Get on/off status of Mount drives
      - `--wsl-version`: Get WSL Version 1/2 for this distro
      - `--default-term`: Get Default Terminal for this distro launcher
      - `--lxguid`: Get WSL GUID key for this distro

    backup [contents]
      - `--tgz`: Output backup.tar.gz to the current directory using tar command
      - `--reg`: Output settings registry file to the current directory

    clean
      - Uninstall the distro.

    help
      - Print this usage message.

How to uninstall instance

>Gentoo.exe clean

Useful Links:

gentoowsl2's People

Contributors

marin-kitagawa avatar vpraharsha03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gentoowsl2's Issues

Missing steps in readme

Hello!

I noticed that the readme never calls out installing sudo or adding the non-root user to sudo. This, combined with not setting password for the root user, creates a condition where the user will be unable to obtain administrative privileges upon logging out for the first time.

Additionally, the step to update the gentoo repo to use git does not call out which file to edit, which might be helpful for a new user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.