4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WSLAdvent Calendar 2020

Day 17

WSL2のUbuntuでsystemdをPID1で動作させる

Last updated at Posted at 2020-12-08

WSL2のubuntu20.04のPID1がinitになっているのでsystemdへ変更した際の備忘録
#環境
windows 10 home
OSビルド19041.630
#手順
microsoft storeからubuntu20.04をインストール
デフォルトだとPID1はinitになっている

$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0    892   568 ?        Sl   09:56   0:00 /init

Genieの依存パッケージであるdaemonize/dbus/policykit-1をaptでインストール

sudo apt update
sudo apt install -y daemonize dbus policykit-1

リポジトリを追加

wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb dpkg -i packages-microsoft-prod.deb

time outするからキャンセルする

更新

sudo apt update; sudo apt upgrade

パッケージリスト消去

sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update

.NET を再インストール

sudo apt-get install -y gpg
wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget https://packages.microsoft.com/config/ubuntu/20.04/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y {dotnet-package}

Genieのインストール
https://github.com/arkane-systems/genie

sudo apt-get install -y dotnet-runtime-3.1
sudo su

apt install lsb-release
cat << EOF > /etc/apt/sources.list.d/wsl-transdebian.list
sudo deb https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main
sudo deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main
EOF

apt update
apt install -y systemd-genie

#ルートパーティションにラベルを付けるためFilesystem名確認
df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb        251G  1.7G  237G   1% /

#ラベルをつける
sudo e2label /dev/sdb cloudimg-rootfs

genie -s

確認

$ ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.1  0.0 173368 13000 ?        Ss   12:27   0:02 systemd

genie自動起動

vi .bashrc
#以下追記
if [[ ! -v INSIDE_GENIE ]]; then
  exec /usr/bin/genie -s
fi
4
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?