# Will the kernel boot without init=/bin/bash parameter?

## colag

linux /boot/vmlinuz-4.7.2 root=/dev/sda2

Will it boot the system without init=/bin/bash? I don't see init=/bin/bash for other linux distributions in grub.cfg menu and those works. Why do those work then? When do we need init=/bin/bash and when don't we need init=/bin/bash?

The question is not related to gentoo directly. Suppose I've installed only binutils,glibc,gcc,bash,coreutils and kernel-4.7 in /dev/sda2. It's a generic question about linux kernel booting process to start the system with a login prompt or with /bin/bash in tty/console.

----------

## khayyam

 *colag wrote:*   

> Will it boot the system without init=/bin/bash? I don't see init=/bin/bash for other linux distributions in grub.cfg menu and those works. Why do those work then? When do we need init=/bin/bash and when don't we need init=/bin/bash?

 

colag ... /bin/bash is not generally used for 'init', though it can be, you can pass init=/bin/bash and get bash as a shell, but bash doesn't then mount filesystems, start services, etc, etc, it will only provide a shell from which you can then do those things (you might think of it as a rescue shell). 

The default init is /sbin/init, and this then looks to /etc/inittab to see what should be run (in the case of openrc this is '/sbin/rc sysinit' and then '/sbin/rc boot') ... but this isn't passed as a kernel parameter:

```
\EFI\linux\vmlinuz-3.12.68-ck.efi quiet ro nopat elevator=bfq video.use_native_backlight=1 rootfstype=ext4 luks enc_root=/dev/sda2 lvm root=/dev/mapper/vg-root tuxonice resume=/dev/mapper/vg-swap
```

Perhaps your mistaking some 'rescue shell' grub entry.

best ... khay

----------

## colag

 *khayyam wrote:*   

> The default init is /sbin/init, and this then looks to /etc/inittab to see what should be run (in the case of openrc this is '/sbin/rc sysinit' and then '/sbin/rc boot') ... but this isn't passed as a kernel parameter:
> 
> Perhaps your mistaking some 'rescue shell' grub entry.

 

What does /sbin/init do? When does /sbin/init work or start loading? If we don't add init=/bin/bash will it look for /sbin/init? I think, kernel mount the / (root) filesystem. Here it's /dev/sda2. I didn't see init=/bin/bash in any entry of grub.cfg. I've other linux there too.

----------

## Logicien

Init is the process number one in all the Unix like operating systems I know but, Bash is never the default of Init. For this reason, you have to explicitely tell to the Linux kernel that /bin/bash is the process number one for this boot.

When init=/bin/bash is pass as a parameter to the Linux kernel, Bash do not set the Linux console where you are dump with the Bash prompt after Linux call Init (/bin/bash here). So, you may not be able to work at the Bash command lines because, for the system be usable, the boot process need to do some console initialisation that Bash do not do, what's the default Init do. I think it depend on an initramfs and what it do before Init is call.

----------

## khayyam

 *colag wrote:*   

>  *khayyam wrote:*   The default init is /sbin/init, and this then looks to /etc/inittab to see what should be run (in the case of openrc this is '/sbin/rc sysinit' and then '/sbin/rc boot') [...] 
> 
> What does /sbin/init do?

 

colag ... I explain that above. If you want a more detailed explanation then see 'man init', or wikipedia.

 *colag wrote:*   

> When does /sbin/init work or start loading?

 

init is PID1, so the first (userland) process.

 *colag wrote:*   

> If we don't add init=/bin/bash will it look for /sbin/init?

 

I explained that above, but yes.

 *colag wrote:*   

> I think, kernel mount the / (root) filesystem. Here it's /dev/sda2.

 

No, but it can read it, so when you pass 'root=/dev/sda2 rootfstype=ext4' then it can find /sbin/init.

 *colag wrote:*   

> I didn't see init=/bin/bash in any entry of grub.cfg. I've other linux there too.

 

Then I'm confused by your initial question ...

best ... khay

----------

## colag

 *khayyam wrote:*   

>  *colag wrote:*   If we don't add init=/bin/bash will it look for /sbin/init? 
> 
> I explained that above, but yes.

 

Why does kernel always search init in /sbin/init? Why doesn't it search in /bin/init or in other directories?

----------

## khayyam

 *colag wrote:*   

> Why does kernel always search init in /sbin/init? Why doesn't it search in /bin/init or in other directories?

 

colag ... it is a "hardcoded filename". The 's' in 'sbin' represents 'system', so "system bin[aries]", whereas commands in /bin (such as echo, cat, sh, bash, etc) are "[e]ssential command binaries that need to be available in single user mode", /sbin contains "[e]ssential system binaries" (see: filesystem hierarchy standard).

best ... khay

----------

## Jaglover

See 

```
man hier
```

----------

