[UC] not able to copy files to vfat partition if partition size is less than 33M

Bug #2028912 reported by Aristo Chen
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OEM Priority Project
Fix Committed
High
Aristo Chen
snapd
New
Undecided
Unassigned

Bug Description

[Summary]
when using ubuntu-image to build ubuntu core image, there will be an issue copying file to vfat partition if the partition size is less than 33M

[Error message]
env UBUNTU_STORE_AUTH_DATA_FILENAME=/home/vagrant/aristo/image-builds/store.auth ubuntu-image snap --debug -O out -w work --channel stable --snap=./mediatek-aiot-kernel_28.snap --snap=./snapd_19459.snap --snap=./mediatek-aiot_22-0.3.2_arm64.snap --snap=./core22_821.snap --disk-info buildstamp model.assert
[0] make_temporary_directories
[1] determine_output_directory
[2] prepare_image
WARNING: proceeding to download snaps ignoring validations, this default will change in the future. For now use --validation=enforce for validations to be taken into account, pass instead --validation=ignore to preserve current behavior going forward
WARNING: the kernel for the specified UC20+ model does not carry assertion max formats information, assuming possibly incorrectly the kernel revision can use the same formats as snapd
WARNING: "mediatek-aiot" installed from local snaps disconnected from a store cannot be refreshed subsequently!
Copying "./snapd_19459.snap" (snapd)
Copying "./mediatek-aiot-kernel_28.snap" (mediatek-aiot-kernel)
Copying "./core22_821.snap" (core22)
Copying "./mediatek-aiot_22-0.3.2_arm64.snap" (mediatek-aiot)
[3] load_gadget_yaml
[4] set_artifact_names
[5] populate_rootfs_contents
[6] generate_disk_info
[7] calculate_rootfs_size
[8] populate_bootfs_contents
[9] populate_prepare_partitions
Error: Error running mkfs with content: cannot populate vfat filesystem with contents: No directory slots

[sample gadget.yaml that have issue]
volumes:
  pc:
    schema: gpt
    bootloader: grub
    structure:
      - name: firmware
        filesystem: vfat
        type: 384E979B-EB76-435A-A3A6-1A071DBAD91D
        size: 32M
        content:
          - source: shimaa64.efi.signed
            target: EFI/BOOT/BOOTAA64.efi
      - name: ubuntu-seed
        role: system-seed
        filesystem: vfat
        type: EF,C12A7328-F81F-11D2-BA4B-00A0C93EC93B
        size: 1200M
        content:
          - source: $kernel:dtbs/dtbs/mediatek/
            target: FIRMWARE/mediatek/genio-350-evk/
      - name: ubuntu-boot
        role: system-boot
        filesystem: ext4
        type: 83,0FC63DAF-8483-4772-8E79-3D69D8477DE4
        size: 750M
      - name: ubuntu-save
        role: system-save
        filesystem: ext4
        type: 83,0FC63DAF-8483-4772-8E79-3D69D8477DE4
        size: 32M
      - name: ubuntu-data
        role: system-data
        filesystem: ext4
        type: 83,0FC63DAF-8483-4772-8E79-3D69D8477DE4
        size: 1G

[Other info]
- If the firmware partition filesystem type is changed to ext4, then there is no issue
- If the size of the firmware partition is greater than or equal to 33M, then there is no issue

[Other info - snap list]
$ snap list
Name Version Rev Tracking Publisher Notes
core18 20230530 2785 latest/stable canonical✓ base
core20 20230622 1974 latest/stable canonical✓ base
core22 20230703 817 latest/stable canonical✓ base
lxd 5.0.2-838e1b2 24322 5.0/stable/… canonical✓ -
snapcraft 7.5.0 9510 7.x/stable canonical✓ classic
snapd 2.59.5 19457 latest/stable canonical✓ snapd
ubuntu-image 3.0+snap4 500 latest/stable canonical✓ classic
yq v4.34.2 2219 latest/stable mikefarah -

Aristo Chen (aristochen)
Changed in oem-priority:
assignee: nobody → Aristo Chen (aristochen)
importance: Undecided → High
status: New → Confirmed
tags: added: oem-pr
tags: added: oem-priority
removed: oem-pr
tags: added: originate-from-2028911
Revision history for this message
Michael Vogt (mvo) wrote :

This might be related to https://bugs.archlinux.org/task/71547 - we have version 4.0.32 in 22.04 so the fixses from the attached patch may help but it will be a bit tricky to test it.

Revision history for this message
Aristo Chen (aristochen) wrote :

Hi Michael,

thanks for providing the info!

I have tried the following steps to verify, hopefully I am doing it correctly

1. Prepare a clean Jammy varant environment
2. If I understand correctly, ubuntu-image snap contains mtools in it, and by default the mtools in ubuntu-snap will be called first, so If I want to use the mtools from debian package, I need to remove the mtools staged in ubuntu-image snap, so I cloned the latest ubuntu-image code from github(https://github.com/canonical/ubuntu-image, commit ID:28b7b85) and rebuild a ubuntu-image snap without stage the mtools debian package
3. Install the ubuntu-image snap built in previous step
4. Use `apt source mtools` command
5. Apply the patch that you have provided in comment #1
6. Rebuild the debian package
7. Install the patched mtools debian package
8. Try to build the image by using ubuntu-image again

Unfortunately, I still get the same error message

Revision history for this message
Aristo Chen (aristochen) wrote :

Looks like the issue can be fixed with version 4.0.41

1. Execute "wget http://ftp.gnu.org/gnu/mtools/mtools_4.0.41_amd64.deb"
2. Install mtools_4.0.41_amd64.deb
3. Try to build the image by using ubuntu-image again

I will try to find out the code changes required to fix this issue

Revision history for this message
Aristo Chen (aristochen) wrote :

I somehow managed to fix the issue, and the attached patch can fix the issue. However, there seems to be no git tree exist for mtools, so SRU could be tricky

I wrote an email to Chris Lamb, who is the maintainer of the mtools debian package, and unfortunately he said that he will orphan the package(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1042948). The maintainer also mentioned that he updated the mtools code on gitlab(https://salsa.debian.org/lamby/pkg-mtools) to the latest version(4.0.43) from upstream, not sure if it means that there will be a 4.0.43 debian package released recently

Revision history for this message
ethan.hsieh (ethan.hsieh) wrote (last edit ):

Tried the latest ubuntu-image 3.x. The issue is gone after replacing vfat in gadget.yaml with vfat-16.

---
Alfonso: This change[1] will require a recompilation[2] of ubuntu-image and also new snap-bootstrap in pc-kernel for all pieces to work.
---
[1] https://github.com/snapcore/snapd/pull/13123
[2] https://github.com/canonical/ubuntu-image/pull/176/

Changed in oem-priority:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.