Before asking here, I tried to search on SU/SE and Google without success. This is the closest thing I got.
Basically, I'm trying to do the following:
- create a disk image of about 128MB;
- create a GPT;
- create a FAT32 partition in the first 32MB(I'll call it UEFI);
- create a FAT32 partition in the remaining bytes(I'll call it SYSTEM);
- create the following subdirectory in the UEFI partition: /EFI/BOOT/;
- copy a file in the subdirectory;
- copy another file in the SYSTEM partition.
This what I've done until now:
dd if=/dev/zero of=disk.img bs=1M count=128
(parted) mktable gpt
(parted) mkpart primary fat32 2048s 65535s
(parted) mkpart primary fat32 65536s 100%
(parted) align-check optimal 1
(parted) align-check optimal 2
(parted) name 1 UEFI
(parted) name 2 SYSTEM
This is my output:
Disk disk.img: 134MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 33,6MB 32,5MB UEFI msftdata 2 33,6MB 134MB 101MB SYSTEM msftdata
The alternate way is to create two different partitions and later merge them:
dd if=/dev/zero of=uefi.img bs=1M count=32 mformat -i uefi.img -v UEFI -f 1440 -c 1 :: mmd -i uefi.img ::/EFI mmd -i uefi.img ::/EFI/BOOT mcopy -i uefi.img BOOTX64.EFI ::/EFI/BOOT
dd if=/dev/zero of=system.img bs=1M count=100 mformat -i system.img -v UEFI -f 1440 -c 1 :: mcopy -i system.img myawesomeOS ::
In the former way I cannot figure out why the "File system" column is empty(it should say fat32) and how to create subdirectories and copy files.
In the latter way I am not able to create a proper FAT32 filesystem for the two images, if I append -F to mformat I get
Too few clusters for this fat size. Please choose a 16-bit fat in your /etc/mtools.conf or .mtoolsrc file
If I'd manage to do it, I still don't know how to set up the GPT and merge the two images in a single file.
How can I achieve this? Any help or hint is appreciated.