Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Will the kernel boot without init=/bin/bash parameter?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
colag
Tux's lil' helper
Tux's lil' helper


Joined: 26 Sep 2009
Posts: 100
Location: Dhaka, Bangladesh

PostPosted: Mon Jan 02, 2017 3:34 am    Post subject: Will the kernel boot without init=/bin/bash parameter? Reply with quote

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.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Mon Jan 02, 2017 4:18 am    Post subject: Re: Will the kernel boot without init=/bin/bash parameter? Reply with quote

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:

cat /proc/cmdline:
\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
Back to top
View user's profile Send private message
colag
Tux's lil' helper
Tux's lil' helper


Joined: 26 Sep 2009
Posts: 100
Location: Dhaka, Bangladesh

PostPosted: Mon Jan 02, 2017 4:41 am    Post subject: Re: Will the kernel boot without init=/bin/bash parameter? Reply with quote

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.
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1369
Location: Montréal

PostPosted: Mon Jan 02, 2017 5:16 am    Post subject: Reply with quote

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.
_________________
Paul
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Mon Jan 02, 2017 6:31 am    Post subject: Re: Will the kernel boot without init=/bin/bash parameter? Reply with quote

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
Back to top
View user's profile Send private message
colag
Tux's lil' helper
Tux's lil' helper


Joined: 26 Sep 2009
Posts: 100
Location: Dhaka, Bangladesh

PostPosted: Mon Jan 02, 2017 7:11 am    Post subject: Re: Will the kernel boot without init=/bin/bash parameter? Reply with quote

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?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Mon Jan 02, 2017 8:42 am    Post subject: Re: Will the kernel boot without init=/bin/bash parameter? Reply with quote

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
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7093
Location: Saint Amant, Acadiana

PostPosted: Mon Jan 02, 2017 12:57 pm    Post subject: Reply with quote

See
Code:
man hier

_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum