# Dynamic busybox in initramfs.

## dE_logics

Since busybox wont compile with static use (reported bug), I decided to use the stock dynamically linked init that's installed.

So I ldd ed and copied over the libraries -> The result is a kernel panic cause it couldn't find init (it said pass init= parameter).

Yes, init has o+wx,u+rwx,g+rwx permissions and is in /. It's a '#! /bin/busybox sh' script.

Speaking of which, is there a proper way to debug a bad initramfs?

----------

## Sadako

Even without the static USE flag, I still get a statically linked /bin/bb, you sure you don't have the same?

As for debugging an initramfs, only thing I can recommend is testing under qemu-kvm, which can boot a linux kernel directly rather than via a bootloader.

That and a bunch of echo statemnets in your linuxrc or similar  :Razz: .

----------

## tclover

 *Sadako wrote:*   

> Even without the static USE flag, I still get a statically linked /bin/bb, you sure you don't have the same?

 

I second that, however I prefer compiling a dedicated one for initramfs because of previous weird errors with `/bin/bb'. That said I can boot just fine with the latest 1.19.3. 

Now, how busybox cannot be compiled with the newest glibc or something? I compiled that 1.19.3 a two weeks or so ago.

For debugging... well, the minimum would be to chroot directly into your initramfs folder with everything [and using busybox as sh]. You'll get something very close to what you'll get in a real world boot, but it's not exactly the same, and test your script there. Else, if you have a minimal shell that you can get dropped into without rolling out the whole init script, you can use it for testing if you don't have any VM.

EDIT: What are you trying to do with your custom initramfs? you could check out my sig for something if need be. I've put together a few interesting stuff in it.

----------

## dE_logics

 *Sadako wrote:*   

> Even without the static USE flag, I still get a statically linked /bin/bb, you sure you don't have the same?
> 
> As for debugging an initramfs, only thing I can recommend is testing under qemu-kvm, which can boot a linux kernel directly rather than via a bootloader.
> 
> That and a bunch of echo statemnets in your linuxrc or similar .

 

Humm... that's worked out well. Thanks for all sugessions.

Considering I've a custom kernel now, I've decided to debug the traditional way.

----------

## dE_logics

I'm doing initramfs for educational purposes. Later on I'll try and make the root ro, do restoration work for end users and make live CDs off both Debian and Gentoo.

Also -- bb doesn't work.   :Sad: 

It works fine in the system but in init it says 'mount: not found'.

As a result I'll download the Debian package busybox-static and use it for the mean time.

Since this's all for educational purposes, I'll pretty persistent to get a dynamic busybox in initramfs.

----------

## tclover

 *dE_logics wrote:*   

> Also -- bb doesn't work.   

 

You have to rename bb to... busybox of course. Make at least `/bin/sh' symlink and possibly `/linuxrc' and install the applets by a `/bin/busybox --install -s' in your init script or else... untar `tar xpf /usr/share/busybox/busybox-links.tar -C $INITRAMFSDIR' the symlinks tarball. It should work with that.

EDIT: Feel free to waste your time with glibc linked libraries... to busybox. The sh symlink may not be necessary with init header but you have to somewhat install the applets anyway or else... edit your init script to...

----------

## dE_logics

 *tclover wrote:*   

>  *dE_logics wrote:*   Also -- bb doesn't work.    
> 
> You have to rename bb to... busybox of course. Make at least `/bin/sh' symlink and possibly `/linuxrc' and install the applets by a `/bin/busybox --install -s' in your init script or else... untar `tar xpf /usr/share/busybox/busybox-links.tar -C $INITRAMFSDIR' the symlinks tarball. It should work with that.
> 
> EDIT: Feel free to waste your time with glibc linked libraries... to busybox. The sh symlink may not be necessary with init header but you have to somewhat install the applets anyway or else... edit your init script to...

 

I modified the init script to use bb instead of busybox.

Also in my system, running 'bb --install -s' drops me to shell, actually doing anything with bb just drops me a bash shell.

----------

