diff --git a/initramfs-init.in b/initramfs-init.in index f64ef26..8f01c8f 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -244,8 +244,8 @@ resolve_dev() { esac } -# remount ALPINE_MNT according given fstab -remount_alpine_mnt() { +# relocate ALPINE_MNT according given fstab +relocate_alpine_mnt() { local fstab="$1" local mnt=$(find_mnt $ALPINE_DEV $fstab) if [ "$ALPINE_MNT" != "$mnt" ]; then @@ -253,10 +253,6 @@ remount_alpine_mnt() { mount -o move $ALPINE_MNT $mnt ALPINE_MNT=$mnt fi - # respect users mount options in fstab - if [ -n "$MNTOPTS" ]; then - mount -o remount,$MNTOPTS "$ALPINE_MNT" - fi } # gotta start from somewhere :) @@ -458,7 +454,6 @@ if [ -f "$ovl" ]; then eend $? $errstr || ovlfiles= # hack, incase /root/.ssh was included in apkovl [ -d "$sysroot/root" ] && chmod 700 "$sysroot/root" - umount $ovl_unmount 2>/dev/null & pkgs="$pkgs $(sed 's/\#.*//' $sysroot/etc/lbu/packages.list 2>/dev/null)" rm -f "$sysroot"/etc/lbu/packages.list pkgs="$pkgs $(cat $sysroot/var/lib/apk/world $sysroot/etc/apk/world 2>/dev/null)" @@ -480,12 +475,19 @@ else rc_add savecache shutdown fi -# let user override tmpfs size in fstab in apkovl if [ -f $sysroot/etc/fstab ]; then + has_fstab=1 + + # let user override tmpfs size in fstab in apkovl mountopts=$(awk '$2 == "/" && $3 == "tmpfs" { print $4 }' $sysroot/etc/fstab) if [ -n "$mountopts" ]; then mount -o remount,$mountopts $sysroot fi + + # move the ALPINE_MNT if ALPINE_DEV is specified in users fstab + # this is so a generated /etc/apk/repositories will use correct + # mount dir + relocate_alpine_mnt "$sysroot"/etc/fstab fi # in case we upgrade we might need those: @@ -496,13 +498,6 @@ rc_add modloop sysinit # hack so we get openrc pkgs="$pkgs alpine-base" -# move the ALPINE_MNT if ALPINE_DEV is specified in users fstab -# this is so a generated /etc/apk/repositories will use correct mount dir -if [ -f "$sysroot"/etc/fstab ]; then - has_fstab=1 - remount_alpine_mnt "$sysroot"/etc/fstab -fi - # copy keys so apk finds them. apk looks for stuff relative --root mkdir -p $sysroot/etc/apk/keys/ cp -a /etc/apk/keys $sysroot/etc/apk @@ -537,11 +532,23 @@ else fi eend $? +# unmount ovl mount if needed +if [ -n "$ovl_unmount" ]; then + umount $ovl_unmount 2>/dev/null +fi + # remount ALPINE_MNT according default fstab from package if [ -z "$has_fstab" ] && [ -f "$sysroot"/etc/fstab ]; then - remount_alpine_mnt "$sysroot"/etc/fstab + relocate_alpine_mnt "$sysroot"/etc/fstab fi +# respect mount options in fstab for ALPINE_MNT (e.g if user wants rw) +opts=$(awk "\$2 == \"$ALPINE_MNT\" {print \$4}" $sysroot/etc/fstab) +if [ -n "$opts" ]; then + mount -o remount,$opts "$ALPINE_MNT" +fi + + # fix inittab if alternative console setup_inittab_console $CONSOLE