diff --git a/dracut/full-modules/mount_modules.sh b/dracut/full-modules/mount_modules.sh index 129de59..afa617e 100644 --- a/dracut/full-modules/mount_modules.sh +++ b/dracut/full-modules/mount_modules.sh @@ -4,11 +4,22 @@ # -if ! [ -d $NEWROOT/lib/modules/`uname -r` ]; then +kver="`uname -r`" +if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then echo "Waiting for /dev/xvdd device..." while ! [ -e /dev/xvdd ]; do sleep 0.1; done - mount -n -t ext3 /dev/xvdd $NEWROOT/lib/modules + # Mount only `uname -r` subdirectory, to leave the rest of /lib/modules writable + mkdir -p /tmp/modules + mount -n -t ext3 /dev/xvdd /tmp/modules + if ! [ -d "$NEWROOT/lib/modules/$kver" ]; then + mount "$NEWROOT" -o remount,rw + mkdir -p "$NEWROOT/lib/modules/$kver" + mount "$NEWROOT" -o remount,ro + fi + mount --bind "/tmp/modules/$kver" "$NEWROOT/lib/modules/$kver" + umount /tmp/modules + rmdir /tmp/modules fi killall udevd systemd-udevd diff --git a/dracut/simple/init.sh b/dracut/simple/init.sh index 773e518..adc525c 100644 --- a/dracut/simple/init.sh +++ b/dracut/simple/init.sh @@ -54,11 +54,22 @@ mkdir -p /sysroot mount /dev/mapper/dmroot /sysroot -o ro NEWROOT=/sysroot -if ! [ -d $NEWROOT/lib/modules/`uname -r` ]; then +kver="`uname -r`" +if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then echo "Waiting for /dev/xvdd device..." while ! [ -e /dev/xvdd ]; do sleep 0.1; done - mount -n -t ext3 /dev/xvdd $NEWROOT/lib/modules + # Mount only `uname -r` subdirectory, to leave the rest of /lib/modules writable + mkdir -p /tmp/modules + mount -n -t ext3 /dev/xvdd /tmp/modules + if ! [ -d "$NEWROOT/lib/modules/$kver" ]; then + mount "$NEWROOT" -o remount,rw + mkdir -p "$NEWROOT/lib/modules/$kver" + mount "$NEWROOT" -o remount,ro + fi + mount --bind "/tmp/modules/$kver" "$NEWROOT/lib/modules/$kver" + umount /tmp/modules + rmdir /tmp/modules fi