Single user mode

When you run into problems installing MX Linux XFCE
Message
Author
rbode
Posts: 18
Joined: Thu Mar 22, 2018 9:36 am

Single user mode

#1 Post by rbode »

Good afternoon Everybody,

My apologies if I have submitted this into a wrong forum area, sorry :shy:

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

User avatar
Eadwine Rose
Administrator
Posts: 14490
Joined: Wed Jul 12, 2006 2:10 am

Re: Single user mode

#2 Post 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.
MX-23.6_x64 July 31 2023 * 6.1.0-35amd64 ext4 Xfce 4.20.0 * 8-core AMD Ryzen 7 2700
Asus TUF B450-Plus Gaming UEFI * Asus GTX 1050 Ti Nvidia 535.247.01 * 2x16Gb DDR4 2666 Kingston HyperX Predator
Samsung 870EVO * Samsung S24D330 & P2250 * HP Envy 5030

User avatar
dolphin_oracle
Developer
Posts: 22128
Joined: Sun Dec 16, 2007 12:17 pm

Re: Single user mode

#3 Post 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.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

User avatar
DukeComposed
Posts: 1330
Joined: Thu Mar 16, 2023 1:57 pm

Re: Single user mode

#4 Post 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.

User avatar
dolphin_oracle
Developer
Posts: 22128
Joined: Sun Dec 16, 2007 12:17 pm

Re: Single user mode

#5 Post 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.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

User avatar
DukeComposed
Posts: 1330
Joined: Thu Mar 16, 2023 1:57 pm

Re: Single user mode

#6 Post 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.

rbode
Posts: 18
Joined: Thu Mar 22, 2018 9:36 am

Re: Single user mode

#7 Post 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

User avatar
fehlix
Developer
Posts: 12634
Joined: Wed Apr 11, 2018 5:09 pm

Re: Single user mode

#8 Post 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.

rbode
Posts: 18
Joined: Thu Mar 22, 2018 9:36 am

Re: Single user mode

#9 Post 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
}

User avatar
fehlix
Developer
Posts: 12634
Joined: Wed Apr 11, 2018 5:09 pm

Re: Single user mode

#10 Post 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.

Post Reply

Return to “Installation”