Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I made a bone-headed mistake in one of my init.d scripts which gets stuck in an infinite loop during the boot process and blocks the completion. I therefore can not get to a shell and fix it. How can I boot and not perform all the boot scripts? I have root if necessary.

share|improve this question
    
I think Red Hat used to have a feature where at some point in the boot it asked if you wanted to continue automatically or manually select for each service if it was to be started or not. I don't know if the feature is still available or if your error happens before that is possible. –  ptman Jun 16 '11 at 4:00
add comment

2 Answers

up vote 6 down vote accepted

Passing 1 on the kernel line in the bootloader should start it in single user mode, which should not start the initscript unless it is severely broken. If booting into single mode does not work then you will need to get the install disc and boot into rescue mode using it.

share|improve this answer
1  
in the grub menu press "e" to edit the menu selection, then 'e' again on the second line, which should contain kernel arguements, then "return" then 'b' on the line to boot it –  bobby Jun 16 '11 at 2:00
    
you can also use "s" on the line for single user mode. easier to remember for some (like me). –  Sirex Jun 16 '11 at 8:49
    
I confirm that this works. Got me out of a hole when I screwed up an init.d script. Simply logged on at run level 1, mounted the drive as RW and rm'd the offending script. Boom! –  user189445 Sep 11 '13 at 6:07
add comment

As Ignacio suggested, the simplest solution is to boot into single user mode. To do this press any key on the countdown splash screen before it boots into the kernel. From here highlight the proper kernel and press e. Press e again to edit the cmdline and at the end at either S, s, single, or 1. Press return and then b to boot. This won't run your init script unless you've explicitly configured it to be part of single user mode, which is unlikely.

However, if you still have problems at this point, you don't need the install disk. You can add the following to your kernel command line:

init=/bin/bash

This will cause the kernel to start /bin/bash as pid 1, rather than init. At this point none of the system initialization scripts will have run, so you should be able to take care of things. Note that you'll probably have a read-only root filesystem, which you should be able to take care of like this:

mount -o remount,rw /

...or you can remove the ro option from the kernel command line.

share|improve this answer
    
I dont believe this will work, at least not as simply as wished. RHEL uses an initrd, and I believe the only shell available on the initrd is nash, which really really sucks. But I could be wrong, going off memory. –  Patrick Jun 16 '11 at 2:47
1  
The initrd loads and transitions to the real root as normal. You're simply loading /bin/bash instead of /sbin/init. This is a common recovery scenario; nothing special happening here. –  larsks Jun 16 '11 at 3:37
    
i believe larsks is correct, this is a viable option. –  Sirex Jun 16 '11 at 8:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.