You are not logged in.

#1 2023-06-26 22:54:20

axsc
Member
Registered: 2019-02-22
Posts: 37

[SOLVED]Grub Boots Into Command Line Every Time

##UPDATE: jonno2002 solved this issue for me. The solution was to mount my EFI partition (for me, /dev/sda1) to /mnt, then input this command:

grub-install --target=x86_64-efi --efi-directory=/mnt --bootloader-id=GRUB

##Original Post:
Hello. I recently built a new PC and transferred my old SSD to my new PC. My old PC was booting in legacy mode, so in order to make my SSD boot-compatible with UEFI I had to install Grub onto an EFI partition on my drive. After doing so, every time I start my PC it boots into the Grub command line. I'm able to get it too boot into Arch Linux manually with:

set root=(hd0,gpt102)
linux (hd0,gpt102)/boot/vmlinuz-linux root=/dev/sda102
initrd (hd0,gpt102)/boot/initramfs-linux.img
boot

This is the output of fdisk -l:

Disk model: Samsung SSD 870 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 14C4BD10-045E-4D10-9BBC-5ACAB1604C70

Device           Start        End    Sectors   Size Type
/dev/sda1         2048    1050623    1048576   512M EFI System
/dev/sda5   1952602112 1953525134     923023 450.7M Microsoft basic data
/dev/sda6   1748418560 1952602111  204183552  97.4G Linux filesystem
/dev/sda100  368082944  368492543     409600   200M BIOS boot
/dev/sda101  368492544  385269759   16777216     8G Linux swap
/dev/sda102  385269760 1748418559 1363148800   650G Linux filesystem

The partition where I installed Grub is in /dev/sda1 and my root partition is in /dev/sda102

When I'm in Arch Linux I have to manually mount my EFI directory with

mount /dev/sda1 /mnt

The contents of /mnt/EFI:

BOOT  ubuntu

The contents of /mnt/EFI/BOOT:

BOOTX64.EFI  fbx64.efi  mmx64.efi

The contents of /mnt/EFI/ubuntu:

BOOTX64.CSV  grub.cfg  grubx64.efi  mmx64.efi  shimx64.efi

The contents of /mnt/EFI/ubuntu/grub.cfg:

search.fs_uuid 61AF-0FCA root hd0,gpt102
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

This is where there might be an issue. The UUID  61AF-0FCA in /mnt/EFI/ubuntu/grub.cfg is the UUID of my EFI partition, NOT my root partition. The problem is that when I change this to my root partition's UUID (not partuuid) and restart my PC, it just boots directly into BIOS and I can't get it to boot into the SSD at all, and I have to boot into a live USB to change it back.

Here's the contents of /etc/fstab:

# 
# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
# /dev/sda102
UUID=32651e3f-b094-430c-966b-4f9cd4a3c44e       /               ext4            rw,relatime,data=ordered        0 1
UUID=323ed795-dd1a-4d3a-9970-98357a7cf8e2 none swap defaults 0 0

When I mount my EFI partition to /mnt and attempt to grub-install /dev/sda, this is the error message I get:

Installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory.

These are the contents of my root partition's /boot directory:

efi  grub  initramfs-linux-fallback.img  initramfs-linux.img  intel-ucode.img  vmlinuz-linux  vmlinuz-linux2

Both /boot/efi and /boot/grub each have a grub.cfg file in them.

Could someone lend me a hand? Thanks in advance!

Last edited by axsc (2023-06-27 00:12:56)

Offline

#2 2023-06-26 23:33:28

jonno2002
Member
Registered: 2016-11-21
Posts: 867

Re: [SOLVED]Grub Boots Into Command Line Every Time

grub-install /dev/sda

is not correct.

please read this page: https://wiki.archlinux.org/title/GRUB#Installation

the correct way to install grub if your efi partition is mounted to /mnt would be:

grub-install --target=x86_64-efi --efi-directory=/mnt --bootloader-id=GRUB

you have a big mess on your hands anyway with things all in the wrong places

Offline

#3 2023-06-26 23:39:38

axsc
Member
Registered: 2019-02-22
Posts: 37

Re: [SOLVED]Grub Boots Into Command Line Every Time

jonno2002 wrote:
grub-install /dev/sda

is not correct.

please read this page: https://wiki.archlinux.org/title/GRUB#Installation

the correct way to install grub if your efi partition is mounted to /mnt would be:

grub-install --target=x86_64-efi --efi-directory=/mnt --bootloader-id=GRUB

you have a big mess on your hands anyway with things all in the wrong places

I just tried that command, and here's the output:

Installing for x86_64-efi platform.
grub-install: warning: disk does not exist, so falling back to partition device /dev/sda1.
grub-install: warning: disk does not exist, so falling back to partition device /dev/sda1.
grub-install: warning: disk does not exist, so falling back to partition device /dev/sda1.
grub-install: error: disk `hostdisk//dev/sda1' not found.

When I tried grub-install --target=x86_64-efi --efi-directory=/dev/sda1 --bootloader-id=GRUB:

Installing for x86_64-efi platform.
grub-install: error: failed to get canonical path of `devtmpfs'.

Could you specify which things are in the wrong places? Thanks

Last edited by axsc (2023-06-26 23:46:00)

Offline

#4 2023-06-26 23:56:53

jonno2002
Member
Registered: 2016-11-21
Posts: 867

Re: [SOLVED]Grub Boots Into Command Line Every Time

did you mount /dev/sda1 to /mnt before running that command..... i only gave this command because thats how you appear to be trying to do it.

Offline

#5 2023-06-26 23:58:51

axsc
Member
Registered: 2019-02-22
Posts: 37

Re: [SOLVED]Grub Boots Into Command Line Every Time

jonno2002 wrote:

did you mount /dev/sda1 to /mnt before running that command..... i only gave this command because thats how you appear to be trying to do it.

Woops, my mistake was I didn't use sudo lol.

This seemed to add a GRUB directory to /mnt/EFI:

BOOT  GRUB  ubuntu

The contents of /mnt/EFI/GRUB:

grubx64.efi

Last edited by axsc (2023-06-27 00:01:27)

Offline

#6 2023-06-27 00:01:32

jonno2002
Member
Registered: 2016-11-21
Posts: 867

Re: [SOLVED]Grub Boots Into Command Line Every Time

lsblk -f
ls -R /mnt

EDIT: nevermind you fixed it.... well does it work now ?

Last edited by jonno2002 (2023-06-27 00:02:28)

Offline

#7 2023-06-27 00:05:12

axsc
Member
Registered: 2019-02-22
Posts: 37

Re: [SOLVED]Grub Boots Into Command Line Every Time

jonno2002 wrote:
lsblk -f
ls -R /mnt

My mistake was I didn't use sudo lol.

After using the command you gave me:

Installing for x86_64-efi platform.
Installation finished. No error reported.

Output of lsblk -f"

NAME     FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                             
├─sda1   vfat   FAT32 EFI   61AF-0FCA                             504.8M     1% /mnt
├─sda5   vfat   FAT32       2620-FD4F                                           
├─sda6   ext4   1.0         6733c547-045d-4eb3-83de-5dee002aa421                
├─sda100                                                                        
├─sda101 swap   1           323ed795-dd1a-4d3a-9970-98357a7cf8e2                [SWAP]
└─sda102 ext4   1.0         32651e3f-b094-430c-966b-4f9cd4a3c44e    3.6G    94% /

And ls -R /mnt:

/mnt:
EFI

/mnt/EFI:
BOOT  GRUB  ubuntu

/mnt/EFI/BOOT:
BOOTX64.EFI  fbx64.efi  mmx64.efi

/mnt/EFI/GRUB:
grubx64.efi

/mnt/EFI/ubuntu:
BOOTX64.CSV  grub.cfg  grubx64.efi  mmx64.efi  shimx64.efi

The /mnt/EFI/GRUB directory seems to be new after I input your command.
The contents of /mnt/EFI/ubuntu/grub.cfg seems to be the same as before (I'm not sure if that's a problem):

search.fs_uuid 61AF-0FCA root hd0,gpt102
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

Offline

#8 2023-06-27 00:08:59

jonno2002
Member
Registered: 2016-11-21
Posts: 867

Re: [SOLVED]Grub Boots Into Command Line Every Time

i have no idea how ubuntus grub works, you will have to ask on their forums if thats the grub you want to use.
the arch grub should work now if you reboot and select it from the efi boot menu, thats assuming you've already done the rest of the grub setup like grub-mkconfig, refer to the wiki link i posted for all of that

Offline

#9 2023-06-27 00:10:44

axsc
Member
Registered: 2019-02-22
Posts: 37

Re: [SOLVED]Grub Boots Into Command Line Every Time

jonno2002 wrote:
lsblk -f
ls -R /mnt

EDIT: nevermind you fixed it.... well does it work now ?

Yes, that worked! Thank you so much!

Just a couple followup questions:
1. Is that EFI partition at /dev/sda1 supposed to be mounted when I boot into Arch? I vaguely recall reading somewhere that it's supposed to be listed in /etc/fstab
2. You might have noticed I have a big unallocated space in my SSD. Would it be safe to boot into a live USB to resize my Arch partition to use up the rest of that space?

Thanks again!!!

Offline

#10 2023-06-27 00:14:21

jonno2002
Member
Registered: 2016-11-21
Posts: 867

Re: [SOLVED]Grub Boots Into Command Line Every Time

1. no it doesnt HAVE to be mounted as its only needed when running the grub-install command.
2. its never SAFE to do anything to your partitions without having a backup first, it may be fine or you might loose everything, ALWAYS BACKUP!

Offline

#11 2023-06-27 00:16:20

axsc
Member
Registered: 2019-02-22
Posts: 37

Re: [SOLVED]Grub Boots Into Command Line Every Time

jonno2002 wrote:

1. no it doesnt HAVE to be mounted as its only needed when running the grub-install command.
2. its never SAFE to do anything to your partitions without having a backup first, it may be fine or you might loose everything, ALWAYS BACKUP!

Got it. Also, I only have the ubuntu directory in /dev/sda1/EFI because I used a live Ubuntu USB to install it. Anyways, thanks again! I really appreciate you!

Offline

Board footer

Powered by FluxBB