I would like to mount the boot partition of the ubuntu-21.10-preinstalled-server-arm64+raspi.img.xz
downloaded off the Raspberry PI web site.
Unpacking the image file and mounting the boot partition with a command like
mount -o loop,offset=1048576,sizelimit=268435456 ubuntu-21.10-preinstalled-server-arm64+raspi.img /var/nfs/ubuntu-21.10-boot
... works just fine. You can see the mounted image together with the /dev/mmcblk0p1
device:
mount | grep boot
/dev/mmcblk0p1 on /boot/firmware type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/var/nfs/ubuntu-21.10-preinstalled-server-arm64+raspi.img on /var/nfs/ubuntu-21.10-boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
However, when I add the same mount to /etc/fstab
to the already existing mount for /boot/firmware
:
LABEL=system-boot /boot/firmware vfat defaults 0 1
/var/nfs/ubuntu-21.10-preinstalled-server-arm64+raspi.img /var/nfs/ubuntu-21.10-boot ext4 loop,offset=1048576,sizelimit=268435456 0 0
... and reboot the system (or run mount -a
) the boot partition of the image is mounted both at /var/nfs/ubuntu-21.10-boot
as expected but also at /boot/firmware
and thus replacing the real firmware at /dev/mmcblk0p1
:
mount | grep boot
/var/nfs/ubuntu-21.10-preinstalled-server-arm64+raspi.img on /var/nfs/ubuntu-21.10-boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/var/nfs/ubuntu-21.10-preinstalled-server-arm64+raspi.img on /boot/firmware type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
This is evidently because the boot partition of the image is labeled system-boot
which collides with the /dev/mmcblk0p1
labeled the same way.
(The mount manual page specifies that fstab
is ignored when both device and mount points are specified which explains why mounting manually works as expected.)
I can think of the following workarounds to avoid the firmware mount to be overwritten:
- Avoid using fstab and mount manually in an rc script
- Relabel the boot partition of the image file
- Replace
LABEL=system-boot
with the actual device that holds the firmware (as suggested in @Tilman's answer below)
... but
Is there a way to prevent an fstab entry to automatically mount by label?