dd if=/dev/zero of=image.img iflag=fullblock bs=1M count=100 && sync(losetup will list all used loopback devices) (losetup loop4 will mount it on the next available loopback devices, eg n+1)
# NOTE: For experienced users, you can use "losetup -f image.img" to automatically use the next available loop device
losetup
losetup loop4 image.img
losetupgdisk /dev/loop4
o
y
n
<enter until hex code>
0xEF00
w
y
partprobe /dev/loop4
ls /dev/loop4*mkfs.fat -F32 /dev/loop4p1mkdir /mnt/image
mount /dev/loop4p1 /mnt/imageumount /mnt/imagelosetup -d /dev/loop4
losetupThis section assumes that you no longer have the image mounted in any way.
# Mount the image as a loopback device first
# -f searches for the next free loop device (no need to manually select one)
# -P triggers a scan for any available partitions in the image
losetup -f -P image.img
# Get the loopback device for the mounted image
LOOP_DEV_PATH=`losetup -a | grep image.img | awk -F: '{print $1;}'`p1
# Mount the EFI partition to a local path (create path first if necessary)
mkdir -p /mnt/image
mount $LOOP_DEV_PATH /mnt/image
ls -lah /mnt/image# Unmount the EFI partition
umount /mnt/opencore
# Remove the mount point
# DISCLAIMER: Be careful with this, as you could potentially lose data if unmounting was unsuccessful etc.
rm -rf /mnt/opencore
# Get the loopback device path
LOOP_DEV_PATH=`losetup -a | grep opencore.img | awk -F: '{print $1;}'`
# Remove the loopback device
losetup -d $LOOP_DEV_PATH