Skip to content
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

Microsoft should provide a static linked /init - Process #229

Closed
hackerswork opened this issue Apr 19, 2016 · 9 comments
Closed

Microsoft should provide a static linked /init - Process #229

hackerswork opened this issue Apr 19, 2016 · 9 comments
Assignees

Comments

@hackerswork
Copy link

With a static linked bash and a static linked busybox it is possible to reduce the WSL - system
to the bare minimum with only three executeables: /init, /bin/bash and the busybox - system
(executable and symlinks in /bin /usr/bin /usr/sbin /sbin).

With a static linked init - process we could get rid of /lib64 and /lib/x64_86-linux-gnu.
This in turn would allow to construct or use a distribution (with busybox as bootstrap) without any dependencies.

Appendix: How to make a minimal WSL - system

I assume you have built or downloaded a static linked bash (bash) and a busybox - system
(busybox and busybox.tar) and is available in C:\Install

cd /

cp /mnt/c/Install/bash /
cp /mnt/c/Install/busybox /

exec /bash

/busybox rm -rf /boot
/busybox rm -rf /bin
/busybox rm -rf /usr
/busybox rm -rf /sbin
/busybox rm -rf /etc/*
/busybox ln -s /run/resolvconf/resolv.conf /etc
/busybox tar -xf /mnt/c/Install/busybox.tar

cp /bash /bin/bash

At this point, the busybox - system is working

Now:
Empty /var
Empty /lib but leave /lib/x64_86-linux-gnu

Conclusion: In order to play with the WSL - system it should be as standalone as possible

@stehufntdev
Copy link
Collaborator

Thanks for the feedback. There's a related discussion in #8 if you are interested, and here's the short summary:

For now WSL is scoped to delivering a solid bash shell but there are many other exciting potential applications of the technology, including allowing people to select their distro of choice.

@benhillis
Copy link
Member

benhillis commented Sep 19, 2017

We've changed the init daemon over to be a statically linked, this will be available in a Windows Insider build soon.

@therealkenc
Copy link
Collaborator

Nice 💯. Of course, this is a bad case of "careful what you wish for". Now I can't LD_PRELOAD the thing. Stashing the old binary while I still can 😉.

@DDoSolitary
Copy link

I can confirm that it works on the latest insider build, thanks!

@jstarks
Copy link
Member

jstarks commented Nov 13, 2017

@therealkenc Out of curiosity, what are you LD_PRELOADing?

@therealkenc
Copy link
Collaborator

@jstarks - It was more of a tounge-in-cheek hypothesis rather than something I got around to trying. This stems from taking the briefest of looks back in August #2372 (message). As long as init was calling into dynamic glibc I figured it should be possible get in underneath and watch the library calls fly by, either by proxy or by swapping out glibc outright. It would not surprise me in the least if you say that is now not possible, regardless of whether I have set the old binary to the side.

@Biswa96
Copy link

Biswa96 commented Jan 1, 2018

How can I get BusyBox binary with bash applet in-build? Or do I compile it myself? I want to make a symbolic link from bash to busybox. So that the tar.gz file will have only one file.

@fcicq
Copy link

fcicq commented Jan 1, 2018

@Biswa96 hint is enable IF_FEATURE_BASH_IS_ASH, I guess you have to do the compile.

@Biswa96
Copy link

Biswa96 commented Apr 14, 2018

@benhillis LxssManager.dll doesn't add the file creation time of init during resource extraction. LxssManager.dll only set the 755 permission and LXATTRB attribute with EaBuffer.

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

No branches or pull requests

9 participants