Page 1 of 5

WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 12:48 am
by FallenAvatar
Hi all,

First off, Mods, if you feel there is a better place for this, feel free to move it.

For anyone who (like me) has Windows 10, you can now install the anniversary update for Windows 10 (if you haven't already), and therefore have access to WSL. WSL is the Windows Subsystem for Linux, very similar to SUA, or Cygwin/MinGW/DJGPP except its fully supported/maintained/"created" by M$. To install it (If you have all the appropriate updates) goto your control panel, (and make sure you aren't looking at categories) then select/click Programs and Features. In the left hand menu you can find "Turn Windows features on or off" and in that window you need to check "Windows Subsystem for Linux (Beta)". After it is installed, you MUST (Yes MUST) reboot. I know most updates/installs do not actually care if you reboot, this one does! After reboot, you can run Bash from your start menu, this will trigger a brief setup process and then you will have a "full" install of Ubuntu (14.04) running side-by-side with your normal Windows GUI.

Please realise, this is a side-by-side "install"! WSL can not directly interact with your desktop session, and vice verse. That being said, it is more integrated than any other option in the past. From inside of Bash, you can view, edit, create, and delete from your Windows files easily enough through "/mnt/[drive letter]/path/to/file" and you can view your "linux" files in "%APPDATA%\Local\lxss". The only thing to remember is that while any instance of Bash is running, any changes you make in Windows in "%APPDATA%\Local\lxss" will not be visible from within WSL/Linux due to caching. I work around this by sym-linking a folder or 2 that use frequently into my home dir.

Also, worth note is that from Windows, you can "run" a shell script (*.sh) and Windows will open a bash session, run the script and exit (Run to completion and exit). You can also run 'bash -e "path\to\script.sh"' to run a Bash script with a windows path, or "bash -c 'command -option option2'" to run a command. The first does not work correctly (as far as I'm concerned) where as the next 2 run fine in every instance I've tried. (The main difference being that the first does not produce output in a command prompt, where as the next 2 do).

All that being said, I am working on testing/"debugging" our current Bare Bone/instructions in WSL to determine what needs to be clarified. I have not start an actual tutorial yet, but I have started to list my notes on the Wiki at one of my User Pages.

Feel free to take a look at my notes, try and reproduce success (I used binutils 2.27 and gcc 6.2 for my cross compiler) in WSL, or add any additional notes you might have. I will try to combine what I find with what you guys add to create a Tutorial that can be added to Bare_Bones to help everyone.

- Monk

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 1:02 am
by Octacone
tjmonk15 wrote:WSL is running Ubuntu 14.04
No thanks! Microsoft is am disappointed with you. I would rather work with my pure up to date Ubuntu than outdated WLS.
I have Windows 10 installed on my other partition and still I haven't received anniversary update notification. I really wanted to try it out but Microsoft...
As far as I know there is a way to run native Ubuntu desktop on Windows, also hidden somewhere in the settings.
I think you should also try using pre-built toolchains and tell us how do they perform.

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 1:22 am
by onlyonemac
I've read that it doesn't even use a Linux kernel.
octacone wrote:I have Windows 10 installed on my other partition and still I haven't received anniversary update notification. I really wanted to try it out but Microsoft...
You can install it manually.
octacone wrote:As far as I know there is a way to run native Ubuntu desktop on Windows, also hidden somewhere in the settings.
It's in the "install programs" section. Make sure you've got the VirtualBox installer to hand, then go to the "install a program" section and choose the VirtualBox installer. (There's also an easier way to do it - just run the VirtualBox installer directly, like opening any other file.)

Unless you're talking about running an X session over a loopback connection to a local X server (such as Xming). EDIT: Sadly Xming seems to have switched to a proprietary licence - well I guess that means there's no easy-to-use X server for Windows anymore :-( .

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 1:47 am
by iansjack
This is a very useful addition to Windows and is, IMO, far better than cygwin or similar hybrids. Whether it is running the Linux kernel, or what version it is based on, is really irrelevant. It is a useful facility that lets you run just about any GNU tool from Windows.

Good work, Microsoft.

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 2:13 am
by Boris
iansjack wrote:Whether it is running the Linux kernel, or what version it is based on, is really irrelevant.
It's not irrelevant when you will want to compile apps for this subsystem. Do you need to use msvc, mingw or another family of libraries ? is it multilib ?

Btw Xming is still open source, see

https://sourceforge.net/projects/xming/

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 2:25 am
by jnc100
It is the Windows kernel, with support added for Linux syscalls (presumably by int 0x80), support for loading ELF executables and a internal VFS emulation. If you have that environment, then you can install any typical Linux userspace (e.g. Ubuntu) without the need for the Linux kernel itself.

It works really well and is much quicker than Cygwin particularly. The cross compiler builds at a similar speed to that when done in Linux. Also Xming does work as an X server for it.

There are still some teething issues (https://github.com/Microsoft/BashOnWindows/issues) but the developers seem to respond quickly to user problems (unlike other MS products).

Also, because it is Ubuntu, it has the grub-pc-bin package. I haven't yet tested whether this easily produces a grub-mkrescue cd (which has become a problem OS devving on Windows since this was removed from 64-bit Cygwin) but it is promising.

Regards,
John.

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 2:40 am
by linguofreak
Boris wrote:
iansjack wrote:Whether it is running the Linux kernel, or what version it is based on, is really irrelevant.
It's not irrelevant when you will want to compile apps for this subsystem. Do you need to use msvc, mingw or another family of libraries ? is it multilib ?
It does not use the Linux kernel. It uses a Windows kernel module that implements Linux system calls faithfully enough that no recompilation or patching of programs is necessary: WSL runs the stock Ubuntu userland, and I have been able to copy programs over from my Linux box and run them on WSL without modification or recompilation of any kind. It is not multilib, only 64-bit programs can be run, and it can only be installed on 64-bit Windows.

There is squirreliness around the networking implementation, ssh works, ICMP doesn't. There is no X-server provided, an existing 3rd party Windows X-server must be used, and not all of the GUI-side Linux infrastructure (dbus, etc) is present.

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 2:52 am
by jnc100
Just to follow-up, both the GCC Cross Compiler and Bare Bones tutorials work as-is with WSL (piccy). For grub, I used the grub-pc-bin package (specifically sudo apt-get install grub-pc-bin --no-install-recommends to prevent it pulling in the rest of grub) and the qemu in the repository works well with Xming (export DISPLAY=:0 before running qemu-system-i386).

Regards,
John.

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 3:24 am
by iansjack
Boris wrote:
iansjack wrote:Whether it is running the Linux kernel, or what version it is based on, is really irrelevant.
It's not irrelevant when you will want to compile apps for this subsystem. Do you need to use msvc, mingw or another family of libraries ? is it multilib ?

Btw Xming is still open source, see

https://sourceforge.net/projects/xming/
You compile just as you would on a Linux system. No compatibility libraries are required; that's rather the point of it.

Re: WSL (Windows Subsystem for Linux)

Posted: Tue Aug 30, 2016 12:35 pm
by Kazinsal
onlyonemac wrote:EDIT: Sadly Xming seems to have switched to a proprietary licence - well I guess that means there's no easy-to-use X server for Windows anymore :-( .
Xming still provides a working X11R6 server for Windows for free. It's old, but it still works. Scroll down to find the link for version 6.9.0.31 -- its state is labeled as Public Domain.

One thing I haven't tested yet is audio and video decode, but I can build and test my OS on it with the exact same tools and result as my build environment (a VM running Xubuntu 16.04).

EDIT: Iansjack beat me to the Xming bit.

Re: WSL (Windows Subsystem for Linux)

Posted: Thu Sep 01, 2016 8:18 am
by crunch
WSL is fantastic. I've been using it since the day it was available - and it's actually the reason I started up my osdev project again after a long time.

Needless to say, I do all my development in WSL. Cross compiler works great...user land programs work great.
Pretty much all Linux tools run natively in it. The only thing I've found that you can't do is mount images. So I wrote a program (based on my OS's driver) to read and write files on ext2 disk images.

Re: WSL (Windows Subsystem for Linux)

Posted: Thu Sep 01, 2016 8:30 am
by Techel
I have heard of this Subsystem, but didn't know it's already available. I'll drop mingw and cygwin to the bin, and finally being able to compile a gcc :o

Re: WSL (Windows Subsystem for Linux)

Posted: Thu Sep 01, 2016 11:57 am
by Roman
@crunch, you could use e2tools for that.

Re: WSL (Windows Subsystem for Linux)

Posted: Thu Sep 01, 2016 1:23 pm
by onlyonemac
Kazinsal wrote:
onlyonemac wrote:EDIT: Sadly Xming seems to have switched to a proprietary licence - well I guess that means there's no easy-to-use X server for Windows anymore :-( .
Xming still provides a working X11R6 server for Windows for free. It's old, but it still works. Scroll down to find the link for version 6.9.0.31 -- its state is labeled as Public Domain.
I suppose there is still that, but it always disappoints me when a project moves away from open licensing, especially when they're meeting a userbase that doesn't have any alternatives.
Techel wrote:I have heard of this Subsystem, but didn't know it's already available. I'll drop mingw and cygwin to the bin, and finally being able to compile a gcc :o
Don't, please don't, discard cygwin. Cygwin's a valuable open source project, and by discarding it for WSL you're just saying "I don't care about open source, I just want to run Linux tools on Windows" and helping M$ take over a need which has already been filled by cygwin.

Re: WSL (Windows Subsystem for Linux)

Posted: Thu Sep 01, 2016 1:55 pm
by Techel
Yeah, I wonder what will happen to these projects. On the other side having a linux on windows, for me at least due to visual studio, which works easily is pretty handy.