Grub reinstall - finding the correct disk

Hi,

with the latest stable update a reinstall of grub is needed.

As I have a complex setup and cannot remember where I have installed grub I need help with finding the correct device to reinstall grub to. I have not yet updated so I still have a running system.

I have two disk. When I installed manjaro on one of the disks a dual boot Windows/Linux was already there (I moved the disk from a broken laptop). On the other disk from the new laptop a ubuntu was already installed. I don’t want to break my system and I am not sure whether I have more then one grub install on the disks. So help to find the correct way to upgrade my grub would be greatly appreciated.

With the help of the info page GRUB/Restore the GRUB Bootloader I tried to gather some information.

I’m pretty sure that I don’t have EFI and the output lets me believe I have gpt.

But how do I find out what the correct disk is?

lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME 
PATH      PTTYPE PARTTYPE                             FSTYPE PARTTYPENAME
/dev/sda  gpt                                                
/dev/sda1 gpt    ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 vfat   Microsoft basic data
/dev/sda2 gpt    0657fd6d-a4ab-43c4-84e5-0933c84b4f4f swap   Linux swap
/dev/sda3 gpt    ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 ext4   Microsoft basic data
/dev/sda4 gpt    ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 ext4   Microsoft basic data
/dev/sda5 gpt    0fc63daf-8483-4772-8e79-3d69d8477de4 ext4   Linux filesystem
/dev/sda6 gpt    0fc63daf-8483-4772-8e79-3d69d8477de4 ext4   Linux filesystem
/dev/sda7 gpt    0fc63daf-8483-4772-8e79-3d69d8477de4 ext4   Linux filesystem
/dev/sdb  dos                                                
/dev/sdb1 dos    0x7                                  ntfs   HPFS/NTFS/exFAT
/dev/sdb2 dos    0x7                                  ntfs   HPFS/NTFS/exFAT
/dev/sdb3 dos    0xf                                         W95 Ext'd (LBA)
/dev/sdb4 dos    0x12                                 ntfs   Compaq diagnostics
/dev/sdb5 dos    0x7                                  ntfs   HPFS/NTFS/exFAT
/dev/sdb6 dos    0x83                                 ext4   Linux
/dev/sdb7 dos    0x82                                 swap   Linux swap / Solaris
/dev/sdb8 dos    0x83                                 ext4   Linux

sudo fdisk -l
[sudo] password for noname: 
Disk /dev/sda: 931,51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000LM014-1EJ1
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: EEB612D4-AF1F-4810-B73A-9E69D56E9702

Device          Start        End   Sectors  Size Type
/dev/sda1        2048    1050623   1048576  512M Microsoft basic data
/dev/sda2     1050624   17827839  16777216    8G Linux swap
/dev/sda3    17827840  122685439 104857600   50G Microsoft basic data
/dev/sda4   122685440  290457599 167772160   80G Microsoft basic data
/dev/sda5   290457600  709887999 419430400  200G Linux filesystem
/dev/sda6   709888000 1443891199 734003200  350G Linux filesystem
/dev/sda7  1443891200 1953523711 509632512  243G Linux filesystem


Disk /dev/sdb: 596,17 GiB, 640135028736 bytes, 1250263728 sectors
Disk model: SAMSUNG HM641JI 
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: 0x2bd2c32a

Device     Boot      Start        End   Sectors   Size Id Type
/dev/sdb1             2048     206847    204800   100M  7 HPFS/NTFS/exFAT
/dev/sdb2           206848  623861759 623654912 297,4G  7 HPFS/NTFS/exFAT
/dev/sdb3        623863806 1248159743 624295938 297,7G  f W95 Ext'd (LBA)
/dev/sdb4       1248159744 1250260991   2101248     1G 12 Compaq diagnostics
/dev/sdb5        623863808  686778367  62914560    30G  7 HPFS/NTFS/exFAT
/dev/sdb6        686780416  965451775 278671360 132,9G 83 Linux
/dev/sdb7       1228943360 1248159743  19216384   9,2G 82 Linux swap / Solaris
/dev/sdb8  *     965453824 1228941311 263487488 125,6G 83 Linux

Partition table entries are not in disk order.

With the correct disk I would update and do

grub-install --force --target=i386-pc --recheck --boot-directory=/boot /dev/sdy

and

grub-mkconfig -o /boot/grub/grub.cfg

Can you confirm this?

Update 2023-12-26: Thanks you all for your help. That was scary but it worked out in the end. On boot grub version 2.12 greets me and everything still works.

/dev/sda1 gpt    ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 vfat   Microsoft basic data

Is most likely your boot, that you share with windows. :-/
But it is gpt, witch is a good sign that you are booting in efi at least. :slight_smile:

That is for old boot, not efi.

Things would become more clear if you post the output of:

cat /etc/fstab
df -h

To be honest, I would recomend you to create a boot partition only for manjaro and use that.

Just a side note:

  • /dev/sda has gpt and a vfat partition at the beginning (sda1), which indicates that it is EFI.
  • /dev/sdb has (ms-)dos what is commonly BIOS, EFI doesn’t work on such a partition table.

https://wiki.manjaro.org/index.php/GRUB/Restore_the_GRUB_Bootloader#Reinstall_GRUB

If it is BIOS, it would be correct.

Thanks for your help.

cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>                           <mount point>  <type>  <options>  <dump>  <pass>
UUID=13af21e3-55c6-4682-9cb8-d56877779e87 swap           swap    defaults,noatime 0       0
UUID=c9dda4da-4c60-473e-83b6-199197f4511e /              ext4    defaults,noatime 0       1
UUID=e66a09e5-948e-4229-bc1f-3ffa8f79e537 swap           swap    defaults,noatime 0       0

df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             3,9G     0  3,9G   0% /dev
run             3,9G  1,5M  3,9G   1% /run
/dev/sda5       196G  179G  7,8G  96% /
tmpfs           3,9G  132K  3,9G   1% /dev/shm
tmpfs           3,9G   20K  3,9G   1% /tmp
tmpfs           785M  184K  785M   1% /run/user/1000
/dev/sda6       344G  316G   11G  97% /run/media/noname/cead30df-60ad-4273-920f-18e866a88794
/dev/sdb6       131G  123G  1,4G  99% /run/media/noname/d07b0dd8-acdf-415c-8af4-0a2a99124c77
/dev/sdb8       124G  115G  7,4G  94% /run/media/noname/78250081-ab6d-4810-9720-fd83a63b8985

I do still want to be able do multi boot and I’d rather put grub where it is now. So I don’t have a third place where grub is.

I found the grubenv file. Is that any help?

saved_entry=gnulinux-simple-c9dda4da-4c60-473e-83b6-199197f4511e

Is the place where the initramfs files are stored an indication where the current grub is located? I found one grub folder with old kernels on sdb8. This must be from the old ubuntu. In nemo under File system/boot/grub are the current initramfs files. I don’t know how to find out what disk it is.

I am almost certain I don’t run efi. It could be that it was initially installed by the vendor but I have never used it. I could check later via

> What I had to do was get into the GRUB command line area to figure out which boot system I have. For those that only have Manjaro installed, such that GRUB defaults to not showing before booting:

1. Restart Manjaro and press the ESC key a bunch of times as the UEFI or BIOS is finishing up and before Manjaro boots. This will bring up the GRUB screen.

2. Press the C key to enter the command line mode.

3. Type in the command echo $grub_platform
If it shows PC, you have a BIOS install, if it shows EFI you have a EFI install.
Link: GNU GRUB Manual 2.12 7

4. Type in exit to end the session, and Manjaro will boot automatically.

That was from this forum post.

2 problems.

  1. I have absolutely zero experience with old boot.
  2. I’m still not convinced that the windows partition is not booting in efi.

What does efibootmgr give?

You will still have a dual boot, it’s just that you start windows from pure boot partition instead of sharing it with the windows partition and vice versa.

If you still want to boot to the windows partition you just put it first in order in your bios.
What I am saying is I recommend you to create a brand new entry in your bios where you can select windows or manjaro AND you will be able to boot manjaro (grub) and from there decide where you want to boot.

But all of this depends on if you are actually booting in efi or not.

Well the problem is not where grub is located, but where the MBR was written. grub is usually installed in /boot/grub on Manjaro. Since sda is gpt and no bios-grub partition is located there and you say that EFI was not used by you, I would proclaim that the MBR was written on sdb although the root is on sda5.

I think that is the ubuntu installation he is talking about, I think windows here is efi and on sda1 and that is where he usually boots from.

The question is why 2 swaps, why no boot mount in fstab, but first things first.

Wait… he use Ubuntu’s grub to boot Manjaro? Then no grub reinstall ist needed, since Ubuntu manages it.

That is a real frankenstein system. :sweat_smile:

@megavolt

I mean this.

We have to figure out what is actually going on here, so I’m taking babysteps instead of flooding questions. :slight_smile:

2 Likes

So in my view the system boots with the MBR of sdb and has the target sdb8:

If sdb8 is not Manjaro, then he doesn’t need to reinstall grub, since booting is managed by another grub of another Distro. On BIOS only one bootloader can be targeted, if you reinstall, it would switch to another bootloader, thus Manjaro’s grub for example.

That is what I question.
I think the ubuntu install was on a completely different computer and THAT was not in efi.
He then just slapped that into the computer.

Only OP can clarify this.

Edit
Darn it, you might be correct.

Is NOT on sda. (unless the parttype id is different from UUID)

1 Like

df /boot | awk 'FNR==2 { print $1 }'

He has no boot mounted in fstab. xD

I guess that is an accurate description :grimacing:

Thank you all for trying to help me.

Let me try to explain what I remember. This all happened a few years ago. I think it started already with the old computer. This had windows installed and there where already so many primary partitions that I had to change the partitions quite a lot to even be able to install a linux next to it.
After a few years the Laptop broke and I bought a new one. This had ubuntu preinstalled and disk sda in it. No idea how grub or efi was handled here. I frankensteined the other disk sdb in (windows, plus old linux installs and I think manjaro was on there already). To be able to to use my computer again like before I must have done something to be able to boot all of the systems. I think I tried to “link” to the old grub but I don’t recall what I really did.

I was kind of confused how ubuntu and manjaro could update grub at the same time (they probably did not) but as everything worked I have not looked more into it).

Maybe it is time to fix the chaos.

I do almost exclusively use manjaro now. I do want to be able to boot into the other systems but manjaro should be the main system. Manjaro is on sdb so I believe it would be a good idea to put the gpt somewhere on that disk. I am not sure where I could find space for it though. Any ideas?

Yeah, decide on ONE system. I would recomend efi because that is what is almost assumed nowdays.
But if it works with old boot, maybe you want to stay on that, idk, only you know.

As I said before, I have limited knowledge of old boot (witch you correctly stated is the boot you are using) so I should probably leave this to others and learn from the sidelines.

Check if Manjaro is really booted in BIOS by checking this directory: ls /sys/firmware/efi/efivars If empty/not there, it is BIOS.

Create a 10MiB unformatted partition (preferably at the beginning of the disk), flag it with bios_grub and name it bios-grub (so you know later what that is). With this partition you can write the MBR on a GPT partition table, when running grub-install.

Then you would use Manjaro’s grub bootloader.

Hwoever I would strongly advice you to use EFI and only BIOS, if the OS doesn’t support it.

ls /sys/firmware/efi/efivars
ls: cannot access '/sys/firmware/efi/efivars': No such file or directory

I won’t be able to do this at the beginning of the disk. Do I have to do something differently if it is is not at the beginning? Can the partition be part of an extended partition?

I would like to stay with BIOS instead of EFI. I just don’t want to have more things to check. With BIOS I know that it works.

I just used the Pamac GUI and could easily auto update with both of my 2 systems running in MBR/Legacy mode… was a flawless update.

Just create timeshift snapshot and prepare a Manjaro USB Stick… just in case.

I personaly think that MBR is superior to this stupid UEFI features anyways… its a big downgrade related to security… applications or a virus can change your UEFI settings while the good old Bios is still protected, is a big plus to NOT use EFI.

I also remember a AMD driver issue, 1,5 years ago… where a AMD driver changed UEFI Voltage (on CPU’s or GPU’s, i can’t remember) settings and alot people had a unstable systems from it!!!

This is total DANGEROUS… dont use UEFI, as long as possible stay with BIOS/Legacy.

To bad that the new GPU Vendors forced us to use UEFI… instead the much better BIOS (with less dangerous FEATURES).

This disk (currently on /dev/sda) is the GPT partitioned drive, containing Windows and Linux. As Bedna mentioned, it’s likely that disk is already configured to boot as UEFI. You can possibly find the model number on the label or the end of the disk, to identify it visually.

ST1000LM014-1EJ1

The other disk (currently /dev/sdb) has Legacy/MBR partitioning.

SAMSUNG HM641JI

Here’s the issue: Booting 2 disks with different boot technologies will guarantee ongoing problems, in a multiboot environment.

You can choose UEFI or Legacy, but not both.

If you choose UEFI, then you need to disable CSM in the BIOS to boot UEFI exclusively, and sacrifice the Legacy disk and its contents (save any data you need to USB, or similar).

Then you would need to create a new GUID Partition Table (GPT) on that disk and prepare it for UEFI boot. If you boot the Manjaro installer and choose manual partitioning, you can do this (carefully) during install.

I also recommend disconnecting the current UEFI disk (ST1000LM014-1EJ1) before installing Manjaro, to avoid likely complication. You can reconnect it later when Manjaro is installed.

There are more steps involved which no doubt someone will help you with once you decide how you’d like to progress.

In the meantime, have a good Xmas. :christmas_tree:

He will lose all data not only a partition on that disk, so he need to backup his whole harddrive from changing from MBR to GPT. This also include a full OS reinstall.

Edit: I just write that, to make 100% clear… how big this change, will be.
And it should be well planned.