I want to switch my grub bootloader from ssd to usb where my os is installed

I installed Manjaro on usb. I forgot to select install bootloader on USB. Now I have it on my ssd. I want to switch it to my usb. I have legacy boot with GPT partion on usb. I have already made a / boot partition and allotted it with boot flag in GParted.

Please help me to switch it.

Thanks in advance.

2 Likes

Just grub-install to that /boot partition, something like:

sudo grub-install --boot-directory=/boot /dev/sda

Feel free to read the wiki article.

1 Like

Welcome to the forum! :vulcan_salute:

When creating a GPT partition table that is to be used in combination with legacy BIOS boot, you should also create an unformatted partition of about 2 MiB in size, of the type bios_grub, and it is -this partition that needs to be marked with the boot flag.

If you do not create this unformatted partition, then GRUB will overwrite the beginning of your root partition. You really don’t want that to happen. It doesn’t matter where on the drive the bios_grub partition is located, as long as it has the boot flag. GRUB will then install (part of) itself — specifically, the core.img part — in that partition. And it doesn’t have to be formatted because there’s no point — GRUB will use the raw blocks either way, because core.boot does not contain any filesystem drivers.

The above all said, first you have to find out what the USB drive is called by the kernel. For the sake of giving you an example of the install command, I will assume that it’s /dev/sdc, but change this to whatever is applicable on your system.

Open up a terminal and issue the following command, again, substituting /dev/sdc by whatever is applicable for your machine, and substituting /dev/sdc2 by the correct partition that is to serve as the root filesystem on your USB drive. :arrow_down:

sudo mount -t auto /dev/sdc2 /mnt
sudo grub-install --recheck --no-rs-codes --modules=gpt --target=i386-pc --boot-directory=/mnt/boot --verbose /dev/sdc

Note: The above command assumes that the /boot directory — which will contain the kernel images and the GRUB configuration — of that system will reside on the target root filesystem. If this is not the case, then you need to not only mount the prospective root filesystem, but you also need to mount the filesystem that is to be used as the /boot of the target system to /mnt/boot before running the command.

1 Like

Thanks a lot brother. It worked for me.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.