microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.47k stars 822 forks source link

Run any Distro in WSL #992

Closed Guerra24 closed 6 years ago

Guerra24 commented 8 years ago

First was a DE, now is time to run another distro, the process is simple but time consuming.

Running Arch For running Arch in WSL you need:

Steps

That's it, very simple but time consuming like I said. The Arch instalation that I used was provided by @matiuri. The same process applies to other distros.

ss 2016-08-26 at 02 36 10

Any problem please leave a comment and I will help you.

fpqc commented 8 years ago

Um, this doesn't seem like it will work unless you do the untar+edit fstab step inside of WSL.

Guerra24 commented 8 years ago

@fpqc The fstab edit can be done before compression, is trivial.

fpqc commented 8 years ago

@guerra24 This seems a whole lot more annoying and difficult than the methods in the linked thread. For one, it requires you to build and set up an arch tarball. I expect that there could be a number of network config problems if you just tarred up your arch system's rootfs including /etc.

goreliu commented 8 years ago

It's not necessary to edit fstab, just leaving an empty fstab also works. And no network problems will happen, WSL doesn't care any network config, and none of ifconfg/ip/dhcpcd/iwconfig/netctl/... will work.

TooYoungTooSimp commented 8 years ago

@Guerra24 How can I get an Arch tar? Using a virtual machine or ?

Guerra24 commented 8 years ago

@fpqc Really no, I never changed any configuration and network is ok, but this method will work with any distro, not only arch.

@crazymonkeylyc Yea, install arch in a VM then compress all files inside a tar and use that.

sthalik commented 8 years ago

Just update to Debian sid inplace but hold the libprocps3 and procps packages. Otherwise top(1) stops working.

iz0eyj commented 8 years ago

@russalex Hi Alex, what percentage of the good work you are doing is the result of Canonical? or WSL layer is only by Microsoft?

fpqc commented 8 years ago

@iz0eyj For legal reasons, pretty much all of the work has to be done by Microsoft, by a team that has not read the Linux Kernel sourcecode or decompiled it.

Also, his name is Russ Alexander, not Alex, lol.

iz0eyj commented 8 years ago

@fpqc I'm sorry for the name :)

Thanks for the answer, I think "Linux Kernel sourcecode" is "Win kernel source code", right? Another question, do you know if exists a list for System Calls supported by WSL?

fpqc commented 8 years ago

@iz0eyj I'm not sure if a full list exists as one file, but if you read the changelogs:

https://msdn.microsoft.com/en-us/commandline/wsl/release_notes

You can read all of the syscalls implemented version-by-version.

TooYoungTooSimp commented 8 years ago

@Guerra24 Thank you for your guide, but after I decompressed the arch tar to rootfs, I got 0x8007001f error when I tried to get into bash. Could you tell me more things about this? such as the command line on tar etc.

Guerra24 commented 8 years ago

@crazymonkeylyc Where did you decompressed arch? Inside Windows or WSL?

fpqc commented 8 years ago

@Guerra24 lol this was exactly what I was saying would happen if people followed those instructions you gave........

ghost commented 8 years ago

I used airrootfs.sfs in Arch Linux Installation ISO and managed to run it.Except some problems:

could not change the root directory (Function not implemented) error: command failed to execute correctly

  • systemctl not work because "Failed to connect to bus: No such file or directory".
  • makepkg cannot run as root,but if you use useradd command to create a user,you will cannnot use su command to change to it because "su: failed to execute /bin/bash (or other shell like /bin/zsh) : Permission denied"
fpqc commented 8 years ago

@KenOokamiHoro I tried messing around with Arch, and there are a few problems that have workarounds for the lack of chrooting, but they don't work all that well. I would suggest holding off on using Arch until chroot is supported. I tested it extensively last night and gave up after pacman started installing packages and telling me they were inaccessible (and I had to manually chmod them to fix it).

If you want to test the workarounds yourself, check out #8

fpqc commented 8 years ago

@SRGOM You need chrooting for "Use Privilege Separation" in sshd. I'm 80% sure that I saw the WSL devs mention that it's planned. One of the development situations we're talking about here is using Visual Studio's new Linux build plugin without running a separate VM for compiling with gcc, and right now the way you do this is by connecting Visual Studio by ssh to a Linux VM for building. It's, I think, one of the original use cases.

russalex commented 8 years ago

@iz0eyj, wanted to jump in here for just a minute and confirm what @fpqc stated. WSL contains no code from Canonical or from the Linux kernel (nor do we read their source). You can read a bit more about what we do on our blog as we are trying to be very open about our implementation. Oh, and no worries about the name, very common mistake.

Also, for the record, we are working on supporting chroot.

fpqc commented 8 years ago

By the way, I would like to plug this nice project https://github.com/RoliSoft/WSL-Distribution-Switcher

It handles everything pretty nice and safe, and with Insider build 14905, I have got ubuntu:devel (yakkety) working with no hacks and no problems.

I don't suggest using distros other than Ubuntu or Debian atm, because their package managers are using unsupported syscalls (pacman makes extensive use of chroot, and the current hacks to fix in #8 only lead to a semi-broken system. I understand that there is a similar problem with CentOS and Redhat). Also, read the instructions on how to enable the sample postinstall script, or you will end up with locale and sudo problems.

I request that the OP move this into the top post, since it is a much preferred alternative to the procedure he described above.

TooYoungTooSimp commented 8 years ago

@Guerra24 Thanks for your reply. I executed "pacstrap -i /mnt base base-devel". mounted my USB to /media and did "tar -cvf /media/arch.tar /mnt". After that, I use bash on windows to decompress arch.tar in C:\ (tar -xvf arch.tar). rename the /mnt to rootfs ,and move it to %LOCALAPPDATA%\lxss. Then I tried to get into the bash, but got 0x8007001f. That is all.

fpqc commented 8 years ago

@crazymonkeylyc you need to untar it inside of VolFS, or else it loses all of the permissions and linux data and breaks it. You could sudo untar it to /root/rootfs_tmp, then move it in windows. That's why the above instructions are bad.

TooYoungTooSimp commented 8 years ago

@fpqc It works! Thank you for your help!

Sazpaimon commented 8 years ago

In case anyone is curious, I managed to get Gentoo working using https://github.com/RoliSoft/WSL-Distribution-Switcher by simply using the Gentoo stage3 tarball as the rootfs instead of a docker image. From there I followed the standard Gentoo installation process of installing portage. There were a few gotchas though:

  1. I had to edit /usr/lib64/python2.7/site-packages/_emerge/AbstractEbuildProcess.py and set _enable_ipc_daemon to False as IPC isn't supported as of yet (#1016). I would also recommend setting the -ipc USE flag in your make.conf file. You can also add sys-apps/portage -ipc to your /etc/portage/profile/package.use.force file to allow disabling IPC if you ever rebuild or upgrade portage before #1016 is fixed
  2. I had to edit /usr/lib64/python2.7/site-packages/portage/util/writeable_check.py and replace:
 attr2 = mount[1].split()[2]

with:

try:
    attr2 = mount[1].split()[2]
except IndexError:
    attr2 = mount[1].split()[1]

This is because WSL, at least for this machine, had invalid entries for /home and /root in /proc/self/mountinfo. However, I didn't have the same behavior on another machine, so this step wouldn't be required there. YMMV

  1. Perl modules would not install properly unless I applied the workaround in #186, except in Gentoo the file I had to edit was /usr/lib/perl5/5.20.2/x86_64-linux/Config.pm

Once those fixes were in place I was able to build packages just fine. I'd also suggest putting the lxss rootfs in your antivirus exclusion list, and windows search indexer exclusion list as emerge downloads lots of source files, and having the rootfs not excluded can slow down things significantly.

Oh and I also wouldn't suggest turning on emerge in parallel mode. Parallel builds works by limiting the number of parallel builds to the load average you provide (as well as a max number of builds). However WSL hardcodes the load average to 0.52, 0.58, 0.59, so Portage has no way of knowing if it's overloading the CPU with too many parallel builds. For now, I would suggest running a single build at a time with the -j option to make to at least the single build will run faster.

cnd commented 8 years ago

@Sazpaimon for me it was /usr/lib64/python3.4/ but thanks a lot

hachre commented 8 years ago

Does locale-gen work for you? I get file not found errors even though the specified locale files exist.

error

Edit: I found a solution. I went to /usr/share/i18n/charmaps and did gzip -d UTF-8.gz. For whatever reason this fixed the problem!

Aerocatia commented 7 years ago

So I installed Arch using this guide: https://www.reddit.com/r/bashonubuntuonwindows/comments/5vnne8/howto_installing_arch_on_wsl_manually/

Everything worked as expected and Pacman is running rather well. Setting the locale has failed however. Running locale-gen fails with this error:

Generating locales... en_US.UTF-8...localedef: ../sysdeps/unix/sysv/linux/spawni.c:360: __spawnix: Assertion `ec >= 0' failed. /usr/sbin/locale-gen: line 41: 36 Aborted (core dumped) localedef -i $input -c -f $charset -A >/usr/share/locale/locale.alias $locale

Anyone know a workaround? The Arch Repos and AUR have proven to be very useful.

aseering commented 7 years ago

@Vaporeon -- a similar issue is reported on #1878 . Does the workaround there help you?

Aerocatia commented 7 years ago

I instead worked around it by running locale-gen on a "real" Arch install and copied the generated file into the WSL instance.

turbo commented 7 years ago

The posix spawn issue fix is currently being merged into the http://github.com/alwsl/alwsl Arch Linux for WSL installer.

benhillis commented 6 years ago

More distrubitons have been added with others on the way.