Auto-mount won’t occur until the base system is running. Entries in “/etc/fstab” can be made to load at a standard point in the boot process.
Consider that when a partition is set to mount in the usual fashion (such as rootfs) this is typically marked as “mandatory”, and if it isn’t there, boot will halt forever. The simplest approach is to just mount like a hard disk, but it will interfere with boot if you don’t have the SD card there with the partition you named also existing in the SD card.
The basic “just always mount” goes something like this…I will assume “/dev/mmcblk1p1” is your SD card partition. This edit to “/etc/fstab” would be the basic “always there” edit for a mount point of “/usr/local”:
/dev/mmcblk1p1 /usr/local ext4 defaults 1 2
To set this up as “not automatic” (or perhaps emphasizing “not required for normal boot”):
/dev/mmcblk1p1 /usr/local ext4 noauto,user 1 2
The trailing “1 2” says file system checking is done, and this is the second device to check. The eMMC is rootfs, so this is actuall “1 1” even if the entry is automatic and not in fstab.
You may be interested in the “nofail” option (see “man fstab”) to allow boot if the SD card is not in place. One variation which tries to auto-mount but which won’t halt boot if missing:
/dev/mmcblk1p1 /usr/local ext4 nofail,user 1 2
The “user” entry allows any user to mount. Remove this for something everyone shouldn’t have access to (it locks to whoever mounted it until it umounts).
This identifies a partition by device, but you can also use the UUID if one is set…this is “unique” and will only mount that exact partition. For example, run this to see:
If you use a UUID then other SD cards won’t accidentally be mounted in this SD card’s place. The UUID is randomly generated during mkfs.ext4, but the e2label program can be used to manually set this. You could create a number of SD cards and label any partition with that label, and then regardless of which SD card and regardless of which partition that label occurs on fstab would do the right thing.