Initramfs-init does not respect apkovl device fstab entry
When booting with an attached device containing an apkovl file, the overlay will be detected and applied, but the disk storing the apkovl will not be remounted to comply with the newly unpacked fstab.
This is problematic on systems that may have disks added or removed, as nlplug-findfs mounts drives by SCSI disk device name, which can change upon reboot. If the apkovl device is also used as an apk cache, this mount point change will cause the cache to not be found.
Functionality is already implemented in the initramfs-init script to remount drives, but is only applied to boot media found by nlplug-findfs, not apk overlay devices.
Steps to verify:
- Configure an apkovl device with a fstab configuring that disk's mount point
- Boot a diskless installation using the apkovl device
- Verify that apkovl disk is incorrectly mounted at
/media/sdX
by nlplug-findfs, not its fstab configuration
Workaround:
Create an empty .boot_repository
file on the apkovl device to detect the device as a boot drive and thus automatically remount in accordance with the fstab.
Proposal:
Modify the relocate_mount()
function (reproduced below) to iterate over boot devices (found through the $repofile
variable) and apk overlay devices (found through the $ovl
variable).
# relocate mountpoint according given fstab
relocate_mount() {
local fstab="${1}"
local dir=
if ! [ -e $repofile ]; then
return
fi
while read dir; do
# skip http(s)/ftp repos for netboot
if ! [ -d "$dir" ]; then
continue
fi
local dev=$(df -P "$dir" | tail -1 | awk '{print $1}')
local mnt=$(find_mnt $dev $fstab)
if [ -n "$mnt" ]; then
local oldmnt=$(awk -v d=$dev '$1==d {print $2}' /proc/mounts)
if [ "$oldmnt" != "$mnt" ]; then
mkdir -p "$mnt"
mount -o move "$oldmnt" "$mnt"
fi
fi
done < $repofile
}