Browse Source

fix(squash): don't mount the mount points if already mounted

It is possible that user setup some early mount in the rootfs even
earlier, so just be more robust and cover that case too.

Signed-off-by: Kairui Song <kasong@redhat.com>
master
Kairui Song 4 years ago committed by Jóhann B. Guðmundsson
parent
commit
636d6df313
  1. 17
      modules.d/99squash/init-squash.sh
  2. 4
      modules.d/99squash/module-setup.sh

17
modules.d/99squash/init-squash.sh

@ -1,12 +1,17 @@
#!/bin/sh #!/bin/sh
PATH=/bin:/sbin PATH=/bin:/sbin


# Basic mounts for mounting a squash image [ -e /proc/self/mounts ] \
mkdir /proc /sys /dev /run || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
mount -t proc -o nosuid,noexec,nodev proc /proc
mount -t sysfs -o nosuid,noexec,nodev sysfs /sys grep -q '^sysfs /sys sysfs' /proc/self/mounts \
mount -t devtmpfs -o mode=755,noexec,nosuid,strictatime devtmpfs /dev || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
mount -t tmpfs -o mode=755,nodev,nosuid,strictatime tmpfs /run
grep -q '^devtmpfs /dev devtmpfs' /proc/self/mounts \
|| (mkdir -p /dev && mount -t devtmpfs -o mode=755,noexec,nosuid,strictatime devtmpfs /dev)

grep -q '^tmpfs /run tmpfs' /proc/self/mounts \
|| (mkdir -p /run && mount -t tmpfs -o mode=755,noexec,nosuid,strictatime tmpfs /run)


# Load required modules # Load required modules
modprobe loop modprobe loop

4
modules.d/99squash/module-setup.sh

@ -42,11 +42,11 @@ installpost() {
# Install required modules and binaries for the squash image init script. # Install required modules and binaries for the squash image init script.
if [[ $_busybox ]]; then if [[ $_busybox ]]; then
inst "$_busybox" /usr/bin/busybox inst "$_busybox" /usr/bin/busybox
for _i in sh echo mount modprobe mkdir switch_root; do for _i in sh echo mount modprobe mkdir switch_root grep; do
ln_r /usr/bin/busybox /usr/bin/$_i ln_r /usr/bin/busybox /usr/bin/$_i
done done
else else
DRACUT_RESOLVE_DEPS=1 inst_multiple sh mount modprobe mkdir switch_root DRACUT_RESOLVE_DEPS=1 inst_multiple sh mount modprobe mkdir switch_root grep
fi fi


hostonly="" instmods "loop" "squashfs" "overlay" hostonly="" instmods "loop" "squashfs" "overlay"

Loading…
Cancel
Save