[HOWTO] boot from grub prompt  [Solved]

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
gor9

[HOWTO] boot from grub prompt  [Solved]

#1 Post by gor9 »

Try at own risk but it should be safe enough. Pay attention to the results you get when pressing TAB key which in grub command mode acts like bash-completion

First you either have /boot mounted on its own partition or as a sub-folder to / partition.
This affects the linux and initrd lines in examples below.

Next you either have a msdos partition table or a GPT one. This affects defining the boot partition with examples of (and its hd zero not hd O for orange) and you may have setup logical volume management (lvm)
set root=(hd0,msdos1)
set root=(hd0,gpt1)
set root=(lvm,<string>)

Don't worry if you can not remember this lvm string as ls command "should" reveal it.
There is no gap between comma and msdos1 or gpt1 or lvm string

Now leaping ahead, you may remember what your linux (kernel) line defined root was.
A number of people also have UUID strings which I regard as "error prone" to type in grub command mode, so use /dev/sdX please
examples include.
root=/dev/sda1
root=/dev/mapper-<string>

Assuming you can not boot and see grub but not grub rescue, you have grub in MBR/GPT and have some broken link to your balance of your boot files for grub.

Before we begin, the TAB key is important, it will offer many options of directories or files and depending on which line you are actioning.....might autocomplete your kernel name or initrd name etc....it will also autocomplete end of brackets if you are lazy to type it

Grub counts hard drives from zero but partitions from one. That is stupid IMHO, they should either both count from zero or both from one.

At grub prompt........ to find what drives and partitions are visible to grub
#########
type

Code: Select all

 ls
and press enter. Output or results include hd values, msdos, gpt or lvm values.

Now lets pretend you can not remember which drive grub is on, and you have 2 drives.
I have W10 on drive 2 as example.

type

Code: Select all

ls (hd1,msdos1)
my result for a W10 MBR with a snip -> Filesystem type ntfs
Ok so I now remember my MX is on drive 0 ;)

# define my boot partition
#####################
remember the examples above may differ to you.

Code: Select all

set root=(hd0,msdos1) 
# input my kernel line and initrd where boot is a sub-folder to / (same partition for boot and /)
####################
linux /boot/vml (and now press TAB key to either autocomplete kernel name or offer kernel names)
(lines becomes)

Code: Select all

linux /boot/vmlinuz-5.10.0-17-amd64 root=/dev/sda1 ro quiet
initrd /boot/initrd.img-5.10.0-17-amd64
# add one more command
####################

Code: Select all

boot
and press enter. Hopefully system boots

2) input my kernel line and initrd where boot is a different partition from /
####################
linux vml (and now press TAB key to either autocomplete kernel name or offer kernel names)
(lines becomes)

Code: Select all

linux vmlinuz-5.10.0-17-amd64 root=/dev/sda5 ro quiet
initrd initrd.img-5.10.0-17-amd64
# add one more command
####################

Code: Select all

boot
and press enter

good luck

3) Once you are in, check your /etc/default/grub and any manual edits you made to /etc/grub.d/40_custom and try

Code: Select all

sudo update-grub
command "should" say something like success.

x-user
Posts: 28
Joined: Sat Apr 09, 2022 10:49 am

Re: [HOWTO] boot from grub prompt

#2 Post by x-user »

error: "unknown command 'linux'

Help
Thinkpad X61T | Thinkpad X220T | Windows...

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

Re: [HOWTO] boot from grub prompt

#3 Post by fehlix »

x-user wrote: Tue Sep 13, 2022 3:57 am error: "unknown command 'linux'

Help
Please try first LiveUSB Grub Rescue menus in combination of MX Boot Repair.
Manual GRUB shell excercises may work if you knwo what you are doing,
hence the mention tools have been created.
Also pleas post your issue with you own thread not in multiple different threads.
Thanks

gor9

Re: [HOWTO] boot from grub prompt

#4 Post by gor9 »

also were you at a grub prompt or a grub rescue prompt?

if set root worked, typing lin (and pressing TAB key) should offer to autocomplete the commands known to grub, but not if you had grub rescue prompt

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

Re: [HOWTO] boot from grub prompt

#5 Post by Eadwine Rose »

Please start a new thread, thank you. This is not a help thread. Closing this one.
MX-23.6_x64 July 31 2023 * 6.1.0-40amd64 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

Locked

Return to “Tips & Tricks by users (not for help)”