Can you use BuildRoot with Windows Subsystem for Linux......
A quick noteI started this blog post back in August of 2018 and never completed it. Essentially I wrote most of it and then found I just couldn't run BuildRoot properly, I came back to it every Windows 10 release due to performance improvements etc however its only now with WSL2 that this is possible. Read on to find out the full story :)
Original PostI love Windows Subsystem for Linux, I mention it all the time in work, done "brown bag" sessions on it, even did a lightning talk on it at DDDSW 18.
This week I've been working with a contractor to produce essentially an Embedded OS for a project. Previously I've always used existing distributions and made them "lite" or used preconfigured ones, Raspbian Lite for example however he promptly told me I'm doing it wrong and that I shoudl be using BuildRoot.
Buildroot is a simple, efficient and easy-to-use tool to generate embedded Linux systems through cross-compilation.Sound's interesting but what does it do....
In essence as I understand it (which could be wrong / nieve) it allows you to define a build process that allows you to produce your own flavour of a Linux distribution, meaning it only contains the packages you need. No extra random stuff, you have as small distribution as you need and hopefully far more secure as you haven't included things you don't need and could "expose" you.
Sounds great. The contractor got on with building us a base OS to get a feel for the system and showed us how we can then pull in our software as packages into the OS. I'm working on a big puse to get our software converted to .Net Core and running on Linux and this is one of the hurdles of making it possible.
Today he said, go checkout the git repo on your Ubuntu VM and run the build script..... So I did and was amazed how it "just worked" once I had got the missing dependencies installed...... I didn't have make installed and apparently this means I'm not a real embedded developer.
Great, but I hate having to run VM's and having to introduce a new Ubuntu or Debian VM for all the other dev's and even Build Agent into our TFS infrastructure didn't really feel me with joy.
So I threw down a challenge, can't I just do this without the VM by using Windows Subsytem for Linux??? If I could it wouldn't be tied down to what ever CPU and memory resource I allocated the VM, it could use *all* of my cores and memory if it wanted.....
So I cracked open WSL (i used my Ubuntu one, but Debian etc would work the same) again installed all the dependencies checked out our git repo and then ran the build script......
Some long time later....
Yup it used *all* of my CPU's thats my Xeon E5-1620 100%, quad core with hyperthreading at 3.5Ghz is apparently not enough....
You can see all of the Linux processes running within Task Manager as well.
Some time later still.... The build root process just failed :(. I kept getting intermitent I/O related errors and no matter how many times I rebuilt it failed. However it worked fine in a VM. From some reading on the internet WSL does have some I/O issues, particulary around git and other applications that are quite intensive.
So originally I gave up on this and stuck to my Ubuntu VM. However with the 1903 release of Windows 10 I noted several improvements to WSL so took up the challenge again. This time things appeared to go alot faster, however eventually I hit a new road blocker I got
Fail. So close yet so far. For now I'm giving up again however at Build 2019 WSL 2 was announced which uses an actual Linux Kernel, this could fix the issue as more kernel calls are implemented etc. I will wait and see.fakeroot, while creating message channels: Function not implementedThis may be due to a lack of SYSV IPC support.fakeroot: error while starting the `faked' daemon.
But the story isn't over yet! Tonight I took the plunge and got the latest Windows 10 Insider Preview and got the all important WSL2! First of all you have to convert your previous distribution to use V2, to do this within a command prompt simply type:
wsl --set-version [distributionname] 2
Now this process does take some time, it also eats alot of disk space during the process as the image is being translated over, I ran out midway through and got "unspecified error" however once I had tidied up my main disk the conversion ran without a problem.
Then came the all important test... I ran my build root script .... ./BUILDME.sh
It's worth pointing out that I can no longer see all of the individual Linux processes, I'm told that this is on the backlog and it'd due to WSL 2 now using it's super small Linux kernel.
After not too long...
So after almost a year later I can safely say YES you can use Windows Subsystem for Linux to make build root builds!
For reference for this blog post I was building Raspberry PI's Noobs project as my test as it's sufficently large and a well known entity.
This leaves me more excited for the possibility of using WSL in my day to day work life. I use it currently for .Net Core Linux testing but always at some point have to switch to my VM, it now feels once WSL 2 is RTM'd my VM's days are numbered!