[Pkg-sysvinit-devel] Re: Drop the mtab magic and just symlink or
bindmount /etc/mtab to /lib/init/rw/mtab ?
Petter Reinholdtsen
pere at hungry.com
Fri Sep 22 16:53:31 UTC 2006
[Petter Reinholdtsen]
> With this in place, it should be safe to let /etc/mtab be a symlink
> to for example /lib/init/rw/mtab, and use mount normally instead of
> with the -n option.
Or just bind-mount it while we boot. Something like this, completely
untested.
- Make sure mount /lib/init/rw and /etc/mtab is mounted using mount -n.
- bind-mount /etc/mtab to /lib/init/rw/mtab, making it writable from
the very beginning. Might need to make /etc/mtab~ writable too?
- umount the bind-mount and copy the content over after the root is
mounted rw. We could drop this and just leave it in /lib/init/rw/.
I'm unsure how this would affect selinux. I am sure it will help us,
as we can drop the mtab.sh script completely, and we can be sure
/etc/mtab include all the content mount wanted to put there.
Index: debian/initscripts/lib/init/mount-functions.sh
===================================================================
--- debian/initscripts/lib/init/mount-functions.sh (revision 948)
+++ debian/initscripts/lib/init/mount-functions.sh (working copy)
@@ -110,7 +110,7 @@
if [ "$VERBOSE" != "no" ]; then
is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files undermount point '$MTPT' will be hidden."
fi
- mount -n -t $FSTYPE $OPTS $5 $DEVNAME $MTPT
+ mount -t $FSTYPE $OPTS $5 $DEVNAME $MTPT
}
#
Index: debian/initscripts/etc/init.d/mountkernfs.sh
===================================================================
--- debian/initscripts/etc/init.d/mountkernfs.sh (revision 954)
+++ debian/initscripts/etc/init.d/mountkernfs.sh (working copy)
@@ -22,10 +22,16 @@
# Get some writable area available before the root is checked
# and remounted.
#
- domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid
+ domount tmpfs "" /lib/init/rw tmpfs "-n -omode=0755,nosuid"
touch /lib/init/rw/.ramfs
#
+ # mtab for use while we boot
+ #
+ touch /lib/init/rw/mtab
+ mount -n --bind /lib/init/rw/mtab /etc/mtab
+
+ #
# Mount proc filesystem on /proc
#
domount proc "" /proc proc -onodev,noexec,nosuid
Index: debian/initscripts/etc/init.d/checkroot.sh
===================================================================
--- debian/initscripts/etc/init.d/checkroot.sh (revision 948)
+++ debian/initscripts/etc/init.d/checkroot.sh (working copy)
@@ -329,6 +329,9 @@
mount -n -o remount,$rootopts,$rootmode /
fi
+ # Remove bind-mount to /lib/init/rw/mtab
+ umount -n /etc/mtab
+
#
# We only create/modify /etc/mtab if the location where it is
# stored is writable. If /etc/mtab is a symlink into /proc/
@@ -342,7 +345,7 @@
/*)
if touch "$MTAB_PATH" >/dev/null 2>&1
then
- :> "$MTAB_PATH"
+ cat /lib/init/rw/mtab > "$MTAB_PATH"
rm -f ${MTAB_PATH}~
INIT_MTAB_FILE=yes
fi
Friendly,
--
Petter Reinholdtsen
More information about the Pkg-sysvinit-devel
mailing list