Skip to content

TOOL-27513 Add FAT and VFAT support for building EFI boot images #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

tonynguien
Copy link

@tonynguien tonynguien commented Mar 5, 2025

Problem

Our os-upgrade buildserver is missing fat/vfat modules which we need to build EFI boot images.

Below is the error from appliance-build-stage1 job

10:41:22  + EFI_DIR=/boot/efi
10:41:22  + chroot /mnt/delphix.RfdjBXD mkdir -p /boot/efi
10:41:22  + chroot /mnt/delphix.RfdjBXD mkfs.vfat -F32 /dev/mapper/loop0p3
10:41:23  mkfs.fat 4.2 (2021-01-31)
10:41:23  + chroot /mnt/delphix.RfdjBXD mount /dev/mapper/loop0p3 /boot/efi
10:41:23  mount: /boot/efi: unknown filesystem type 'vfat'.
10:41:23         dmesg(1) may have more information after failed mount system call.
10:41:23  E: config/hooks/90-raw-disk-image.binary failed (exit non-zero). You should check for errors.
10:41:23  P: Begin unmounting filesystems...
10:41:23  P: Saving caches...
10:41:24  Reading package lists...
10:41:24  Building dependency tree...
10:41:24  Reading state information...
10:41:24  + kill -9 17789
10:41:24  + [[ ! -f binary/SHA256SUMS ]]
10:41:24  + exit 1
10:41:25  
10:41:25  > Task :live-build:buildInternalQaEsxVmArtifacts FAILED
10:41:26  
10:41:26  FAILURE: Build failed with an exception.
10:41:26  
10:41:26  * What went wrong:
10:41:26  Execution failed for task ':live-build:buildInternalQaEsxVmArtifacts'.
10:41:26  > Process 'command '/export/home/delphix/jenkins/workspace/appliance-build-stage1/pre-push/appliance-build/scripts/run-live-build.sh'' finished with non-zero exit value 1

https://selfservice-jenkins.eng-tools-prd.aws.delphixcloud.com/job/appliance-build-stage1/job/pre-push/49608/consoleFull

The VM kernel does not have fat/vfat modules thus

delphix@ip-10-110-229-113:~$ modprobe vfat
modprobe: FATAL: Module vfat not found in directory /lib/modules/6.8.0-1017-dx2025012303-9c92c5173-aws
delphix@ip-10-110-229-113:~$ modinfo vfat
modinfo: ERROR: Module vfat not found.

Solution

Include FAT and VFAT filesystem in the Delphix kernel build.

Testing Done

Confirmed VFAT/FAT are included and that creation/mounting vfat filesystem succeed.

delphix@ip-10-110-214-171:~$ ARTIFACT_NAME=dummy
delphix@ip-10-110-214-171:~$ truncate -s 10G $ARTIFACT_NAME.img

delphix@ip-10-110-214-171:~$ sgdisk --zap-all "$ARTIFACT_NAME.img"
Creating new GPT entries in memory.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
delphix@ip-10-110-214-171:~$ sgdisk "$ARTIFACT_NAME.img"        --set-alignment=1 --new=2:1m:+1m --typecode=2:EF02
Creating new GPT entries in memory.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
delphix@ip-10-110-214-171:~$ sgdisk "$ARTIFACT_NAME.img"        --new=3::+200m --typecode=3:EF00 -c:3:"EFI Boot"
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
delphix@ip-10-110-214-171:~$ sgdisk "$ARTIFACT_NAME.img" --new=1:: --typecode=1:8300
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
delphix@ip-10-110-214-171:~$ sgdisk $ARTIFACT_NAME.img --print
Disk dummy.img: 20971520 sectors, 10.0 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 30D3E06E-D2F0-4578-A968-BFD1B3941CB7
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 20971486
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1          413696        20971486   9.8 GiB     8300
   2            2048            4095   1024.0 KiB  EF02
   3            4096          413695   200.0 MiB   EF00  EFI Boot
   

delphix@ip-10-110-214-171:~$ sudo kpartx -asv $ARTIFACT_NAME.img
add map loop0p1 (252:0): 0 20557791 linear 7:0 413696
add map loop0p2 (252:1): 0 2048 linear 7:0 2048
add map loop0p3 (252:2): 0 409600 linear 7:0 4096  

delphix@ip-10-110-214-171:~$ sudo fdisk -l /dev/loop0
Disk /dev/loop0: 10 GiB, 10737418240 bytes, 20971520 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: 30D3E06E-D2F0-4578-A968-BFD1B3941CB7

Device        Start      End  Sectors  Size Type
/dev/loop0p1 413696 20971486 20557791  9.8G Linux filesystem
/dev/loop0p2   2048     4095     2048    1M BIOS boot
/dev/loop0p3   4096   413695   409600  200M EFI System

delphix@ip-10-110-214-171:~$ sudo mkfs.vfat -F32 /dev/mapper/loop0p3
mkfs.fat 4.2 (2021-01-31)
delphix@ip-10-110-214-171:~$ sudo mount /dev/mapper/loop0p3 /mnt
mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.

delphix@ip-10-110-214-171:~$ mount | grep vfat
/dev/mapper/loop0p3 on /mnt type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
delphix@ip-10-110-214-171:~$

@tonynguien tonynguien force-pushed the dlpx/pr/tonynguien/c5f27efd-4454-4918-b347-7862884ad0f3 branch from a760726 to 9574301 Compare March 5, 2025 18:20
@tonynguien tonynguien force-pushed the dlpx/pr/tonynguien/c5f27efd-4454-4918-b347-7862884ad0f3 branch from 9574301 to 2774597 Compare March 5, 2025 19:26
@tonynguien tonynguien changed the title Add FAT and VFAT support for building EFI boot images TOOL-27513 Add FAT and VFAT support for building EFI boot images Mar 5, 2025
@tonynguien tonynguien marked this pull request as ready for review March 5, 2025 19:31
@tonynguien tonynguien requested a review from palash-gandhi March 5, 2025 19:31
Copy link
Contributor

@palash-gandhi palash-gandhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, testing this may be a long process. You could start an ab-pre-push from any one kernel fork, abort that job, rebuild it and pass this PR branch in LINUX_PKG_GIT_BRANCH and ensure you build a buildserver variant, finally verify these modules are present.

@tonynguien
Copy link
Author

Lgtm, testing this may be a long process. You could start an ab-pre-push from any one kernel fork, abort that job, rebuild it and pass this PR branch in LINUX_PKG_GIT_BRANCH and ensure you build a buildserver variant, finally verify these modules are present.

Thanks for the pointer. I've verified the new image has vfat/fat and that we can successfully mount vfat filesystem.

@tonynguien tonynguien merged commit 5a72143 into os-upgrade Mar 6, 2025
17 checks passed
@tonynguien tonynguien deleted the dlpx/pr/tonynguien/c5f27efd-4454-4918-b347-7862884ad0f3 branch March 6, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants