0

I'm trying to install ParrotSec Linux on an MBR USB stick. The root folder in mounted on sdc5 and I have an ext2 partition on sdc3 containing grub configuration, vmlinux and initrd. I have another small partition on my stick on sdc1 formatted in fat32 and I'm trying to install EFI grub on it so I can boot to it from my computer.

For now, what I'm able to do is to boot to grub cli from another usb stick containing only grub and then use the grub cli to load linux and initrd and boot to the system. But that involves plugging two usb sticks on my computer, one with the system, the second one with grub.

Is there any way I can install grub directly on my ParrotSec usb stick so I can EFI boot on it ? I don't mind reinstalling the whole system.

1

In my experience, getting BIOS-mode and EFI-mode GRUBs to coexist on one medium can be tricky, since they may want to use the same configuration file, but have different needs for that. To be sure, it can be made to work, but unless you're very knowledgeable about GRUB, have very explicit instructions from somebody who has that knowledge, or are very lucky, you can end up with a tangled mess. I realize from your own answer, tourdetour, that you've worked past this hurdle, and that's great; but....

My general recommendation for this task is to rely on two different boot loaders, such as GRUB for BIOS-mode and rEFInd (caveat: I maintain rEFInd) for EFI-mode booting. They use different configuration files, so there's no chance of conflict on that score. Setting it up for BIOS-mode first, but with a FAT partition set aside to become the EFI System Partition (ESP), is a good start. The EFI boot loader must then be installed using the fallback filename (EFI/BOOT/bootx64.efi, at least for x86-64 systems) on the ESP. In the case of rEFInd, this can be done with the refind-install script:

refind-install --usedefault /dev/sdb1

This example sets up rEFInd on /dev/sdb1, which should be the unmounted FAT partition on the USB drive -- adjust that value as necessary. If you want to use ELILO, gummiboot/systemd-boot, or something else instead, you'll need to consult its documentation to learn how to install and configure it.

One caveat: If you plan to boot on systems that support Secure Boot, it may be easier to use GRUB 2 as the EFI-mode boot loader, at least if the distribution supports Secure Boot. You'd then use something else (SYSLINUX, LILO, or GRUB Legacy) for BIOS-mode booting. The reason is that most distributions provide a complete path, from Shim to GRUB 2 to the kernel, with Secure Boot support. Swapping out GRUB 2 for something else is possible, but means you'll need to add at least one key to your MOK list when you boot. This isn't too great a challenge on a one-time basis, but if you move the installation from one machine to another or distribute it widely, it can be a pain.

  • Thanks for your answer ! I had already refind installed on my mac and you're right, it's an excellent boot loader. Il actually recognized all my installed grub on my stick whereas my regular bios computer (that supports EFI) only recognizes the bios mode. But it's a great idea to install rEFInd directly onto the stick to make it portable. – tourdetour Apr 21 '16 at 5:01
1

Seems like I've done it. I've installed grub using grub-install from another linux distribution into the usb stick. That allowed my to boot on my USB stick from the BIOS. Then, I've copied another copy of grub inside of an EFI folder that allows me to boot from EFI. I have actually two grubs installed but it works...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.