我可以编辑 wsl.conf 以修复无法启动的虚拟机吗?

huangapple go评论66阅读模式
英文:

Can I edit wsl.conf for vm which fails to boot?

问题

我在Windows10上安装了Fedora38,按照https://www.linuxfordevices.com/tutorials/linux/install-fedora-on-windows的步骤进行操作。一切顺利。

然后我尝试切换Fedora以使用systemd,通过创建/etc/wsl.conf文件,内容如下:

[boot]
systemd=true

我猜我应该先安装systemd包,因为我遇到了以下错误:

PS C:\Users\xxxxx> wsl
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED

现在的问题是,我可以编辑wsl.conf以阻止虚拟机启动吗?

英文:

I installed Fedora38 on Windows10 following https://www.linuxfordevices.com/tutorials/linux/install-fedora-on-windows.
That was OK.

Then I tried to switch fedora to use systemd, by creating /etc/wsl.conf as

[boot]
systemd=true

I guess I should install systemd pkg first,
because I got

PS C:\Users\xxxxx> wsl
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED

Now the question is can I edit wsl.conf for not-booting VM ?

答案1

得分: 1

Mounting the vhdx image file on another distro made possible to edit the /etc/wsl.conf on faulty system.

On Windows:

wsl -d <working system> --mount --vhd <path to image>/<image name>.vhdx --bare

Example: wsl -d Ubuntu-20.04 --mount --vhd c:\wsl\vms\Ubuntu-22.04\Ubuntu-22.04.vhdx --bare

Inside the working system:

  1. Mount the device on a mount point (Example: $ sudo mount /dev/sdc /mnt);

Note: You can use lsblk to discover the new /dev/sd?

  1. Edit the /etc/wsl.conf, removing the [boot] systemd=true part;
  2. Umount and exit the system.

Back on Windows, umount the image:

wsl --unmount \\?\c:\wsl\vms\Ubuntu-22.04\Ubuntu-22.04.vhdx

Example: wsl --unmount \\?\c:\wsl\vms\Ubuntu-22.04\Ubuntu-22.04.vhdx

Check if the former faulty system boot up.

英文:

Mounting the vhdx image file on another distro made possible to edit the /etc/wsl.conf on faulty system.

On Windows:

wsl -d &lt;working system&gt; --mount --vhd &lt;path to image&gt;\&lt;image name&gt;.vhdx --bare

Example: wsl -d Ubuntu-20.04 --mount --vhd c:\wsl\vms\Ubuntu-22.04\Ubuntu-22.04.vhdx --bare

Inside the working system:

  1. Mount the device on a mount point (Example: $ sudo mount /dev/sdc /mnt);
    > Note: You can use lsblk to discover the new /dev/sd?

  2. Edit the &lt;mount point&gt;/etc/wsl.conf, removing the [boot] systemd=true part;

  3. Umount and exit the system.

Back on Windows, umount the image:

wsl --unmount \\?\&lt;path to image&gt;\&lt;image name&gt;.vhdx

Example: wsl --unmount \\?\c:\wsl\vms\Ubuntu-22.04\Ubuntu-22.04.vhdx

Check if the former faulty system boot up.

huangapple
  • 本文由 发表于 2023年5月18日 08:59:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277105.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定