カテゴリー: 技術系

  • Bitnami Redmineで3.4.6から4.1.1にアップグレード

    Bitnami Redmineで、Redmineの3.4.6を使っている。3.4系が古いので、Redmineの4.1.1にアップグレードにアップグレードしたときの作業を残す。基本的には、Bitnamiのドキュメントの流れでインストールはできた。インストーラーを普通に走らせるとパスなどは変わるので、そこらへんはアレンジしてる。

    ■参考
    https://docs.bitnami.com/general/apps/redmine/administration/upgrade/

    ■やったこと

    アップデート前の環境のDBのユーザ名とパスワードをファイルから抜く。対象のファイルは、下記。

    /opt/redmine-3.4.6-1/apps/redmine/htdocs/config/database.yml
    

    接続の確認をする

    /opt/redmine-3.4.6-1/mysql/bin/mysql -u bitnami -p
    

    データを保存するフォルダを作る

    mkdir data
    cd data
    

    mysqldumpでデータベースのデータを保存する

    /opt/redmine-3.4.6-1/mysql/bin/mysqldump bitnami -p --databases bitnami_redmine --add-drop-database < bitnami_redmine.sql
    

    Redmineのファイルを保存する

     tar czf redmine_files.tar.gz -C /opt/redmine-3.4.6-1/apps/redmine/htdocs/files .
    

    プラグインのファイルを保存する

    tar czf redmine_plugins.tar.gz -C /opt/redmine-3.4.6-1/apps/redmine/htdocs/plugins .

    現在の環境のbitnami redmineを停止する

    sudo /opt/redmine-3.4.6-1/ctlscript.sh stop
    

    新しいバージョンのbitnami redmineのインストーラを実行する。ウィザード形式なので、ウィザードにしたがって設定をする。

    sudo ./bitnami-redmine-4.1.1-5-linux-x64-installer.run
    

    インストールができたら、新しいRedmineが起動しているので、アクセスして、アクセスできることを確認する。

    アクセスができ(=インストールされている)ていれば、次にApacheを停止する

    sudo /opt/redmine-4.1.1-5/ctlscript.sh stop apache
    

    新しいデータベースの接続情報を確認する。下記のファイルに記載されている。

    /opt/redmine-4.1.1-5/apps/redmine/htdocs/config/database.yml

    旧環境のデータを保存したディレクトリに移動し、下記のコマンドで、データベースのデータを入れる。

    /opt/redmine-4.1.1-5/mysql/bin/mysql -u bitnami -p < ./bitnami_redmine.sql
    

    次に、データを展開する。プラグインを使っているようであれば、プラグインも同じように展開する。

    sudo tar xzf ./redmine_files.tar.gz -C /opt/redmine-4.1.1-5/apps/redmine/htdocs/files
    

    Productionログのパーミッションを一時的に変更する(後から戻す)。

    sudo chmod 666 /opt/redmine-4.1.1-5/apps/redmine/htdocs/log/production.log
    

    新しい環境のRedmineの実行環境のディレクトリに移動する

    cd /opt/redmine-4.1.1-5/apps/redmine/htdocs/
    

    次にDBのマイグレーションを実行する。

    sudo /opt/redmine-4.1.1-5/ruby/bin/ruby bin/rake db:migrate RAILS_ENV=production
    

    キャッシュをクリーンナップする

    sudo /opt/redmine-4.1.1-5/ruby/bin/ruby bin/rake tmp:clear

    Productionログの権限を元に戻す

    sudo chmod 644 /opt/redmine-4.1.1-5/apps/redmine/htdocs/log/production.log
    

    Apacheを起動する

    sudo /opt/redmine-4.1.1-5/ctlscript.sh start apache
    

    設定ファイルなどの変更が必要な場合には変更する。

  • WSL2でDockerを使えるようにインストールする

    メモとして。前提として、WSL2のインストールは終わっている。

    Docker Desktop for Windowsをダウンロードする。下記のURLにアクセスして、「Get Docker」からダウンロードする。

    https://hub.docker.com/editions/community/docker-ce-desktop-windows/

    ダウンロードしたインストーラー(EXEファイル)を実行する。インストールのときに、「Install required Windows components for WSL2」にチェックが入っているので、WSL2対応もばっちり。

    インストールが終わったら、Windows10の再起動が入る。

    で、なにをしたらいいのかわからないので、チュートリアルを実施。

    チュートリアルの通りにやったら、チュートリアルのコンテナが立ち上がった。

    このコンテナがどこで動いているのか気になって、WSL2のUbuntuでpsコマンドをたたいてみると、dockerに関連したプロセスが起動しているので、WSL2の上で動作していることが確認できた。

     root       185  0.0  0.5 1463396 31664 pts/1   Ssl+ 20:06   0:00 /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-n 
  • Windows 10 ver 20H2のIMEの予測変換がひどいのでオフにする

    Windows 10 Ver.20H2のIMEの予測変換がかなりひどいので、オフにしてみる。Ver.2004でもひどかったが、20H2はさらにひどい。IMEは止め時なのかもしれないが、選択肢がほぼないので、オフにして様子を見る。

    1. 右下のツールバーで、IMEを選んで、右クリックする(「A」か「あ」のアイコン)
    2. 「設定」を選ぶ
    3. 「全般」を選ぶ
    4. 「予測入力」の部分のプルダウンで、「オフ」を選択する

    これで、予測入力は使えなくなるが、誤変換や勝手に選択される問題もなくなる。

  • PHPのバージョンアップしたら、Nginxが起動しなくなった

    Ubuntu 18.04で、PHPをPHP7.2からPHP7.4にアップデートしたところ、作業後にOSを再起動したら、Nginxが起動しなくなった。原因を調べて対処したので、メモを残す。

    Nginxのステータスを確認したところ。

    ubuntu@ip-10-0-0-122:/etc/nginx$ sudo service nginx status
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Wed 2020-10-14 22:35:23 PDT; 5s ago
         Docs: man:nginx(8)
      Process: 1296 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
    Oct 14 22:35:23 ip-10-0-0-122 systemd[1]: Starting A high performance web server and a reverse proxy server...
    Oct 14 22:35:23 ip-10-0-0-122 nginx[1296]: nginx: [emerg] "try_files" directive is duplicate in /etc/nginx/sites-enabled
    Oct 14 22:35:23 ip-10-0-0-122 nginx[1296]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Oct 14 22:35:23 ip-10-0-0-122 systemd[1]: nginx.service: Control process exited, code=exited status=1
    Oct 14 22:35:23 ip-10-0-0-122 systemd[1]: nginx.service: Failed with result 'exit-code'.
    Oct 14 22:35:23 ip-10-0-0-122 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
    ubuntu@ip-10-0-0-122:/etc/nginx$
    

    PHP7.4にアップデートしたタイミングで、Apacheがインストールされて、これが自動起動しており、Nginxと、ポート80の使用が競合して、Nginxが落ちていた。apache2の自動起動を停止する。

    sudo systemctl disable apache2
    

    それでも、まだ、Nginxの起動でエラーになる。ログを見ると、コンフィグの問題のようなので、configtestを実施し、見事にエラーになる。

    ubuntu@ip-10-0-0-122:/etc/nginx/sites-available$ sudo service nginx configtest
     * Testing nginx configuration                                                                                   [fail]
    ubuntu@ip-10-0-0-122:/etc/nginx/sites-available$
    

    Nginxのコンフィグのdefaultで、php7.2-fpmの部分を、php7.4-fpmのsockに書き換え。

    その後、Nginxの起動を試すが失敗。Nginxのコンフィグチェックを行って、エラーになっている行を特定。

    sudo nginx -t
    nginx: [emerg] "try_files" directive is duplicate in /etc/nginx/sites-enabled/default:77
    nginx: configuration file /etc/nginx/nginx.conf test failed
    

    “try_files” がダブっているというので、場所を確認して、変更した。なぜ、急にエラーになったのか、はあるが、とりあえず、スルー。修正後は、Nginxが無事に起動した。

    最初のStatusのログをみると、最初から”try_files ”が問題って書いてあった。おちついて、見る必要あり。

  • Windows10 October 2020 Updateが配信された

    Windows 10 October 2020 Update (Ver 20H2)が配信されたので、早速、VAIOにWindows 10に適用した。とりあえず、動作に問題はなし。

    春のとき(Ver 2004)に廃止されていた大型アップデートを遅らせるためのGUIの画面は復活せず。それは、もう、グループポリシーで設定するしかないようだ。

    あと、Ver.20H2にすることで、EdgeがChromiumベースのEdgeに置き換わった。なので、個別にアップデートをしなくても、October 2020 Updateを入れるだけで、Edgeの更新ができる。これは管理する側からすると楽。

    バージョンは、今回は20H2となっている。これは、全部数字にすると、2010になるので、紛らわしくなるので、変えたとのこと。

    https://forest.watch.impress.co.jp/docs/news/1284147.html

  • UbuntuのPHPを7.2から、7.4にしてみた

    Ubuntu 18.04のPHPをPHP7.2からPHP7.4に上げた。PHPを使っているのは、Wordpress。そのメモ。でも、途中が消えてる気がする、というか消えてる。

    ubuntu@ip-10-0-0-122:~$ php -v
    PHP 7.2.24-0ubuntu0.18.04.7 (cli) (built: Oct  7 2020 15:24:25) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.2.24-0ubuntu0.18.04.7, Copyright (c) 1999-2018, by Zend Technologies
    ubuntu@ip-10-0-0-122:~$
    ubuntu@ip-10-0-0-122:~$ sudo apt install software-properties-common
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    software-properties-common is already the newest version (0.96.24.32.14).
    software-properties-common set to manually installed.
    The following packages were automatically installed and are no longer required:
      libdumbnet1 libnginx-mod-http-geoip libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail
      libnginx-mod-stream linux-aws-5.3-headers-5.3.0-1017 linux-aws-5.3-headers-5.3.0-1019
      linux-aws-5.3-headers-5.3.0-1023 linux-aws-5.3-headers-5.3.0-1028 linux-aws-5.3-headers-5.3.0-1030
      linux-aws-5.3-headers-5.3.0-1032 linux-aws-5.3-headers-5.3.0-1033 linux-aws-5.3-headers-5.3.0-1034
      linux-aws-5.3-headers-5.3.0-1035 linux-aws-headers-4.15.0-1041 linux-aws-headers-4.15.0-1043
      linux-aws-headers-4.15.0-1044 linux-aws-headers-4.15.0-1045 linux-aws-headers-4.15.0-1047
      linux-aws-headers-4.15.0-1048 linux-aws-headers-4.15.0-1050 linux-aws-headers-4.15.0-1052
      linux-aws-headers-4.15.0-1054 linux-aws-headers-4.15.0-1056 linux-aws-headers-4.15.0-1057
      linux-aws-headers-4.15.0-1058 linux-aws-headers-4.15.0-1060 linux-aws-headers-4.15.0-1063
      linux-aws-headers-4.15.0-1065 linux-headers-5.3.0-1035-aws linux-image-5.3.0-1035-aws linux-modules-5.3.0-1035-aws
      nginx-common nginx-core
    Use 'sudo apt autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    ubuntu@ip-10-0-0-122:~$
    ubuntu@ip-10-0-0-122:~$
    ubuntu@ip-10-0-0-122:~$
    ubuntu@ip-10-0-0-122:~$ sudo add-apt-repository ppa:ondrej/php
     Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.
    Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa
    You can get more information about the packages at https://deb.sury.org
    IMPORTANT: The -backports is now required on older Ubuntu releases.
    BUGS&FEATURES: This PPA now has a issue tracker:
    https://deb.sury.org/#bug-reporting
    CAVEATS:
    1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
    2. If you are using apache2, you are advised to add ppa:ondrej/apache2
    3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline
       or ppa:ondrej/nginx
    PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/
    WARNING: add-apt-repository is broken with non-UTF-8 locales, see
    https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:
    # LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
     More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
    Press [ENTER] to continue or Ctrl-c to cancel adding it.
    Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
    Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
    Get:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
    Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease [20.8 kB]
    Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
    Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages [71.9 kB]
    Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main Translation-en [29.5 kB]
    Fetched 374 kB in 1s (398 kB/s)
    Reading package lists... Done
    ubuntu@ip-10-0-0-122:~$
    ubuntu@ip-10-0-0-122:~$
    ubuntu@ip-10-0-0-122:~$ sudo apt update
    Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
    Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
    Get:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
    Hit:4 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
    Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
    Fetched 163 kB in 0s (399 kB/s)
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    20 packages can be upgraded. Run 'apt list --upgradable' to see them.
    ubuntu@ip-10-0-0-122:~$
    ubuntu@ip-10-0-0-122:~$ php -v
    PHP 7.4.11 (cli) (built: Oct 10 2020 19:44:50) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.11, Copyright (c), by Zend Technologies
    ubuntu@ip-10-0-0-122:~$
    

    このあと、Nginxのコンフィグで、php7.2-fpmからphp7.4-fpmに指定を変更して、Nginxを再起動。

    WordPressにアクセスしたら、php7.4-mysqlが入っていないと言われ、使えず。aptでインストールする。

    sudo apt install php7.4-mysql

    そのあと、Wordpressのヘルスチェックを確認。gdもないというので、aptでインストール。

    sudo apt install php7.4-gd

    これでバージョンアップは終わり。

  • apt autoremoveしたら

    aptで、個別にパッケージをdeleteしていたら、autoremoveしろと表示されたので、実行した。

    sudo apt autoremove
    

    その結果、概ね、不必要なパッケージは削除されたが、実際にサービスとして使っているパッケージも削除された。急に使えなくなったので、コマンドを調べたら存在せず。結局、もう一度、apt install した。こういうこともあるので、apt autoremove したら、機能確認はしよう。

  • WSL2でDockerを使えるようにインストールする

    自分のメモとして。

    前提として、WSL2のインストールは終わっている。

    Docker Desktop for Windowsをダウンロードする。下記のURLにアクセスして、「Get Docker」からダウンロードする。

    https://hub.docker.com/editions/community/docker-ce-desktop-windows/

    ダウンロードしたインストーラー(EXEファイル)を実行する。インストールのときに、「Install required Windows components for WSL2」にチェックが入っているので、WSL2対応もばっちり。

    インストールが終わったら、Windows10の再起動が入る。

    で、なにをしたらいいのかわからないので、チュートリアルを実施。

    チュートリアルの通りにやったら、チュートリアルのコンテナが立ち上がった。

    このコンテナがどこで動いているのか気になって、WSL2のUbuntuでpsコマンドをたたいてみると、dockerに関連したプロセスが起動しているので、WSL2の上で動作していることが確認できた。

    root      185  0.0  0.5 1463396 31664 pts/1  Ssl+ 20:06  0:00 /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-n

    Dockerのインストールというかセットアップが簡単すぎて、正直よくわからない。利用する側にしてみると、どのみちブラックボックスなので、このくらい簡単なのがいいのだろう。

  • デプロイしたアプリにアクセスしたら ”HRESULT からの例外:0x801310“ が発生した

    ASP.NET(MVC5)で作成したアプリを変更してデプロイした。デプロイ後、Invoke-WebRequestでアクセスしたところ、アプリケーションエラーが発生した。エラー内容は下記。

    Invoke-WebRequest : '/API' アプリケーションでサーバー エラーが発生しました。
    ファイルまたはアセンブリ 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicK
    eyToken=31bf3856ad364e35'、またはその依存関係の 1 つが読み込めませんでした。見つかったアセンブリのマニフェスト定義はア
    センブリ参照に一致しません。 (HRESULT からの例外:0x80131040)
    説明: 現在の Web 要求を実行中に、ハンドルされていない例外が発生しました。エラーに関する詳細および例外の発生場所について
    は、スタック トレースを参照してください。
    例外の詳細: System.IO.FileLoadException: ファイルまたはアセンブリ 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform,
    Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'、またはその依存関係の 1 つが読み込めませんでした。見
    つかったアセンブリのマニフェスト定義はアセンブリ参照に一致しません。 (HRESULT からの例外:0x80131040)
    ソース エラー:
    現在の Web 要求の実行中にハンドルされていない例外が生成されました。障害の原因および発生場所に関する情報については、下の
    例外スタック トレースを使って確認できます。
    アセンブリ読み込みトレース: 以下の情報は、アセンブリ 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1
    .0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' を読み込めなかった原因を調べるのに役立ちます。
    警告: アセンブリ バインドのログ記録がオフにされています。
    アセンブリ バインドのエラー ログを有効にするには、レジストリ値 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) を 1
    に設定してください。
    注意: アセンブリ バインドのエラー ログに関連するパフォーマンス ペナルティがあります。
    この機能をオフにするには、レジストリ値 [HKLM\Software\Microsoft\Fusion!EnableLog] を削除します。
    スタック トレース:
    [FileLoadException: ファイルまたはアセンブリ 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Cult
    ure=neutral, PublicKeyToken=31bf3856ad364e35'、またはその依存関係の 1 つが読み込めませんでした。見つかったアセンブリの
    マニフェスト定義はアセンブリ参照に一致しません。 (HRESULT からの例外:0x80131040)]
       System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly
    , StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
       System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly
    , StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +96
       System.Type.GetType(String typeName) +62
       System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +15
       System.Web.Compilation.CompilationUtil.GetRecompilationHash(CompilationSection ps) +2406
       System.Web.Configuration.CompilationSection.get_RecompilationHash() +110
       System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDateInternal(Int64 cachedHash) +551
       System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate(Int64 cachedHash) +59
       System.Web.Compilation.BuildManager.ExecutePreAppStart() +155
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMap
    PathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception ap
    pDomainCreationException) +746
    [HttpException (0x80004005): ファイルまたはアセンブリ 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.
    1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'、またはその依存関係の 1 つが読み込めませんでした。見つかったアセ
    ンブリのマニフェスト定義はアセンブリ参照に一致しません。 (HRESULT からの例外:0x80131040)]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737
    バージョン情報: Microsoft .NET Framework バージョン:4.0.30319; ASP.NET バージョン:4.8.4075.0
    発生場所 行:1 文字:1
    + Invoke-WebRequest http://xxxx:8080/api/xxxxCopy/
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest]、WebExce
        ption
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

    Visual Studioで開発してテストしていると何も問題がなかった。原因は、Web.configをデプロイしていなかったこと。Visual Studioの環境や.Net Framework 4.8の環境は、毎月更新されていく。その環境でコンパイルしたときに、もともとのWeb.configに記載された情報と新しくコンパイルされたものの情報が異なった。そのために、実行時にエラーになった。解決策としては、新しくコンパイルした方のWeb.configを使うこと。環境に合わせて変更する必要があれば変更する。

  • WSLからWSL2に更新する

    Windows10 Ver.1903でWSLからWSL2にしたので、メモ。WSL2が出たときの手順よりも、かなり楽になってて衝撃的だった。特に仮想マシンのプラットフォームの部分がmsiファイルでインストールではなく、コマンドで済んだので、楽。

    1. 「仮想マシン プラットフォーム」をコマンドで有効にする。

    Powershellを管理者として実行する。下記のコマンドを実行する。

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

    PCを再起動する

    2. 規定のバージョンをWSL2に変更する

    Powershellを管理者として実行する。下記のコマンドを実行する。

    wsl --set-default-version 2

    3. 既存のWSLをWSL2に変換する。

    PCにインストールされている既存のWSLの名前を下記のコマンドで確認する。

    wsl -l -v

    次にWSL2に、下記のコマンドで変換する。(Ubuntu-20.04の部分は、上記のコマンドで調べた名前を入れる)

    wsl --set-version Ubuntu-20.04 2
    

    もう一度、「wsl -l -v」コマンドを実行し、WSLのバージョンが2になっているか確認する。

    wsl -l -v

    ■実際に試したところ

    PS C:\windows\system32>  wsl --set-default-version 2
    WSL 2 との主な違いについては、https://aka.ms/wsl2 を参照してください
    PS C:\windows\system32>
    PS C:\windows\system32>
    PS C:\windows\system32>
    PS C:\windows\system32> wsl -l -v
      NAME            STATE           VERSION
    * Ubuntu-20.04    Stopped         1
    PS C:\windows\system32> wsl --set-version Ubuntu-20.04 2
    変換中です。この処理には数分かかることがあります...
    WSL 2 との主な違いについては、https://aka.ms/wsl2 を参照してください
    変換が完了しました。
    PS C:\windows\system32>
    PS C:\windows\system32> wsl -l -v
      NAME            STATE           VERSION
    * Ubuntu-20.04    Stopped         2
    PS C:\windows\system32>