Reputation: 479
I created a live Linux system and I want to create an iso file that is able to boot uefi, old BIOS is not needed.
I have one folder with the EFIBOOT files (containing the Refind boot manager and my efi boot kernel (Linux-Sytem.efi))
EFITBOOT
efi
├── boot
│ ├── bootx64.efi
│ └── refind.conf
└── gentoo
└── Linux-Sytem.efi
and one folder that contains the system image:
system/
└── Linux-Sytem.img
My guess is now that I have to create an efi-compatible (fat16/32) efi.img containing the EFIBOOT structure.
Then I somehow have to create the iso putting together the efi.img and the system structure...
I've seen various tutorials using grub to do this but they all use dual boot options (for uefi AND bios)...
How can I do that without grub tools and pure uefi?
(I veryfied that the EFIBOOT and the System structure works if copied it to a proper partitioned/formated usb drive. It boots without problems)
Upvotes: 1
Views: 7147
Reputation: 479
This works for me, but might be wrong:
First, I create a disk.iso
with two partitions on it, an EFI partition and a SYSTEM partition, the whole img will be 1.4GB (100MB for the EFI partition, the rest for the SYSTEM partition):
dd if=/dev/zero of=disk.iso bs=1M count=1400
Then I partition the disk.iso file with fdisk GPT Table:
fdisk disk.iso
# press
g # create GPT-Table
n # new partition
1 # partition number
ENTER # select default
+100M # set size to 100MB
t # set partition type
1 # to EFI SYSTEM
n # new partition
ENTER # default partition number
ENTER # default 1st sector
ENTER # default last sector
w # write changes to file and exit
Then show the partition layout:
fdisk -l disk.iso
Disk disk.iso: 1.4 GiB, 1468006400 bytes, 2867200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: D7DD43FA-30B6-2445-B34C-F4DB7B5D6F37
Device Start End Sectors Size Type
disk.iso1 2048 206847 204800 100M EFI System
disk.iso2 206848 2867166 2660319 1.3G Linux filesystem
Use losetup to loop-mount both partitions from disk.iso to format both partitions to your desired format (fat16 for EFI and ext4 for SYSTEM) and additionally assign labels to them if needed... Use fdisk START END values multiplied with sectorsize to set boundaries:
losetup --offset $((512*2048)) --sizelimit $((512*206847)) --show --find disk.iso
# /dev/loop0
losetup --offset $((512*206848)) --sizelimit $((512*2867166)) --show --find disk.iso
# /dev/loop1
mkfs.fat -F16 /dev/loop0
mkfs.ext4 /dev/loop1
tune2fs -L "SYSTEM" /dev/loop1 # assign label SYSTEM to SYSTEM-Partition
Mount both partitions and copy the corresponding content to them:
mkdir /mnt/p1 /mnt/p2
mount /dev/loop0 /mnt/p1/
mount /dev/loop1 /mnt/p2/
cp -a efi /mnt/p1/
cp -a system/* /mnt/p2/
umount /mnt/p1 /mnt/p2
Unmount both loop devices:
losetup -d /dev/loop0 /dev/loop1
The disk.iso is now ready for booting. Iso tested with qemu-kvm & virt-manager, inserted as CDROM medium. Not Tested with real burned disks!
Upvotes: 4