WSL2のapt installエラー発生時にやったこと


はじめに

ゼロからのOS自作入門( https://book.mynavi.jp/ec/products/detail/id=121220 )の学習中に、"qemu-img create -f raw disk.img 200M" の実行でつまづいたので、エラーの内容と解決までにやったことを共有します。

エラー内容

Ubuntuのコンソールにて、qemu-imgを実行すると、qemu-utilsのインストールをうながされる。

$ qemu-img create -f raw disk.img 200M
Command 'qemu-img' not found, but can be installed with:
sudo apt install qemu-utils

$ sudo apt install qemu-utils を実行すると、下記のエラーが発生しました。

Err:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 qemu-block-extra amd64 1:4.2-3ubuntu6.12
  404  Not Found [IP: 91.189.88.142 80]
Err:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 qemu-utils amd64 1:4.2-3ubuntu6.12
  404  Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu/qemu-block-extra_4.2-3ubuntu6.12_amd64.deb  404  Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu/qemu-utils_4.2-3ubuntu6.12_amd64.deb  404  Not Found [IP: 91.189.88.142 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

$ sudo apt install default-jre を実行しても同様のエラーが発生し、qemu-utilsのインストールができません。

解決までにやったこと

下記のブログを参照させていただき、apt-getの利用リポジトリを日本サーバーへ変更しました。

リポジトリを変更した後、 sudo apt-get update実行後に、sudo apt install qemu-utilsを再度実行すると正常にインストールできました。