0

I intend to create a dualboot persistent usb. I'd like to try creating a USB where I can boot macOS High Sierra and WIndows 10. From what I understand of LVM, I can create 2 VG, 1 APFS and 1 NTFS. This would allow me to boot into Windows10 on a PC and Windows10/macOS on a Mac. I know workarounds involve using 2 USB, or using bootcamp, but I'd like to give it a try. rEFInd would be able to give me the options I need, with individual /boot files intheir own VG.

Rather than using GUI, I'm using this opportunity to learn about the basics. These are the steps I have taken.

Step 1: I wiped my USB with

sudo dd if=/dev/zero of=/dev/sdb bs=4k && sync

Step 2: Add GPT.

sudo gdisk /dev/sdb

o         # Create new empty GPT

Step 3: Create EFI partition

n         # new partition
1         # 1st partition
<enter>   # suggested/default start sector 
+512M     # Internet wisdom on EFI size
ef00      # EFI system

Step 4: Create LVM partition

n         # new partition
4         # 2nd partition
+128M     # Internet wisdom on good practice
-128M     # Internet wisdom to create buffer space
8e00      # LVM file system

printing the end result:

Disk /dev/sdd: 242614272 sectors, 115.7 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): FE8B1928-7122-4004-9CF6-D5D47C08999E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 242614238
Partitions will be aligned on 2048-sector boundaries
Total free space is 526302 sectors (257.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  EFI System
   2         1312768       242352094   114.9 GiB   8E00  Linux LVM

Here is where I am lost. I don't know how to install Boot loaders into the EFI partition. I have followed Rod Smith's Managing EFI Boot Loaders for Linux: EFI Boot Loader Installation and The rEFInd Boot Manager: Installing rEFInd but I got lost at the /boot/efi part. My Ubuntu Machine does not /boot/efi, but /boot/grub.

Could anyone advise on actual steps to achieve rEFInd on an external USB?

1

An EFI System Partition is simply a FAT32-formatted partition (with the ESP boot flag set on GPT partition tables). Some UEFI systems will happily load bootloaders from a FAT32 partition on a standard MBR partition. It looks to me like you've created it properly, but lacks formatting. Once formatted, you'll "install" rEFInd there by copying the rEFInd files.

  1. Format: mkfs.vfat -F 32 /dev/sdd1
  2. Mount: mkdir /tmp/usbboot && mount /dev/sdd1 /tmp/usbboot
  3. Prepare destination folder: mkdir /tmp/usbboot/EFI
  4. Copy rEFInd's files: cp -a /path/to/refind /tmp/usbboot/EFI/ (or use the refind-install script: refind-install --root /tmp/usbboot)
  5. Edit rEFInd's configuration to taste (/tmp/usbboot/EFI/refind/refind.conf)

The final step to fully install a bootloader on a UEFI system is to register it with your UEFI firmware, using efibootmgr or similar. This is often skipped with bootable USB drives; it will only affect the current system. To boot on other systems you'd use the firmware's boot menu. (If there are no other drives plugged in, and no other bootloaders on the USB's ESP, the firmware should autodetect rEFInd and load it automatically.)

1

On a removable disk, it would be best to copy/rename the bootloader (refind.efi) as /tmp/usbboot/EFI/boot/bootx64.efi (using pathnames as in quixotic's instructions). This is a special filename that UEFI firmware looks for: if it exists, then the disk will be detected as UEFI-bootable.

If you use any other path or filename for your bootloader, then you'll need to use efibootmgr or similar to specify the boot path, as quixotic said. That's fine for permanent installations, but it's less than convenient if your purpose is to have an USB device you can plug into any system to boot your own OS.

However, it looks like you're planning to use Linux LVM on your USB device - that is unlikely to work for you. Neither Windows nor macOS will understand Linux LVM without extra software (or at all), and definitely won't accept that as a location for their system partition.

You don't need Linux LVM here: it would be just a major complication for your plans. Just create a NTFS partition and a APFS partition using the GPT partition table.

  • when using the refind-install script, the option --usedefault /dev/sdd1 will copy rEFInd to the default path shown here (...EFI/boot/bootx64.efi). (the manpage suggests this should be performed on an unmounted partition.) – quixotic Dec 2 '17 at 20:06

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.