/usr/share/initramfs-tools/scripts/local-bottom/bootcdoverlayfs is in bootcd 5.12.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/bin/sh
# if necessary mount iso image loopback
# use overlayfs (either aufs or overlay) to make iso image "writable"
# See manpage initramfs-tools(8)
[ -f /scripts/functions ] && . /scripts/functions
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
# chkerr <EXIT CODE> <action performed>
chkerr()
{
e=$1
shift
if [ $e -ne 0 ]; then
echo "bootcdoverlayfs: ERROR $e while running: $*"
echo "try to fix and exit"
/bin/sh
fi
}
getiso()
{
sed -n "s/^.*\<root=iso:\([^ :]*\):\([^ ]*\)\>.*$/\2/p"
}
modprobe aufs || true
modprobe overlay || true
if [ "$(grep "\<bootcd=" /proc/cmdline)" ]; then
echo "bootcdoverlayfs rootmnt=<$rootmnt>"
iso="$(cat /proc/cmdline | getiso)"
if [ "$iso" ]; then
mkdir /bootcd.disk_with_iso
mount -o move ${rootmnt} /bootcd.disk_with_iso
chkerr $? "mount -o move ${rootmnt} /bootcd.disk_with_iso"
modprobe loop
mount -o loop -t iso9660 /bootcd.disk_with_iso/${iso} ${rootmnt}
chkerr $? "mount -o loop -t iso9660 /bootcd.disk_with_iso/${iso} ${rootmnt}"
fi
mkdir /bootcd.upper
mount -t tmpfs tmpfs /bootcd.upper
chkerr $? "mount -t tmpfs tmpfs /bootcd.upper"
mkdir /bootcd.lower
mount -o move ${rootmnt} /bootcd.lower
chkerr $? "mount -o move ${rootmnt} /bootcd.lower"
mkdir /overlayfs
if [ "$(cat /proc/filesystems | grep "\<aufs\>")" ]; then
mount -t aufs -o dirs=/bootcd.upper:/bootcd.lower=ro aufs /overlayfs
chkerr $? "mount -t aufs -o dirs=/bootcd.upper:/bootcd.lower=ro aufs /overlayfs"
elif [ "$(cat /proc/filesystems | grep "\<overlay\>")" ]; then
mkdir /bootcd.upper/upper
mkdir /bootcd.upper/work
mount -t overlay -o lowerdir=/bootcd.lower,upperdir=/bootcd.upper/upper,workdir=/bootcd.upper/work overlay /overlayfs
chkerr $? "mount -t overlay -o lowerdir=/bootcd.lower,upperdir=/bootcd.upper/upper,workdir=/bootcd.upper/work overlay /overlayfs"
else
chkerr 1 "no aufs and no overlay in /proc/filesystems"
fi
mkdir -p /overlayfs/mnt/bootcd.lower
mount -o move /bootcd.lower /overlayfs/mnt/bootcd.lower
chkerr $? "mount -o move /bootcd /overlayfs/mnt/bootcd.lower"
if [ "$iso" ]; then
mkdir -p /overlayfs/mnt/bootcd.disk_with_iso
mount -o move /bootcd.disk_with_iso /overlayfs/mnt/bootcd.disk_with_iso
chkerr $? "mount -o move /bootcd.disk_with_iso /overlayfs/mnt/bootcd.disk_with_iso"
fi
mkdir -p /overlayfs/mnt/bootcd.upper
mount -o move /bootcd.upper /overlayfs/mnt/bootcd.upper
chkerr $? "mount -o move /bootcd.upper /overlayfs/mnt/bootcd.upper"
mount -o move /overlayfs ${rootmnt}
chkerr $? "mount -o move /overlayfs ${rootmnt}"
fi
exit 0
|