iTranslated by AI
How to Use Arch-based Manjaro on WSL2
What is Manjaro?
Related article:
Using ArchLinux on WSL2
With the release of Windows 11,
WSL has entered the WSLg era.
Opportunities to use Linux UI on Windows are increasing.
Following this trend, I thought I might be able to use a Linux Desktop on Windows, so I started looking for something good.
The following two candidates came up:
I tried Pop!_OS, but it didn't work out very well.
So, I decided to try Manjaro to see if it would work.
I previously integrated ArchLinux into WSL via Docker, and since they are in the same family, it should probably work.
Let's try incorporating it into WSL using the official Docker image.
ヾ(・ω<)ノ" 三三三● ⅱⅲ Rolling along♪
------------------- ↓ The main part starts here ↓-------------------
Preliminary preparation
Since Docker is required,
I will install Docker Desktop for convenience.
Run the following command in PowerShell:
winget install Docker.DockerDesktop
Pulling and running what is likely the official image from DockerHub
Pulling it beforehand will cache it.
docker pull manjarolinux/base:latest
docker run --rm -it -t manjarolinux/base:latest
Dockerfile
FROM manjarolinux/base:latest
ARG BUILDERNAME=builder
ARG USERNAME=dozo
RUN pacman-mirrors -c Japan,United_States\
&& pacman -Sy\
&& pacman -Syu --noconfirm --needed git sudo wget nano go base-devel
RUN usermod -l ${USERNAME} ${BUILDERNAME}\
&& groupmod -n ${USERNAME} ${BUILDERNAME}\
&& usermod -d /home/${USERNAME} -m ${USERNAME}
RUN usermod -aG wheel ${USERNAME}\
&& passwd -d ${USERNAME}\
&& printf "%%wheel ALL=(ALL) NOPASSWD:ALL\n" | tee -a /etc/sudoers.d/wheel\
&& printf "[user]\ndefault=${USERNAME}\n" | tee /etc/wsl.conf
RUN localedef -f UTF-8 -i ja_JP ja_JP.UTF-8
ENV LANG="ja_JP.UTF-8" \
LANGUAGE="ja_JP:ja" \
LC_ALL="ja_JP.UTF-8"
USER ${USERNAME}
RUN cd \
&& git clone https://aur.archlinux.org/yay-bin \
&& cd yay-bin\
&& makepkg -si --noconfirm\
&& cd .. \
&& rm -rf ./yay-bin
WORKDIR /home/${USERNAME}
September 20, 2022: Updated the Dockerfile.
According to a comment, base-devel seems to be required for the Dockerfile. (Unverified)
Checking DockerHub, it appears that the manjarolinux/base image size was reduced in an update on August 31 of the same year.
Starting the docker build
docker build . -t manjaro:1.0
Exporting the container and importing it into WSL
Get the container ID with docker ps.
docker run -t manjaro:1.0 test
docker ps -a
CONTAINER ID IMAGE COMMAND
e4c8378ef5ae manjaro:1.0 "test"
Export the container to a disk image on PowerShell.
Assuming the installation destination is C:\Programs\Manjaro:
docker export -o manjaro.tar e4c8378ef5ae
wsl --import Manjaro C:\Programs\Manjaro manjaro.tar --version 2
Trying to log in to WSL
Let's try logging in.
wsl -d manjaro
$ passwd
New password:
Retype new password:
passwd: password updated successfully
(・∀・)(・∀・)
------------------- ↓ Postscript starts here ↓-------------------
The following items have already been included in the aforementioned Dockerfile.
I often find things out later, so I will update this as I go.
Setting the pacman repository to Japan
As with Arch, the slow pacman repository issue persists even after switching to Manjaro.
Last time, I sent requests to the repository site, but it seems there is a command to update it, so I am using that this time.
I also added the United States just in case.
RUN pacman-mirrors -c Japan,United_States\
&& pacman -Sy
Installing yay
I will re-post the description for installing yay, which is the Go version of pacman.
When installing ArchLinux, I built it from source, but since there is a binary available, I am using that this time.
RUN pacman -Syu --noconfirm --needed go
...
RUN cd \
&& git clone https://aur.archlinux.org/yay-bin \
&& cd yay-bin\
&& makepkg -si --noconfirm\
&& cd .. \
&& rm -rf ./yay-bin
Discussion
とても参考になる記事でした。ありがとうございます。
本日 2022年9月19日 時点のmanjarolinux/base:latestを使うとmakepkg の箇所で
ERROR: Cannot find the strip binary required for object file stripping.
が発生します。
下記の通り base-develの追加が必要なようです。
&& pacman -Syu --noconfirm --needed git sudo wget nano go base-devel
ご指摘ありがとうございます。
base-develを追記しました。