Page 1 of 2
Single user mode
Posted: Fri Jun 14, 2024 8:55 am
by rbode
Good afternoon Everybody,
My apologies if I have submitted this into a wrong forum area, sorry
I've been searching the internet and the MX site for information on how to add a entry in the Grub boot menu in order to get into single user mode just by selecting the right boot line from the Grub menu.
I have found myself surfing the web numerous times to find howto boot into single user mode after I made a change to the system and it wouldn't start again.
I thought it would be handy, at least for myself, to have a "rescue line" into my computer without having to remember adding "init=/bin/bash".
I would appreciate any help on howto accomplish this.
Please advise.
Best regards,
Rene
Re: Single user mode
Posted: Fri Jun 14, 2024 9:04 am
by Eadwine Rose
"after I made a change to the system and it wouldn't start again."
That would be the liveUSB you made to install the system.
Re: Single user mode
Posted: Fri Jun 14, 2024 10:17 am
by dolphin_oracle
easiest way to add an entry is to copy a working entry from /boot/grub/grub.cfg into /boot/grub/custom.cfg. add whatever boot code you want to the menu entry in custom.cfg.
that should be it. our default scripts should source the file if it exists. no need to update-grub.
Re: Single user mode
Posted: Fri Jun 14, 2024 10:35 am
by DukeComposed
dolphin_oracle wrote: Fri Jun 14, 2024 10:17 am
easiest way to add an entry is to copy a working entry from /boot/grub/grub.cfg into /boot/grub/custom.cfg. add whatever boot code you want to the menu entry in custom.cfg.
that should be it. our default scripts should source the file if it exists. no need to update-grub.
And adding "1" to the end of the kernel arguments of that custom entry should be sufficient to create an entry that will always start the machine in single-user mode.
Re: Single user mode
Posted: Fri Jun 14, 2024 10:43 am
by dolphin_oracle
DukeComposed wrote: Fri Jun 14, 2024 10:35 am
dolphin_oracle wrote: Fri Jun 14, 2024 10:17 am
easiest way to add an entry is to copy a working entry from /boot/grub/grub.cfg into /boot/grub/custom.cfg. add whatever boot code you want to the menu entry in custom.cfg.
that should be it. our default scripts should source the file if it exists. no need to update-grub.
And adding "1" to the end of the kernel arguments of that custom entry should be sufficient to create an entry that will always start the machine in single-user mode.
FYI 1 won't work if the root account is locked. using init=/bin/bash works by essentially breaking startup, but you do get a root console though. this is an OLDDDDDDDD trick.
Re: Single user mode
Posted: Fri Jun 14, 2024 10:53 am
by DukeComposed
dolphin_oracle wrote: Fri Jun 14, 2024 10:43 am
FYI 1 won't work if the root account is locked. using init=/bin/bash works by essentially breaking startup, but you do get a root console though. this is an OLDDDDDDDD trick.
A fair point, albeit "1" is pretty easy to remember.
Re: Single user mode
Posted: Sat Jun 15, 2024 5:33 am
by rbode
Dear fellow MX users,
Thank you VERY much for the suggestions.
I've tried the procedure "copying a working entry" from /boot/grub/grub.cfg to /boot/grub/custom.cfg as suggested by the "Dolphin Oracle" and adding my custom text "init=/bin/bash" to the end of line which resulted in:
linux /boot/vmlinuz-6.1.0-21-amd64 root=UUID=770634bb-f73b-4887-aab5-37503d68b2b6 ro init=/bin/bash
I also changed the menu id from "menuentry 'MX 23.2 Libretto'" to "menuentry 'MX 23.2 Libretto Single User'" for my entry only!
Changed the attributes for the file /boot/grub/custom.cfg to readonly (chmod 444).
However after reboot the bootmenu showed no change to previous startups and thus I was not able to find my entry which I added to /boot/grub/custom.cfg.
Also on subsequent reboots the bootmenu did not display my "Single User" option.
Any further suggestions.
TIA, Rene
Re: Single user mode
Posted: Sat Jun 15, 2024 6:48 am
by fehlix
rbode wrote: Sat Jun 15, 2024 5:33 am
Also on subsequent reboots the bootmenu did not display my "Single User" option.
Any further suggestions.
A simple typo often leads to the custom.cfg being incorrect and not being displayed.
Sometimes it helps to post the content of the changes you have made if you cannot find errors yourself.
And incase you post, pls. post within code-block, with help of the [</>]-code-block button above the post-editor.
Re: Single user mode
Posted: Sat Jun 15, 2024 7:01 am
by rbode
@fehlix
Thanks for the suggestion.
Here's the contents of my /boot/grub/custom.cfg:
Code: Select all
menuentry 'MX 23.2 Libretto Single User' --class mx --class gnu-linux --class gnu --class os $menuen
try_id_option 'gnulinux-simple-770634bb-f73b-4887-aab5-37503d68b2b6' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
set root='hd0,gpt4'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-ba
remetal=ahci0,gpt4 770634bb-f73b-4887-aab5-37503d68b2b6
else
search --no-floppy --fs-uuid --set=root 770634bb-f73b-4887-aab5-37503d68b2b6
fi
echo 'Loading Linux 6.1.0-21-amd64 ...'
linux /boot/vmlinuz-6.1.0-21-amd64 root=UUID=770634bb-f73b-4887-aab5-37503d68b2b6 ro init=
/bin/bash
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-6.1.0-21-amd64
}
Re: Single user mode
Posted: Sat Jun 15, 2024 7:56 am
by fehlix
rbode wrote: Sat Jun 15, 2024 7:01 am
@fehlix
Thanks for the suggestion.
Here's the contents of my /boot/grub/custom.cfg:
Code: Select all
menuentry 'MX 23.2 Libretto Single User' --class mx --class gnu-linux --class gnu --class os $menuen
try_id_option 'gnulinux-simple-770634bb-f73b-4887-aab5-37503d68b2b6' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
set root='hd0,gpt4'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-ba
remetal=ahci0,gpt4 770634bb-f73b-4887-aab5-37503d68b2b6
else
search --no-floppy --fs-uuid --set=root 770634bb-f73b-4887-aab5-37503d68b2b6
fi
echo 'Loading Linux 6.1.0-21-amd64 ...'
linux /boot/vmlinuz-6.1.0-21-amd64 root=UUID=770634bb-f73b-4887-aab5-37503d68b2b6 ro init=
/bin/bash
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-6.1.0-21-amd64
}
The text shown contains some line breaks, which would make it fail.
Maybe to double check, open again with featherpad, mark all, and copy & paste again,
incase that's only a issue within your post.