Install grub2 only.

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
PeterTi
Level 1
Level 1
Posts: 19
Joined: Wed Apr 17, 2013 1:27 pm

Install grub2 only.

Post by PeterTi »

Hi,

I'm having a grub2 installation problem
I had an installed system with 4 physical drives:
#1 Windows
#2 Linux Mint
#3 Linux mint
#4 I want to boot from this drive and keep the rest empty. So I just want to install grub2 on a 1 GB partition on this drive.This is an nvme-ssd.

The system used to work after installing the first 3 drives. The boot partition was accidentally already on #4.(Probably caused becuase this drive was accidentally selected with the standard mint installer... ).
When I formatted this drive supprisingly my grub2 was gone. I thought it was on #3. So my #3 installation has no boot option. I'm unable to boot it from bios.
After a day trying to install grub2 manually, I'm still not succesfull.

So now i'm asking for help. :D
I do would like to do this manual. So I learn and can repeat it in the future.

What I tried was(booting from live-usb):
1. showing devices:

Code: Select all

sudo fdisk -l
result

Code: Select all

Disk /dev/loop0: 1.7 GiB, 1842749440 bytes, 3599120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/nvme0n1: 465.8 GiB, 500107862016 bytes, 976773168 sectors
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: 66F4369E-083D-4C1E-AFC0-92AB7D913A62

Device         Start      End  Sectors  Size Type
/dev/nvme0n1p1  2048 60561407 60559360 28.9G Linux filesystem


Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
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: 1965D484-46F2-4F0D-B935-E0BC8226BE2C

Device       Start       End   Sectors  Size Type
/dev/sda1  7815168 976773134 968957967  462G Linux filesystem
/dev/sda2     2048   7815167   7813120  3.7G Linux swap

Partition table entries are not in disk order.


Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 762B86F7-7610-4DBB-B27E-66F85FA01A37

Device     Start        End    Sectors  Size Type
/dev/sdb1   2048 3907028991 3907026944  1.8T Linux filesystem


Disk /dev/sdc: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 794FB41C-9B39-4ACD-962B-83EEED5CD0D6

Device       Start        End    Sectors  Size Type
/dev/sdc1     2048    1023999    1021952  499M Windows recovery environment
/dev/sdc2  1024000    1226751     202752   99M EFI System
/dev/sdc3  1226752    1259519      32768   16M Microsoft reserved
/dev/sdc4  1259520 3907028991 3905769472  1.8T Microsoft basic data


Disk /dev/sdi: 7.5 GiB, 8015314944 bytes, 15654912 sectors
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: dos
Disk identifier: 0xaff9ac97

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdi1  *     2048 15654911 15652864  7.5G  c W95 FAT32 (LBA)


2. formatting drive (gparted :D)
1gb ext4.
with error
realised this writing this topic :s :
e2label: No such file or directory while trying to open /dev/nvme0n1p1
Couldn't find valid filesystem superblock.

Couldn't find valid filesystem superblock.


3. mounting:

Code: Select all

mount /dev/nvme0n1 /boot
error:

Code: Select all

mount: wrong fs type, bad option, bad superblock on /dev/nvme0n1,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

and

Code: Select all

mount /dev/nvme0 /boot
error:

Code: Select all

mount:  /dev/nvme0 is not a block device
logical error reading 3...(realised writing this)
I still dont know how to solve
4. installing grub.

Code: Select all

sudo grub-install /dev/nvme0
error:

Code: Select all

grub-probe: error: failed to get canonical path of `aufs'.
Installing for i386-pc platform.
grub-install.real: error: failed to get canonical path of `aufs'.
I got stuck. I have been googling and retrying for a day. I also had other errors but I wanted to post a good single fresh try.
The goal is not to do a complete install on #4. This would be easy doing an automatic install .
I want to keep this drive empty. Except for the 1 gb boot partition.

Thanks in advance.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
michael louwe

Re: Install grub2 only.

Post by michael louwe »

@ PeterTi, .......
PeterTi wrote:...
.
For some guidance, please refer to these links ...

https://ubuntuforums.org/showthread.php?t=2147295 (uefi install on multi-drives)
.
.
(info on uefi booting and how to use efibootmgr)
https://www.happyassassin.net/2014/01/2 ... work-then/

https://nwrickert2.wordpress.com/2013/0 ... and-linux/

https://askubuntu.com/questions/380447/ ... ew-machine
(One possible workaround to this problem is to copy GRUB from EFI/ubuntu/grubx64.efi to EFI/BOOT/bootx64.efi = create a new folder, BOOT, in the EFI folder and rename grubx64.efi to bootx64.efi. Restart.)

https://www.lifewire.com/change-the-efi ... gr-4028027

https://www.linuxbabe.com/command-line/ ... r-examples
.
.
(Laurent85's UEFI boot repair)
viewtopic.php?f=46&t=260547
.
viewtopic.php?f=46&t=260504
.
viewtopic.php?f=46&t=260170
.
viewtopic.php?f=46&t=260576
PeterTi
Level 1
Level 1
Posts: 19
Joined: Wed Apr 17, 2013 1:27 pm

Re: Install grub2 only.

Post by PeterTi »

Thanks

I got a bit further.

1. Creating partition.
Succes ext4 on /dev/nvme0n1

Code: Select all

 /dev/nvme0n1p1
2. mounting
Succes

Code: Select all

sudo mount /dev/nvme0n1p1 /mnt
mkdir /mnt/boot
3. copying files
Succes.
Just copying al the working stuff from current booting drive. Have not did the renaming thing yet. EFI/BOOT/bootx64.efi

Code: Select all

sudo cp -R /boot/* mnt/boot/
4. installing grub.

Code: Select all

sudo grub-install --boot-directory=/mnt/boot /dev/nvme0 #drive not partition,right?
Error:

Code: Select all

Unrecognized option `--boot-directory=/mnt/boot'
Usage: grub-install [OPTION] install_device
Install GRUB on your drive.
Retry:

Code: Select all

sudo grub-install --root-directory=/mnt/boot /dev/nvme0n1
Error:

Code: Select all

/dev/nvme0n1 does not have any corresponding BIOS drive.

In the following lint it explains that.
https://ubuntuforums.org/showthread.php?t=1014708
But im not restoring or installing to my current drive.
Plus it didn't work even if i would wanted to restore.

Code: Select all

find /boot/grub/stage1 ->Error 15: File not found
Also

Code: Select all

sudo grub-install --root-directory=/mnt/boot /dev/nvme0n1 [b]--recheck[/b]

Error:

Code: Select all

Probing devices to guess BIOS drives. This may take a long time.
/dev/nvme0n1 does not have any corresponding BIOS drive
Reading in the link:
https://ubuntuforums.org/showthread.php?t=2147295
I learned, if i understand correctly that in the grub shell i have to :

Code: Select all

root (hd<a>,<b>)
?
So i need to get the "hd*" identification of my nvme drive?
I have no idea. Please help.

Addded later:
"
On this link:
https://wiki.gentoo.org/wiki/GRUB_Error_Reference
It explains its due to exotic drive. I have the m.2 in a pci-e slot.
This was the reason for different boot partitions. If the pcie slot is inserted i have my grub menu. If not it boots second boot option (firmware).
After saving all my new learned lessons i unmount and reboot and see what i can do.Maybe it already works. Becuase of copying.
"
5. unmounting
not there yet
6. rebooting
not there yet
Thanks.
michael louwe

Re: Install grub2 only.

Post by michael louwe »

@ PeterTi, .......
PeterTi wrote:...
.
AFAIK, a UEFI multi-drives system can only use one EFI System Partition(ESP) for the bootloaders, ie the last installed Linux OS should have its grub-efi bootloader installed on this one ESP, which in your case is at /sdc2 of the 1.8TB HDD. IOW, you cannot install the last bootloader on another ESP that is on another hard-drive, ie your 4th NVMe SSD.

So, try installing the grub-efi bootloader on the ESP at /sdc2. Please refer to ... https://sites.google.com/site/easylinuxtipsproject/6
PeterTi
Level 1
Level 1
Posts: 19
Joined: Wed Apr 17, 2013 1:27 pm

Re: Install grub2 only.

Post by PeterTi »

Thank you.

AFAIK you must be right. Meanwhile I tried to fix my #3 drive which did not boot.
The ESP must be on #2 becuase that does boot.

What did work was on #3(as in positive grub result):

Code: Select all

sudo grub-install --root-directory=/media/peter/730181ff-88da-418d-b3a7-75030205d6c5/ /dev/sdb
with result of second try:

Code: Select all

Installing GRUB to /dev/sdb as (hd1)...
Installation finished. No error reported.
This is the contents of the device map /media/peter/730181ff-88da-418d-b3a7-75030205d6c5//boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(fd0)   /dev/fd0
(hd0)   /dev/sda
(hd1)   /dev/sdb
(hd2)   /dev/sdc

it posts the harddrive names hd* :D

But the drive was not bootable from firmware. Just not visable!

This does confirm you're last post afaik.
Before I formatted. It all used to work amd firmware detected all bootable drives.All performed by default live-usb installation. Just adding new harddrives and installing them. But I want to learn and understand.

So it is a matter of placing the ESP.

Also:

Code: Select all

grub> root(fd0,1)
root(fd0,1)

Error 27: Unrecognized command

failed. If I get this last root(fd0,1) code to work I shoud be able to run my

Code: Select all

udo grub-install --root-directory=/mnt/boot /dev/nvme0n1 --recheck
succesful.

Error still:

Code: Select all

Probing devices to guess BIOS drives. This may take a long time.
/dev/nvme0n1 does not have any corresponding BIOS drive.

The drive is mounted and looks exactly like the current booting drive as for the /boot folder off course. Its ext4 by the way.

The EFI partition is on #1 it's a FAT32 partititon and has mount point /boot/efi.
But it's not where i have booted from now.

I added in fstab the UUID of my nvme:

Code: Select all

UUID=a9ac61c2-9cc7-4408-bd94-034bb9650fa4 /boot/efi ext4 umask=0077  0 1
Also in sudo vim /mnt/boot/grub/device.map :

Code: Select all

(hd3)   /dev/nvme0n1
(hd0)   /dev/sda
(hd1)   /dev/sdb
(hd2)   /dev/sdc
from http://go2linux.garron.me/linux/2010/09 ... rub2-765/
Still same error.
PeterTi
Level 1
Level 1
Posts: 19
Joined: Wed Apr 17, 2013 1:27 pm

Re: Install grub2 only.

Post by PeterTi »

You where right about the booting. It was from the Windows the FAT32 partition on #1
michael louwe

Re: Install grub2 only.

Post by michael louwe »

@ PeterTi
PeterTi wrote:...
.
You have 4 hard-drives;

/sdc = Windows = 2TB HDD
/sdb = LM = 2TB HDD
/sda = LM = 500GB HDD
/nvme0n1 = nearly empty = 500GB SSD

The EFI System Partition is on the Windows drive at /sdc2.

You can either mount the / or Root partition of /sdb or /sda. Let's use /sda1 as the mounted / or Root partition to do the reinstall of Grub as per the link I had provided.
... After the Grub reinstall has completed, configure BIOS setup to boot first from /sda(= the 500GB HDD). You should then be presented with the Grub menu to boot into any one of the 3 OS.

Keep the SSD as a data drive.

Alternatively, if Grub reinstall fails, try to reinstall one of the LM, like you did previously.(eg "Erase disk and install LM") If needed, do a sudo update-grub after the reinstall. Backup data if needed, before reinstalling.
PeterTi
Level 1
Level 1
Posts: 19
Joined: Wed Apr 17, 2013 1:27 pm

Re: Install grub2 only.

Post by PeterTi »

I got once again a bit further in understanding EFI, grub etc. I've been reading from the links, especially https://www.happyassassin.net/2014/01/2 ... work-then/ helped me a lot understanding the bunch.

I have not used the live-cd or live-usb method from you're link. https://sites.google.com/site/easylinuxtipsproject/6
I booted and did the same thing booted in LM from sda1. Almost..

I performed:

Code: Select all

sudo grub-install /dev/sda1
#Succes first time doing it as simple as this
Then:

Code: Select all

sudo apt-get install --reinstall grub-efi-amd64
This finally gave all the entries in the grub menu (on sdb). (Sorry for not understanding any sooner :D )
But choosing for the LM on on sdb i got an error (ACPI ERROR: [DSSP] namespace lookup failure.) it does not reach desktop. I'll fix this later.

Also I mounted and copied the /EFI/* from sdc to nvme0n1.
It now gives Windows and LM (firmware reeds Ubuntu) entries in firmware on nvme0n1. So another succes. This was my first goal. Now I want to boot from sda.

The only thing i still don't understand is why i cannot boot sda from firmware. The /boot folder on sda is exactly the same as the /boot folder on sdb.
I was already able to boot sda from the grub menu on sdb.
What could i do? update EFI partition? :S


Thanks a lot.
michael louwe

Re: Install grub2 only.

Post by michael louwe »

@ PeterTi, .......
PeterTi wrote:...
.
FYI,

https://sites.google.com/site/easylinuxtipsproject/grub
Grub consists of two parts.
First, the main part of the program itself, which is placed in the Master Boot Record (MBR). The Master Boot Record is the first sector of the hard disk.

Secondly, there's the Grub boot menu with the various operating systems, plus some supporting files. These are not in the MBR, but in a folder on the active Linux partition.

Do you have two physical hard disks in your computer? Then it's important for you to know that Grub always resides in the MBR of the first hard disk. The first hard disk is the hard disk that's number 1 in the boot priority (boot sequence) in the BIOS of your computer.

If you restore (repair) Grub in the MBR, then you must again tell Grub where it can find the existing boot menu.
The above conditions also apply when installing Grub bootloader to the EFI System Partition. During a clean install of LM, the LM Installer does the above automatically for the users. But when reinstalling Grub, the users have to manually do it, ie entering Grub menu data on the active / or Root partition.
lostfarmer

Re: Install grub2 only.

Post by lostfarmer »

the m.2 in a pci-e slot
But the drive was not bootable from firmware. Just not visable!
error code : /dev/nvme0n1 does not have any corresponding BIOS drive.
Would say your computer can not boot from a pci-e slot or you have not enabled it in the bios/firmware.
PeterTi
Level 1
Level 1
Posts: 19
Joined: Wed Apr 17, 2013 1:27 pm

Re: Install grub2 only.

Post by PeterTi »

Thank you for you're information michael louwe.

The first part of grub, the boatloader (AFAIK) resides now succesfully on the nvme(this was my goal at the beginning, install grub2 only, but now with the menu on sdb).
So it works lostfarmer :D .

Code: Select all

df /boot/efi/
Filesystem
/dev/nvme0n1p1
Also i'm able to boot this option from my firmware succesfull. This is the only boot option so i disabled all other options, so i'm sure this works.
This is the first part of grub, the EFI partition (mbr on old mobo's), formatted as FAT32. This partition is a requirement, right for multiboot systems? (ext3 in this link:)
https://help.ubuntu.com/community/Parti ... le_systems

This works. The second part of grub, the menu of boot options is on sda1,the sata-ssd, i think. I don't know how to verify,yet.

I resolved the issue i had, the fact that sdb, the 2TB wouldn't boot. It was:

Code: Select all

Failed to create mount unit file /run/systemd/generator/boot-efi.mount, as it already exists. dublicate entry in /etc/fstab
by modifying the /etc/stab/ i manually added the nvme entry... I removed it now it works.
So from grub i'm able to boot any OS. 8)

It still gives this error but it works:

Code: Select all

 (ACPI ERROR: [DSSP] namespace lookup failure.) i
Now the only thing to do is to detect my sata-ssd in firmware.
I found:
http://www.rodsbooks.com/efi-bootloader ... #obtaining
so this would solve it:

Code: Select all

efibootmgr -c -d /dev/sda -p 2 -L "Linux Mint sata-ssd 500" -l "\efi\boot\bootx64.efi"
right?

Allright to wrap this up:

Grub needs one EFI partition.(old mobo's mbr). Holds boot programs, Windows boot manager and linux boot manager (grub).

It needs one os to have the grubmenu in, in /boot/grub/. This has to be updated in the EFI partition.

If i want to detect OS's in (uefi) firmware i have to use the efibootmgr command? The EFI partition must be accesible? Becuase this is what the firmware reeds and so detects?
How is a single boot system detecting it's OS? It hasn't have an EFI partition? Why is my usb cardreader detected as an boot option in firmware but not my sata-ssd?


Thanks a lot for help, patience and info. I got a step further in Linux, ehh i think :roll: :P . Thanks.
Locked

Return to “Installation & Boot”