forgot passwd, cannot login, [rd]init=/bin/sh don't work
Gentlemen, last time I forgot my password and couldn't log into my machine here on my far away rural mountaintop, I ended up digging up an old Debian "potato" CDROM and installing it into some free space on my disk, from which I could edit /etc/passwd and zero out the password. These days that would no longer necessarily work, see man mkfs.ext3 -I.
Quoted 3 lines
Presuming Linux, you can add "init=/bin/sh" to the kernel command line. This will give you a shell without asking for a password. From this shell you can edit your password file.
Didn't work.
Quoted 1 line
Initrd scripts might change everything.
OK, I then tried linux-doc-2.6.26/Documentation/kernel-parameters.txt.gz:
rdinit= [KNL]
Format: <full_path>
Run specified binary instead of /init from the ramdisk, used for early userspace startup. See initrd.
So in grub2 I chose "e" to edit, and changed the lines to
linux /boot/vmlinuz-2.6.26-1-686 root=UUID=... rdinit=/bin/sh
initrd /boot/initrd.img-2.6.26-1-686
hit ESC then RET, and alas it was like I didn't type anything at all but just hit RET, booting proceeded as usual, and /proc/cmdline shows that my changes to that command line were thrown away.
Quoted 7 lines · [email protected] wrote:
...
OK, I then tried linux-doc-2.6.26/Documentation/kernel-parameters.txt.gz:
rdinit= [KNL]
Format:<full_path>
Run specified binary instead of /init from the ramdisk, used for early userspace startup. See initrd.
Quoted 6 lines
So in grub2 I chose "e" to edit, and changed the lines to
linux/boot/vmlinuz-2.6.26-1-686root=UUID=... rdinit=/bin/sh
initrd/boot/initrd.img-2.6.26-1-686
hit ESC then RET, and alas it was like I didn't type anything at all but just hit RET, booting proceeded as usual, and/proc/cmdlineshows that my changes to that command line were thrown away.
The only reason to use a ramdisk during boot is if your kernel doesn't have any support for your root filesystem (unlikely) or for your hardware (much more likely).
If the disk controller on your motherboard isn't too exotic you could probably boot the kernel directly, i.e:/boot/vmlinuz-2.6.26-1-686 init=/bin/sh root=whatever Note the use of *init* instead of rdinit because you aren't using the initial ramdisk this way.
May or may not work, but it's worth a try.
Quoted 7 lines · On Wednesday 08 October 2008, [email protected] wrote:
So in grub2 I chose "e" to edit, and changed the lines to
linux/boot/vmlinuz-2.6.26-1-686root=UUID=... rdinit=/bin/sh
initrd/boot/initrd.img-2.6.26-1-686
hit ESC then RET, and alas it was like I didn't type anything at all but just hit RET, booting proceeded as usual, and/proc/cmdlineshows that my changes to that command line were thrown away.
That's normal behaviour, if you press ESC all your changes are gone.
The solution is not to press ESC, but Ctrl-x instead. There's also a hint about that in the online help below the editor frame.
Niels Böhm
Ah, no wonder. These need rewording:
Use the %C and %C keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting or 'c' for a command-line.
Minimum Emacs-like screen editing is supported. TAB lists available completions. Press C-x ('x' with Ctrl) to boot, C-c ('c' with Ctrl) for a command-line or ESC to return menu.
Here, I have reworded the latter, preserving terseness, and fixing grammar:
Minimum Emacs-like editing is supported. TAB lists available completions. Press C-x ('x' with Ctrl) to boot, C-c for a command-line or ESC to throw away changes and return to menu.
Kindly integrate it into your next version. Thank you.
(There is also a grub screen with its several lines of help text enclosed by "[ ]". Might as well chuck them too.)
By the way, I indeed now could login now without remembering the password. Use
linux /boot/vmlinuz-... root=... rw init=/bin/sh
initrd /boot/initrd.img-...
The key is the "rw init=/bin/sh". (And after editing /etc/passwd to change root's :x: to ::, be sure not to just exit the shell, but hit CTRL-ALT-DEL, else one has to push the reset button.)
Can somebody please integrate my patches? For the parent article and the "grub-install message should mention --recheck" article.
I am a mere "apt-get install" user. I fear if I learn your whole source code system, and finally make an official patch, it too will fall on deaf ears.
As I expect I will only have one patch per three years, please integrate it for me. Thanks.
PATCH 1/1 menu.c clearer instructions
In reply to [email protected]diff -C 1 menuO*.c menu.c
*** menuORIG.c 2008-12-27 02:42:57.000000000 +0800
--- menu.c 2008-12-27 02:53:49.000000000 +0800
***************
*** 84,87 ****
Minimum Emacs-like screen editing is supported. TAB lists\n\
! available completions. Press C-x (\'x\' with Ctrl) to boot,\n\
! C-c (\'c\' with Ctrl) for a command-line or ESC to return menu.");
}
--- 84,87 ----
Minimum Emacs-like screen editing is supported. TAB lists\n\
! completions. C-x (\'x\' with Ctrl) to boot, C-c for command-line,\n\
! or ESC to throw away changes and return to menu.");
}[semi-PATCH] grub.texi: emergency booting without root passwd
In reply to [email protected]Please add this somewhere you feel comfortable with in grub.texi.
I looked, but cannot find the right place.
Thank you.
@Chapter Tips
@node Forgot the root password
One place when grub can come in very handy is when one forgot the root password, and hence cannot boot or even shutdown the system. Use @example
linux /boot/vmlinuz-... root=... rw init=/bin/sh
initrd /boot/initrd.img-...
@end example
The key is the "rw init=/bin/sh". (And after editing /etc/passwd to change root's :x: to ::, be sure not to just exit the shell, but hit CTRL-ALT-DEL, else one has to push the reset button.)
cmdline.c: ESC at any time exits: only mentioned once
In reply to [email protected]Gentlemen, there is a serious usability problem with cmdline.c.
At the very start the user sees the message made by
grub_printf ("\
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\
lists possible command completions. Anywhere else TAB lists possible\n\
device/file completions.%s ]\n\n",
nested ? " ESC at any time exits." : "");
The problem is, just let him type "help" just once...
The note about "ESC at any time exits" is now gone from the screen.
He now faces a list of the help commands, with NO "exit" or "quit" choices.
No. Not even the tiniest hint left about how to get back out.
Quoted 1 line
If he is smart he would have remembered "ESC at any time exits".
But he is just average, not smart.
He ends up choosing "reboot", the only choice that seems like it will get him BACK.
Therefore, please add
"ESC at any time exits" to the bottom of the help list.
No, I don't know how to make this patch.
You will have to do it for me.
Also note the help list must still fit on one screen after the patch.
Thank you.
Re: [semi-PATCH] grub.texi: emergency booting without root passwd
In reply to [email protected]Hello,
(I'm not Grub expert)
Quoted 6 lines · On Dec/27/2008, [email protected] wrote:
Please add this somewhere you feel comfortable with in grub.texi.
I looked, but cannot find the right place.
Thank you.
Quoted 11 lines
@Chapter Tips
@node Forgot the root password
One place when grub can come in very handy is when one forgot the root password, and hence cannot boot or even shutdown the system. Use @example
linux/boot/vmlinuz-... root=... rw init=/bin/sh
initrd/boot/initrd.img-...
@end example
The key is the "rw init=/bin/sh". (And after editing/etc/passwdto change root's :x: to ::, be sure not to just exit the shell, but hit CTRL-ALT-DEL, else one has to push the reset button.)
and I think that better type "sync" to synchronize the buffers.
Also, I'm not sure if this should be in the Grub "Chapter Tips" (because it's half Grub related, half Linux related) (so, maybe would be useful but I wonder if it's the correct place)
What other people thinks?
Signature · 2 lines
Carles Pina i Estany GPG id: 0x17756391 http://pinux.info
Re: [PATCH] menu.c clearer instructions
In reply to [email protected]Hello,
Again: I'm not a Grub expert/mantainer, but I have been reading some emails here and I will wear the police hat for this email:
Quoted 1 line · On Dec/27/2008, [email protected] wrote:
diff -C 1 menuO*.c
menu.c
Could you send using diff unified format, with 3 lines of context? (default one)
I think that people here is used to receive this diff's, not the not-unifed format that you sent.
I suggest download from the SVN and use svn diff :-)
Also, and before somebody else will tell to you, could you write a Changelog entry for your patches? (take a look on the current Changelog to know the way that should be written), so you can attach the patch (not in the mail inline) and copy in the email the Changelog entry.
Thanks,
Signature · 2 lines
Carles Pina i Estany GPG id: 0x17756391 http://pinux.info
Re: [PATCH] menu.c clearer instructions
2008-12-27 [email protected]
* normal/menu.c: print clearer instructions on the screen
menu.c renamed from menuORIG.c +2 -2
@@ -82,8 +82,8 @@ {grub_printf ("\n\ Minimum Emacs-like screen editing is supported. TAB lists\n\ -available completions. Press C-x (\'x\' with Ctrl) to boot,\n\ -C-c (\'c\' with Ctrl) for a command-line or ESC to return menu." ); +completions. C-x (\'x\' with Ctrl) to boot, C-c for command-line,\n\ +or ESC to throw away changes and return to menu." ); } else {
"No name needed".
Re: [PATCH] menu.c clearer instructions
menu.c line 86
Quoted 4 lines · On Sat, 2008-12-27 at 06:54 +0800, [email protected] wrote:
menu.c renamed from menuORIG.c +2
-2- available completions. Press C-x (\'x\' with Ctrl) to boot,\n\ - C-c (\'c\' with Ctrl) for a command-line or ESC to return menu."); + completions. C-x (\'x\' with Ctrl) to boot, C-c for command-line,\n\ + or ESC to throw away changes and return to menu.");
How about "Ctrl-x to boot, Ctrl-c for command line, or ESC to abandon changes and return to the menu"?
We don't need to use the "C-" notation at all if it needs explanation. "Ctrl-x" should be clear to most users (everyone knows "Ctrl-Alt-Del"). "abandon" sounds better than "throw away" in this context.
Signature · 2 lines
Regards, Pavel Roskin
Re: [PATCH] menu.c clearer instructions
OK, Pavel Roskin's suggestions sound great. I leave this in your hands.
Re: [PATCH] menu.c clearer instructions
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"j" == jidanni <[email protected]> writes:
j> OK, Pavel Roskin's suggestions sound great. I leave this in your hands.
However, will these patches I sent this week be used, or
slowly
forgotten
?Re: [PATCH] menu.c clearer instructions
I'll track your patches. If everyone comes to a consensus on them in a week I'll commit them to the repo.
I agree with Pavel also that using "Ctrl-<key>" is more descriptive then what is there now.
What other patches where you going to submit like this?
Quoted 15 lines · On Mon, Dec 29, 2008 at 8:09 PM, <[email protected]> wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"j" == jidanni <[email protected]> writes:
j> OK, Pavel Roskin's suggestions sound great. I leave this in your hands.
However, will these patches I sent this week be used, or
slowlyforgotten ?_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] menu.c clearer instructions
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"JY" == Jerone Young <[email protected]> writes:
JY> I'll track your patches.
Thanks!
JY> What other patches where you going to submit like this? There is a total of four issues,
[PATCH] grub-install message should mention --recheck [PATCH] menu.c clearer instructions
[semi-PATCH] grub.texi: emergency booting without root passwd cmdline.c: ESC at any time exits: only mentioned once
There won't be more soon as I now boot like a charm.
Re: [PATCH] menu.c clearer instructions
In reply to [email protected]Committed a variant of this patch into the repository.
Thanks,
Jerone
Quoted 27 lines · On Fri, Dec 26, 2008 at 4:54 PM, <[email protected]> wrote:
2008-12-27 [email protected]
*
normal/menu.c: print clearer instructions on the screenmenu.c 2008-12-27 02:53:49.000000000 +0800 renamed from menuORIG.c 2008-12-27 02:42:57.000000000 +0800 +2
-2@@ -82,8 +82,8 @@ { grub_printf ("\n\ Minimum Emacs-like screen editing is supported. TAB lists\n\ - available completions. Press C-x (\'x\' with Ctrl) to boot,\n\ - C-c (\'c\' with Ctrl) for a command-line or ESC to return menu."); + completions. C-x (\'x\' with Ctrl) to boot, C-c for command-line,\n\ + or ESC to throw away changes and return to menu."); } else {"No name needed".
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] menu.c clearer instructions
JY> Committed a variant of this patch into the repository.
OK, thanks. Say, three semi-patches of mine remain to be resolved. Their subjects were:
[PATCH] grub-install message should mention --recheck
[semi-PATCH] grub.texi: emergency booting without root passwdcmdline.c: ESC at any time exits: only mentioned once
patches not acted upon
I sent patches etc. last month, Subjects:
[PATCH] grub-install message should mention --recheck [semi-PATCH] grub.texi: emergency booting without root passwd cmdline.c: ESC at any time exits: only mentioned once
but nobody acted on them one way or the other
Re: patches not acted upon
Quoted 5 lines · [email protected] wrote:
I sent patches etc. last month, Subjects:
[PATCH] grub-install message should mention --recheck [semi-PATCH] grub.texi: emergency booting without root passwdcmdline.c: ESC at any time exits: only mentioned once
but nobody acted on them one way or the other
If you hide your messages to some threads don't expect that hurry people will notice them. Just write a _new_ message and not a reply when starting a _new_ topic.
Personally I can easily mark threads not within my interest area as ignored or mark automatically as read.
This time I'll try to hunt your patches and comment on them if there is something to be done...
Re: [semi-PATCH] grub.texi: emergency booting without root passwd
In reply to Carles Pina i EstanyQuoted 23 lines · Carles Pina i Estany
Hello,
(I'm not Grub expert)
Quoted 6 lines · On Dec/27/2008, [email protected] wrote:
Please add this somewhere you feel comfortable with in grub.texi.
I looked, but cannot find the right place.
Thank you.
Quoted 11 lines
@Chapter Tips
@node Forgot the root password
One place when grub can come in very handy is when one forgot the root password, and hence cannot boot or even shutdown the system. Use @example
linux/boot/vmlinuz-... root=... rw init=/bin/sh
initrd/boot/initrd.img-...
@end example
The key is the "rw init=/bin/sh". (And after editing/etc/passwdto change root's :x: to ::, be sure not to just exit the shell, but hit CTRL-ALT-DEL, else one has to push the reset button.)
Quoted 7 lines
and I think that better type "sync" to synchronize the buffers.
Also, I'm not sure if this should be in the Grub "Chapter Tips" (because it's half Grub related, half Linux related) (so, maybe would be useful but I wonder if it's the correct place)
What other people thinks?
First of all it does not work with every Linux distribution and secondly I do not see that we should take any side how to enter to Linux installations without proper authentication...
So you are free to keep information like this on the web, but not as part of official grub distribution...
Re: cmdline.c: ESC at any time exits: only mentioned once
In reply to [email protected]Quoted 9 lines · [email protected] wrote:
Gentlemen, there is a serious usability problem with
cmdline.c.At the very start the user sees the message made by
grub_printf("\
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\
lists possible command completions. Anywhere else TAB lists possible\n\
device/file completions.%s ]\n\n",nested ? " ESC at any time exits." : "");
This is kinda problem for translations anyway. So it would be preferable to have static text there...
What is the overall gain for having nested to control output of that text?
Quoted 6 lines
The problem is, just let him type "help" just once...
The note about "ESC at any time exits" is now gone from the screen.
He now faces a list of the help commands, with NO "exit" or "quit" choices.
Now the question is, should we provide an exit command? Bash basically supports that so it could be a good idea.
Re: patches not acted upon
In reply to [email protected]Next week I was going to hunt all the patches I personally missed or had not been commited yet by someone else. Been so busy lately havn't had time. But I did commit one of your patches.
1)[PATCH] grub-install message should mention --recheck
This one really isn't necessary. Kind of agreed with the first commenter. I don't have any strong feeling toward not including it. But it does seem like something that users can easily find when using --help.
2) [semi-PATCH] grub.texi: emergency booting without root passwd This patch isn't completed. Whould need to work on this more
3) cmdline.c: ESC at any time exits: only mentioned once Not sure off head. Will check it though.
Quoted 12 lines · On Fri, Jan 23, 2009 at 2:05 PM, <[email protected]> wrote:
I sent patches etc. last month, Subjects:
[PATCH] grub-install message should mention --recheck [semi-PATCH] grub.texi: emergency booting without root passwdcmdline.c: ESC at any time exits: only mentioned once
but nobody acted on them one way or the other_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Re: cmdline.c: ESC at any time exits: only mentioned once
In reply to Vesa JääskeläinenHello,
Quoted 5 lines · Vesa Jääskeläinen
Quoted 4 lines · [email protected] wrote:
Gentlemen, there is a serious usability problem with
cmdline.c.At the very start the user sees the message made by
Quoted 8 lines
Quoted 5 lines
grub_printf("\
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\
lists possible command completions. Anywhere else TAB lists possible\n\
device/file completions.%s ]\n\n",nested ? " ESC at any time exits." : "");This is kinda problem for translations anyway. So it would be preferable to have static text there...
I'm reading it and I don't see any problem for translation. Should be like:
grub_printf (_("\
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\
lists possible command completions. Anywhere else TAB lists possible\n\
device/file completions.%s ]\n\n"),
nested ? _(" ESC at any time exits.") : "");Or I'm wrong?
Signature · 2 lines
Carles Pina i Estany GPG id: 0x17756391 http://pinux.info
Re: patches not acted upon
In reply to Jerone YoungOK, thanks for evaluating them, worthy or not.