New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run any Distro in WSL #992

Closed
Guerra24 opened this Issue Aug 26, 2016 · 30 comments

Comments

Projects
None yet
@Guerra24
Copy link

Guerra24 commented Aug 26, 2016

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:

  • An Arch installation compressed inside a tar.

Steps

  • Run Bash, decompress(inside WSL, use sudo) the Arch tar.
  • Now exit bash and go to lxss directory.
  • Rename the actual rootfs to rootfs_old, now go inside your user's home and move(copy&paste don't work) the arch folder to the lxss folder and rename it to rootfs.
  • Now set the default user to root.
  • Run Bash.

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

This comment has been minimized.

Copy link

fpqc commented Aug 26, 2016

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

@Guerra24

This comment has been minimized.

Copy link

Guerra24 commented Aug 26, 2016

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

@fpqc

This comment has been minimized.

Copy link

fpqc commented Aug 26, 2016

@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

This comment has been minimized.

Copy link

goreliu commented Aug 26, 2016

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

This comment has been minimized.

Copy link

TooYoungTooSimp commented Aug 26, 2016

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

@Guerra24

This comment has been minimized.

Copy link

Guerra24 commented Aug 26, 2016

@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

This comment has been minimized.

Copy link

sthalik commented Aug 26, 2016

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

@russalex russalex added the discussion label Aug 26, 2016

@iz0eyj

This comment has been minimized.

Copy link

iz0eyj commented Aug 27, 2016

@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

This comment has been minimized.

Copy link

fpqc commented Aug 27, 2016

@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

This comment has been minimized.

Copy link

iz0eyj commented Aug 27, 2016

@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

This comment has been minimized.

Copy link

fpqc commented Aug 27, 2016

@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

This comment has been minimized.

Copy link

TooYoungTooSimp commented Aug 27, 2016

@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

This comment has been minimized.

Copy link

Guerra24 commented Aug 27, 2016

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

@fpqc

This comment has been minimized.

Copy link

fpqc commented Aug 27, 2016

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

@ghost

This comment has been minimized.

Copy link

ghost commented Aug 27, 2016

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

  • fakeroot not work (Because chroot cannot work),It will cause pacman report this error when install some packages:

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

This comment has been minimized.

Copy link

fpqc commented Aug 27, 2016

@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

This comment has been minimized.

Copy link

fpqc commented Aug 27, 2016

@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

This comment has been minimized.

Copy link
Contributor

russalex commented Aug 27, 2016

@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

This comment has been minimized.

Copy link

fpqc commented Aug 28, 2016

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

This comment has been minimized.

Copy link

TooYoungTooSimp commented Aug 28, 2016

@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

This comment has been minimized.

Copy link

fpqc commented Aug 28, 2016

@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

This comment has been minimized.

Copy link

TooYoungTooSimp commented Aug 28, 2016

@fpqc It works! Thank you for your help!

@Sazpaimon

This comment has been minimized.

Copy link

Sazpaimon commented Sep 2, 2016

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
3. 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

This comment has been minimized.

Copy link

cnd commented Sep 16, 2016

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

cnd added a commit to cynede/portage that referenced this issue Sep 16, 2016

Handle situation with invalid entries in /proc/self/mountinfo
That fixes Gentoo installation won WLS
Source: Microsoft/WSL#992 (comment)
Can reproduce on two machines

cnd added a commit to cynede/portage that referenced this issue Sep 16, 2016

Handle situation with invalid entries in /proc/self/mountinfo
That fixes Gentoo installation won WLS
Source: Microsoft/WSL#992 (comment)
Can reproduce on two machines

zmedico added a commit to zmedico/portage that referenced this issue Sep 18, 2016

Handle situation with invalid entries in /proc/self/mountinfo
That fixes Gentoo installation won WLS
Source: Microsoft/WSL#992 (comment)
Can reproduce on two machines

zmedico added a commit to zmedico/portage that referenced this issue Sep 18, 2016

Handle situation with invalid entries in /proc/self/mountinfo
That fixes Gentoo installation won WLS
Source: Microsoft/WSL#992 (comment)
Can reproduce on two machines

zmedico added a commit to zmedico/portage that referenced this issue Sep 18, 2016

writeable_check: handle invalid entries in /proc/self/mountinfo
That fixes Gentoo installation won WLS
Source: Microsoft/WSL#992 (comment)
Can reproduce on two machines
@hachre

This comment has been minimized.

Copy link

hachre commented Oct 24, 2016

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!

@Vaporeon

This comment has been minimized.

Copy link

Vaporeon commented Apr 13, 2017

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

This comment has been minimized.

Copy link
Contributor

aseering commented Apr 14, 2017

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

@Vaporeon

This comment has been minimized.

Copy link

Vaporeon commented Apr 15, 2017

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

@turbo

This comment has been minimized.

Copy link

turbo commented May 31, 2017

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

monsieurp added a commit to monsieurp/portage that referenced this issue Mar 12, 2018

writeable_check: handle invalid entries in /proc/self/mountinfo
That fixes Gentoo installation won WLS
Source: Microsoft/WSL#992 (comment)
Can reproduce on two machines
@benhillis

This comment has been minimized.

Copy link
Member

benhillis commented May 24, 2018

More distrubitons have been added with others on the way.

@benhillis benhillis closed this May 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment