initramfs: use overlayfs for /lib/modules, if available
If overlay fs is available, use it for /lib/modules. This way the whole /lib/modules will be writable and changes (like extra modules) will persist in TemplateVM/StandaloneVM. In practice, this will allow to conveniently build in-vm kernel modules, even for dom0-provided kernels. QubesOS/qubes-issues#2908
This commit is contained in:
parent
90641b0dce
commit
9c6c825691
@ -94,15 +94,26 @@ if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then
|
||||
echo "Waiting for /dev/xvdd device..."
|
||||
while ! [ -e /dev/xvdd ]; do sleep 0.1; done
|
||||
|
||||
# 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
|
||||
if /sbin/modprobe overlay; then
|
||||
# if overlayfs is supported, use that to provide fully writable /lib/modules
|
||||
if ! [ -d "$NEWROOT/lib/.modules_work" ]; then
|
||||
mount "$NEWROOT" -o remount,rw
|
||||
mkdir -p "$NEWROOT/lib/.modules_work"
|
||||
mount "$NEWROOT" -o remount,ro
|
||||
fi
|
||||
mount -t overlay none $NEWROOT/lib/modules -o lowerdir=/tmp/modules,upperdir=$NEWROOT/lib/modules,workdir=$NEWROOT/lib/.modules_work
|
||||
else
|
||||
# otherwise mount only `uname -r` subdirectory, to leave the rest of
|
||||
# /lib/modules writable
|
||||
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"
|
||||
fi
|
||||
mount --bind "/tmp/modules/$kver" "$NEWROOT/lib/modules/$kver"
|
||||
umount /tmp/modules
|
||||
rmdir /tmp/modules
|
||||
fi
|
||||
|
@ -9,6 +9,10 @@ depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
hostonly='' instmods overlay
|
||||
}
|
||||
|
||||
install() {
|
||||
inst $moddir/init.sh /init
|
||||
inst_multiple \
|
||||
|
Loading…
Reference in New Issue
Block a user