LoginSignup
0
0

Windows11のWSLにCentOSをインストールする

Posted at

Windows11の設定

PowerShellを管理者権限で開く

PowerShell

以下のコマンドで、WSLを有効にする

> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

以下のコマンドで、仮想マシンプラットフォームを有効にする

> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Windows11を再起動する

PowerShellを管理者権限で開き、以下のコマンドで、WSL2をデフォルトバージョンにする

> wsl --set-default-version 2

CentOSのインストール

GitHubからCentOS(CentOS7.zip)をダウンロードする

zipファイルから、rootfs.tarを取り出す
.tarの取り出しには、7-zipを使用
https://7-zip.opensource.jp/

以下のコマンドで、CentOSをインポートする
事前にインポート先のフォルダ(.\CentOS7)を作成しておく

> wsl --import CentOS7 .\CentOS7 .\rootfs.tar

CentOSを起動する

> wsl -d CentOS7

パッケージをアップデートし、sudoとパスワード設定ツールをインストール

# yum update -y && yum install passwd sudo -y

ユーザ(caloewen)を追加し、sudo特権を付与する

# myUsername=caloewen
# adduser -G wheel $myUsername
# echo -e "[user]\ndefault=$myUsername" >> /etc/wsl.conf
# passwd $myUsername

WindowsからCentOSのファイルにアクセス

以下のアドレスで、エクスプローラーを開く

\\wsl.localhost\CentOS7

参考にしたサイト

https://learn.microsoft.com/ja-jp/windows/wsl/use-custom-distro
https://learn.microsoft.com/ja-jp/windows/wsl/install-manual

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