6

I have an existing Dualboot-Setup with Windows 11 and Arch Linux, managed by grub.

Is it possible to use my Arch System as WSL in Windows?

$ lsblk -f
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1
|
|-nvme0n1p1
|    vfat   FAT32       73A8-FF43                             451.3M    12% /boot
|-nvme0n1p2
|    swap   1           23fe1eb0-971a-455f-bb80-301c0eb7eed5                [SWAP]
|-nvme0n1p3
|    ext4   1.0         702789b8-6895-4117-98f3-56908ea027d0  180.4G     3% /
`-nvme0n1p4
     ext4   1.0         9ac9ebb5-c604-4d89-875d-89590ff43db6    672G     0% /home
nvme1n1
|
|-nvme1n1p1
|    vfat   FAT32 SYSTEM
|                       BABE-8522
|-nvme1n1p2
|
|-nvme1n1p3
|    ntfs         Windows
|                       EC0AC1070AC0CFAE                      402.8G    15% /windows
`-nvme1n1p4
     ntfs         WinRE_DRV
                        0EFEC19BFEC17C09
4
  • Isn't this more like a Windows problem? As in: Should be on SuperUser? Commented Dec 23, 2021 at 14:52
  • 1
    I’m voting to close this question because it belongs on SuperUser. (I am adding this as another comment since this option was not available under "This question belongs on another site in the Stack Exchange network")
    – maddingl
    Commented Dec 23, 2021 at 15:00
  • @AlexStragies You might think, but I recommended that it be posted here (after it was originally on Stack Overflow) because the methods needed to do this really require much more Linux knowledge than Windows. The question works on either site, of course. Commented Dec 27, 2021 at 13:36
  • 1
    @NotTheDr01ds but this site assumes zero Windows knowledge.
    – A.B
    Commented Dec 27, 2021 at 18:22

1 Answer 1

2

There is, to my knowledge, no current way to actually bootstrap a WSL instance off of a drive that wasn't "initialized" by WSL in the first place.

There are at least two possible workarounds, though. Both require Windows 11, or at least a developer/Insider build of Windows 10.

  1. If you simply want to access the files on your Arch partitions from inside a different WSL2 instance, then should be fairly straightforward. You can mount the existing physical partitions using the Microsoft instructions documented here.

  2. If you actually want to use those Arch partitions under WSL2, then that's quite a bit more complicated, but likely still possible by setting it up for chroot access under a separate WSL2 instance.

    This comes with several huge caveats:

    • WSL2 doesn't directly support Systemd. There are ways to get it running, but they are hacky workarounds.
    • Related -- Since a lot of the startup of your Arch system likely depends on Systemd, you'll need to start most of the necessary services yourself through other means.
    • Even if you did run Systemd, there are things that it would do which would expect physical hardware to be available. For instance, it would attempt to start X/Wayland. For WSL, that needs to be handled by the WSLg instance.

    If this is the route you want to take, then you'll need to:

    • Mount the necessary Linux partitions per that same WSL2 doc for mounting a partitioned disk.

    • Create a minimal "bootstrap" WSL2 instance. If this is a long-term solution, then I'd probably go with Alpine as the base distribution for this since it is so "lean", but it might be easiest to start with some more "full-featured" (out of the box) like Ubuntu. I've used my existing Ubuntu distribution for a similar chroot in the past.

    • Create a directory for the chroot.

    • sudo mount --bind (bind mount) the mounted partitions from their default location (usually /mnt/wsl) to the appropriate locations (i.e. the chroot directory itself for the rootfs partition, and the home directory inside it, of course, for the /home partition).

    • The trickiest part is making all of the WSL special mounts and sockets available to the chroot. I've done this before as documented here, and it should be similar for Arch. That said, make sure you document any changes you made so that you can "back them out" if needed to change back to using them for the dual-boot.

      WSL usually sets up most of this for you via its /init process, but in a chroot you need to do it manually. The directories, files, and sockets involved are, at least:

      • /mnt/wsl: includes the resolv.conf generated by WSL for use with Windows networking
      • /etc/resolv.conf: needs to be symlinked to the generated version.
      • /mnt/wslg: for communication with the WSLg Weston distribution for running graphical apps
      • mnt/wslg/.X11-unix/ (the X socket)
      • /run/WSL: For Interop with Windows
      • /dev
      • /proc
      • /dev/pts
      • /sys
      • /binfmt_misc: For running Windows .exe's

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .