WSL (Windows Subsystem for Linux)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

WSL (Windows Subsystem for Linux)

Post 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
Last edited by FallenAvatar on Tue Aug 30, 2016 2:13 am, edited 1 time in total.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: WSL (Windows Subsystem for Linux)

Post 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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: WSL (Windows Subsystem for Linux)

Post 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 :-( .
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: WSL (Windows Subsystem for Linux)

Post 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.
Boris
Member
Member
Posts: 145
Joined: Sat Nov 07, 2015 3:12 pm

Re: WSL (Windows Subsystem for Linux)

Post 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/
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: WSL (Windows Subsystem for Linux)

Post 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.
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: WSL (Windows Subsystem for Linux)

Post 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.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: WSL (Windows Subsystem for Linux)

Post 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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: WSL (Windows Subsystem for Linux)

Post 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.
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: WSL (Windows Subsystem for Linux)

Post 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.
User avatar
crunch
Member
Member
Posts: 81
Joined: Wed Aug 31, 2016 9:53 pm
Libera.chat IRC: crunch
Location: San Diego, CA

Re: WSL (Windows Subsystem for Linux)

Post 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.
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: WSL (Windows Subsystem for Linux)

Post 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
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: WSL (Windows Subsystem for Linux)

Post by Roman »

@crunch, you could use e2tools for that.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: WSL (Windows Subsystem for Linux)

Post 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.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: WSL (Windows Subsystem for Linux)

Post 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.
Post Reply