0

My partition table looks like this.

/dev/mmcblk1p1     2048     6143     4096    2M BIOS boot
/dev/mmcblk1p2     6144  4200447  4194304    2G Linux filesystem
/dev/mmcblk1p3  4200448 16783359 12582912    6G Linux filesystem

I'm booting from BIOS mode. UEFI is not supported on the devices.

I have two identical devices. On device A grub is taking the configuration from "/dev/mmcblk1p2"/boot/grub/grub.cfg.
On device B I copied over the content in the partitions /dev/mmcblk1p2 and /dev/mmcblk1p3.
I then installed grub on device B with:

grub-install /dev/mmcblk1

On device A grub was already installed correctly.

In the grub menu I can correctly select the partitions I want to boot into. However grub is taking the grub.cfg from /dev/mmcblk1p3 instead of /dev/mmcblk1p2.

I want grub to be installed on /dev/mmcblk1p2 because this is my "recovery" partition.

I've booted into different partitions and ran grub-install /dev/mmcblk1 but it didn't have any effect on which partition grub was going to take the grub.cfg file from.
I've also booted from an USB stick and ran the command from there.

Question: How can I make grub take the /boot/grub/grub.cfg from /dev/mmcblk1p2 instead of /dev/mmcblk1p3?


I have seen this Stackoverflow question but it didn't help me further.

2
  • Hello and welcome to SU. I think you contradict yourself in your question. It is not clear what you are trying to achieve. You frist state that "grub is taking the grub.cfg from /dev/mmcblk1p3 instead of /dev/mmcblk1p2" but then you say you are trying to achieve exactly the same behavior "How can I make grub take the /boot/grub/grub.cfg from /dev/mmcblk1p3 instead of /dev/mmcblk1p2?". If the above is correct then there is no problem right? Commented Feb 25, 2020 at 16:31
  • Sorry I mistyped. Edited my question. I want both devices to take the grub.cfg from the second partition /dev/mmcblk1p2. It works on device A but not on device B.
    – Tin Nguyen
    Commented Feb 25, 2020 at 17:10

1 Answer 1

1

Consider using flag --boot-directory to explicitly tell GRUB where you want your grub.cfg

Note that if you are installing this on filesystem other than your current root you need to either chroot into it or mount it and use --boot-directory

Otherwise when grub-install is running it will write code to MBR pointing at \boot on your current root partition by default...

example:

sudo mount /dev/mmcblk1p2 /mnt
sudo grub-install --boot-directory /mnt/boot/ /dev/mmcblk1

For chroot option you can follow example here:

https://howtoubuntu.org/how-to-repair-restore-reinstall-grub-2-with-a-ubuntu-live-cd

2
  • Thanks I will try this tomorrow evening! I'll report back.
    – Tin Nguyen
    Commented Feb 25, 2020 at 17:11
  • It's working. :-)
    – Tin Nguyen
    Commented Feb 26, 2020 at 14:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .