0

I'm trying to make a usb drive with two linux distros installed inside. The idea is to carry the usb drive with me and boot the distros in the computer available at the place where I am at that moment. I know that this might be a bad practice, but just wanna give it a try.

I tried to install Kali Linux distro to my usb drive according to this video, in which a VirtualBox VM is used to install the O.S. into a usb drive.

When I first tried I didn't booted my VM in EFI mode and so the O.S. was installed in legacy mode (boot instructions written in the MBR). All was OK as long as I booted on my pc supporting legacy boot, but when I tried to boot from my Microsoft Surface (which doesn't support legacy boot), I obviously couldn't boot from the external drive.

So I tried to reinstall Kali with EFI mode activated on the VM, but I wasn't lucky this time either and didn't manage to boot the distro on my Surface. The situation was the same as when I tried to boot from my Surface having the distro installed in legacy mode: the Surface didn't recognize the bootable usb drive at all.

Googling I found a bunch of solutions to install/reinstall GRUB to an usb/external drive, but when I tried them, it seemed they were working only as long as I booted on the same device which I used to install GRUB on the usb drive. As an example, when I used the VirtualBox VM to install GRUB into my usb device, I was able to boot my Kali distro into the usb device ONLY from that VirtualBox VM.

I think I'm missing something here... Can someone give me an hand to clarify and, maybe, solve?

I attach screenshots describing the partitioning of my usb drive and the content of the ESP partition on the USB drive after the installation in EFI mode of Kali Linux, in case they can help:

Partitioning

ESP Partition content

--- UPDATE ---

I managed to boot my system on BOTH my PCs capable of EFI boot. I just moved the Kali boot loader located in my ESP from /EFI/Kali to the fallback path /EFI/BOOT and renamed the bootloader from "grubx64.efi" to the fallback name "bootx64.efi". I don't know why the boot process didn't manage to boot /EFI/Kali/grubx64.efi do someone has any clues?

Now I only got to make everything bootable in legacy mode (aka using BIOS), is it possible? It seems to be possible to boot a usb drive both UEFI and legacy mode, but is there a way I can set everything up without messing anything working in my actual EFI bootable configuration?

9
  • Info on Ubuntu: Updates -Instructions to make a boot drive, that boots both in UEFI and BIOS mode help.ubuntu.com/community/Installation/iso2usb/diy ubuntuforums.org/showthread.php?t=2299040 & askubuntu.com/questions/1300454/…
    – oldfred
    Apr 18 at 2:44
  • Hi, thanks for the comment. I took a look at your links. As far as I understood, the first two links refers to creating a usb LIVE boot UEFI/BIOS, while I need a full install of the distros. The third link seems to address my issue, but I couldn't understand how it works... It talks about a Full Install on the usb but still seems to use .iso images of some uefi-n-bios system which I couldn't manage to understand what it does... Could you give me more details about this?
    – ela
    Apr 18 at 11:08
  • Never used Kali, but with Ubuntu it only installs grub to the first drive, almost always the internal drive. You need to reinstall grub to USB drive. With Ubuntu, it used to be you only had UEFI version of grub or BIOS version of grub. So then you had to install with one, and then install with the other. But eventually a grub update would get system out of sync. Can you install both grub-pc and grub-efi-amd64?
    – oldfred
    Apr 18 at 13:58
  • I think I could. but I don't know if that's the point. At the current state I can't boot from the usb drive in UEFI mode either. The usb drive simply don't get recognized as a boot drive...
    – ela
    Apr 18 at 14:01
  • Lets see details, use ppa version with your live installer (2nd option) or any working install, not Boot-Repair ISO: Please copy & paste the pastebin link to the Boot-info summary report ( do not post report), do not run the auto fix till reviewed. help.ubuntu.com/community/Boot-Repair
    – oldfred
    Apr 18 at 14:17
0

After a ton of tests and a deeper investigation started from @oldfred useful insights, I think I solved the issue. In this answer I just want to briefly describe how I managed to accomplish that and the findings of my investigation.

I managed to boot my dual boot (Kali + AVLinux) system on every PC of mine, either only BIOS booting capable, only EFI booting booted or both.

The major requirement to do that is installing grub either in BIOS mode AND in EFI mode. This can be accomplished preparing the device/disk in such a way that it uses a GPT partition table and then creating a BIOS_BOOT partition as well as an EFI system partition at the beginning of the device. They're easy to create as there's plenty of material on creating both types of partition on the web. (e.g. BIOS_boot partition, EFI partition).

I attach a screenshot of my device partitioning, hoping to make it clearer:

My Device partitioning for dual boot BIOS+EFI

I now address the topic splitting it to the EFI boot part and the BIOS boot part

EFI Boot

As I said in the question, I also installed (for EFI boot mode: i.e. booting my VirtualBox VM enabling EFI*) the first distro (Kali Linux) of my dual boot system simply using its installer by a VirtualBox VM with its .iso file loaded as the content of the VM optical drive.

The installation went all good, except for the fact I wasn't able to boot my system in any machine (maybe apart the same VM which I used for the installation, but I'm not completely sure).

The reason for this was that the grub-install ran by the Kali installer placed grub inside my EFI partition in the /EFI/Kali/grubx64.efi path, while, as @oldfred suggested:

external devices only UEFI boot from /EFI/Boot/bootx64.efi.

This is why I managed to boot the system moving+renaming the boot loader located into the EFI partition from the /EFI/Kali/grubx64.efi path to /EFI/BOOT/bootx64.efi path.

Also, further investigation showed me that we can get rid of the problem reinstalling grub (f.e. following the metodology showed in this question) and adding the --removable parameter in the calling of the grub-install command.

the command on the guide would therefore become:

grub-install --removable /dev/sdX

This will place the boot loader into the /EFI/BOOT/BOOTX64.EFI path, solving the problem.

* This is pretty much the same of running the installer on an EFI boot capable PC

BIOS (Legacy) Boot

Once a BIOS_boot partition is created, we have to install grub for BIOS boot mode (a.k.a. installing it in the MBR) through grub-pc package*. The procedure is pretty much the same of the one used for installing grub for EFI boot mode, unless we DON'T mount the EFI directory:

sudo mount /dev/sdXX /mnt/boot/efi

and we specify the i386-pc target platform in the grub-install command:

grub-install --target=i386-pc /dev/sdX

* Actually, unless I read that grub-pc package is for installing grub in MBR (so for BIOS boot mode) and grub-efi package is for installing grub in the EFI partition (so for EFI boot mode) I'm not 100% sure about this, since I managed to install grub in the EFI partition with grub-pc package installed as well

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.