0
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 5 years have passed since last update.

WSLでCentOS7をインストールする

0
Posted at

WSLでCentOS7をインストールする

CentOS7のファイルのダウンロード

CentOS7のファイルを下記のGitHubリポジトリからダウンロードします。
mishamosher/CentOS-WSL

この方のリポジトリには、CentOS 7.9-2009、CentOS 7.8-2003 が配布されています。

古いCentOS7のファイルが必要な場合

最新ではなく古いCentOS7をインストールしたい場合、アーカイブされた下記のGitHubリポジトリからダウンロードします。

wsldl-pg/CentWSL

この方のリポジトリには、CentOS 7.6-1901、CentOS 7.6-1905、CentOS 7.6-1907が配布されています。

展開と実行

ダウンロードしたファイルは、Zip圧縮されていますので展開してください。
展開したフォルダを、%USERPROFILE%\AppData\Local\Packages にコピーし、実行します。

C:\Users\(ユーザ名)\AppData\Local\Packages\CentOS7>CentOS7.exe
Using: C:\Users\(ユーザ名)\AppData\Local\Packages\CentOS7\rootfs.tar.gz
Installing...
Installation Complete!
Press any key to continue...

確認

インストールが完了したかどうか確認するため、以下のコマンドを投入します。

C:\Users\(ユーザ名)\AppData\Local\Packages\CentOS7>wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Stopped         2
  docker-desktop         Stopped         2
  CentOS7                Stopped         2
  Ubuntu-20.04           Stopped         2

起動

起動するには以下のコマンドを投入します。

C:\Users\(ユーザ名)\AppData\Local\Packages\CentOS7>wsl -d CentOS7
[root@DESKTOP-MT7U9JC CentOS7]#

インストール後の設定

ルートパスワードの設定

インストール直後はrootのパスワードが設定されていません。
以下のようにコマンドを投入してパスワードを設定します。

[root@DESKTOP-MT7U9JC CentOS7]# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@DESKTOP-MT7U9JC CentOS7]#

一般ユーザーの生成

一般的に使用するユーザーを生成します。

ユーザーの作成、パスワード設定

# useradd sampleuser
# passwd sampleuser

ユーザーを wheelグループに追加

# usermod -aG wheel sampleuser

wslでログインするデフォルトのユーザーを変更する。

.\CentOS7.exe config --default-user  ユーザー名

上記のコマンドは、シェルではなくコマンドプロンプトで実行します。
CentOS7.exe の実行は、コマンドプロンプトから cd で移動してから実行します。

以降は、通常のCentOS7の操作と同じになります。

アンインストール

アンインストールするには、他のディストリビューションと同様に cleanコマンドを投入します。

.\CentOS7.exe clean
0
0
0

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
0
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?