# need to know where to look for the overlay
if [ -z "$setup" -a -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
mkdir -m 0755 -p /run/initramfs/overlayfs
- mount -n -t auto "$devspec" /run/initramfs/overlayfs || :
+ if ismounted "$devspec"; then
+ devmnt=$(findmnt -e -v -n -o 'TARGET' --source "$devspec")
+ # We need $devspec writable for overlay storage
+ mount -o remount,rw "$devspec"
+ mount --bind "$devmnt" /run/initramfs/overlayfs
+ else
+ mount -n -t auto "$devspec" /run/initramfs/overlayfs || :
+ fi
if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then
OVERLAY_LOOPDEV=$(losetup -f --show ${readonly_overlay:+-r} /run/initramfs/overlayfs$pathspec)
over=$OVERLAY_LOOPDEV