[Lunar-commits] <moonbase> lunar-init: LVM support in mount script and changes to fsck and mounting

Stefan Wold ratler at lunar-linux.org
Thu Oct 23 06:49:48 CEST 2008


commit ea1d69302d088168a247eff1560372c07880489b
Author: Stefan Wold <ratler at lunar-linux.org>
Date:   Sun Sep 7 17:53:45 2008 +0200

    lunar-init: LVM support in mount script and changes to fsck and mounting
    
    * Added LVM support
    * Rewrote fsck part of mount script, no more parsing /etc/fstab
      instead let fsck determine the fsck order on it's own
    * No longer parse fstab, we let mount -a handle that
---
 utils/lunar-init/DETAILS |    6 +-
 utils/lunar-init/mount   |  118 +++++++++++++++++++++-------------------------
 2 files changed, 57 insertions(+), 67 deletions(-)

diff --git a/utils/lunar-init/DETAILS b/utils/lunar-init/DETAILS
index 0bc9851..e7e67d2 100644
--- a/utils/lunar-init/DETAILS
+++ b/utils/lunar-init/DETAILS
@@ -1,10 +1,10 @@
           MODULE=lunar-init
-         VERSION=0.1.1
+         VERSION=0.1.2
         WEB_SITE=http://lunar-linux.org
          ENTERED=20070404
-         UPDATED=20080718
+         UPDATED=20081023
            SHORT="the Lunar init scripts vital to any system"
-         PROFILE=yes
+PROFILE=yes
 
 cat << EOF
 This package contains vital init scripts needed to run a Lunar Linux
diff --git a/utils/lunar-init/mount b/utils/lunar-init/mount
index 0e93697..3a21dc9 100644
--- a/utils/lunar-init/mount
+++ b/utils/lunar-init/mount
@@ -146,11 +146,27 @@ kernel_is_24()
 }
 
 
+check_for_lvm()
+{
+    if [[ -x /sbin/vgscan ]]; then
+	if [[ -e /proc/modules ]] && ! grep -qs 'device-mapper' /proc/{devices,misc}; then
+ 	    run_without_msg "modprobe dm-mod"
+	fi
+	if [[ -d /proc/lvm ]] || grep -qs 'device-mapper' /proc/{devices,misc}; then
+	    run_with_msg " * Scanning for LVM volume groups" "/sbin/vgscan --mknodes --ignorelockingfailure"
+	    if [[ $? -eq 0 ]] && [[ -d /etc/lvm ]] && [[ -x /sbin/vgchange ]]; then
+		run_with_msg " * Initializing LVM volume groups" "/sbin/vgchange --ignorelockingfailure -a y"
+	    fi
+	fi
+    fi
+}
+
 start()
 {
 	echo -e "Mounting filesystems:"
 
 	run_with_msg " * Mounting /proc" "mount -n -t proc proc /proc"
+
 	if ! grep -qw "ro" /proc/cmdline; then
 		run_with_msg " * Remounting root read-only" "mount -n -o remount,ro /"
 	fi
@@ -196,21 +212,21 @@ start()
 		run_with_msg " * Mounting /dev" "mount -n -t devfs devfs /dev"
 		run_with_msg "Starting devfsd" "devfsd /dev"
 	elif [ "$DEVNODES" = "udev" ]; then
-		run_with_msg " * Mounting udev  on /dev" "mount -w -n -t tmpfs udevfs /dev -o size=6m,mode=0755"
-		# Creating "must have" static device nodes
-		run_without_msg "mkdir -p /dev/{pts,shm}"
-		run_without_msg "cp -a /lib/udev/devices/* /dev"
-		if [ ! -h /dev/ram ]; then
-			ln -sf /dev/ram0 /dev/ram
-		fi
+        run_with_msg " * Mounting udev  on /dev" "mount -w -n -t tmpfs udevfs /dev -o size=6m,mode=0755"
+        # Creating "must have" static device nodes
+        run_without_msg "mkdir -p /dev/{pts,shm}"
+        run_without_msg "cp -a /lib/udev/devices/* /dev"
+        if [ ! -h /dev/ram ]; then
+            ln -sf /dev/ram0 /dev/ram
+        fi
 		run_without_msg "echo > /proc/sys/kernel/hotplug" # Hotplug agents are deprecated!
-                run_with_msg "Starting udev device handling daemon" "/sbin/udevd --daemon"
-                run_with_msg "Activating coldplug devices" "/sbin/udevadm trigger"
-		run_with_msg "Devices activation - please wait" "/sbin/udevadm settle"
-		# This is first aid code for devices hard to init (too slow or to buggy for init by 1st time)
-		# I never have to use it as my machine works great - I leave it just in case
-		#run_with_msg "Activating lazy devices" "/sbin/udevadm trigger --retry-failed"
-		#run_with_msg "Lazy devices activation - please wait" "/sbin/udevadm settle"
+	    run_with_msg "Starting udev device handling daemon" "/sbin/udevd --daemon"
+        run_with_msg "Activating coldplug devices" "/sbin/udevadm trigger"
+        run_with_msg "Devices activation - please wait" "/sbin/udevadm settle"
+        # This is first aid code for devices hard to init (too slow or to buggy for init by 1st time)
+        # I never have to use it as my machine works great - I leave it just in case
+        #run_with_msg "Activating lazy devices" "/sbin/udevadm trigger --retry-failed"
+        #run_with_msg "Lazy devices activation - please wait" "/sbin/udevadm settle"
 		if [ ! -h /dev/fd ]; then
 			ln -sf /proc/self/fd /dev/fd
 		fi
@@ -220,6 +236,9 @@ start()
 		ln -snf /proc/self/fd/2 /dev/stderr
 	fi
 
+	# Time to init LVM
+	check_for_lvm
+
 	# or do we want to explicitly _not_ fsck at all
 	if ! grep -qw nofsck /proc/cmdline ; then
 		# force fsck run?
@@ -228,28 +247,19 @@ start()
 		fi
 
 		# check filesystems
-		FSCKLEVELS=$(sed 's/#.*$//g' /etc/fstab | awk '($6>0){print$6}' | sort -n | uniq)
-		if [ -n "$FSCKLEVELS" ]; then
-			echo "Checking file systems:"
-			for FSCKLEVEL in $FSCKLEVELS; do
-				for FS in $(sed 's/#.*$//g' /etc/fstab | awk "(\$6==$FSCKLEVEL){print\$1}"); do
-				
-					run_with_msg_and_exit_codes " * Checking $FS" "fsck -T -C -y -V $FORCE $FS" "0" "1" ""
-					if [ $? -ge 2 ]; then
-						echo ""
-						echo " *** fsck failed! ***"
-						echo ""
-						echo "   Please repair your file system manually by"
-						echo "   running /sbin/fsck without the -p option."
-						echo ""
-						sulogin
-						reboot  -f
-					fi
-				done
-			done
+		run_with_msg_and_exit_codes "Checking filesystems: " "fsck -A -T -C -y -V $FORCE" "0" "1" ""
+		if [ $? -ge 2 ]; then
+		    echo ""
+		    echo " *** fsck failed! ***"
+		    echo ""
+		    echo "   Please repair your file system manually by"
+		    echo "   running /sbin/fsck without the -p option."
+		    echo ""
+		    sulogin
+		    reboot  -f
 		fi
 	fi
-	
+
 	run_with_msg " * Remounting root read-write" "mount -n -o remount,rw /"
 	if [ "$FORCE" == "-f" ]; then
 		rm -f /forcefsck
@@ -260,38 +270,18 @@ start()
  	run_without_msg "mount -f -o remount,rw /"
 	run_with_msg  "Turning on swap" "swapon -a"
 
-	echo "Mounting remaining filesystems: "
-
 	# hack to get it into /etc/mtab
 	if [ "$DEVNODES" == "devfs" ]; then
 		run_without_msg "mount -f -t devfs devfs /dev"
 	fi
 
-	# sort the filesystems, swapfiles at bottom, squeeze separators into spaces
-	sed 's/#.*$//g' /etc/fstab | tr '\t' ' ' | tr -s '[:space:]' | grep -v -e '^$\|noauto' | LC_ALL=C sort -k2 | while read DEVICE MOUNTPOINT FSTYPE OPTS REST
-	do
-		case $MOUNTPOINT in
-			/|/proc|/sys|/dev) # been mounted previously
-				continue
-				;;
-			none)
-				continue
-				;;
-		esac
-
-		case $FSTYPE in
-			nfs|nfs4|smbfs|cifs)   # we don't do networked fs's yet!
-				continue
-				;;
-		esac
+	# Mount everything except NET_FS and a few others
+	NET_FS="nosmbfs nocifs nonfs nonfs4 nocoda noafs nogfs noncpfs noshfs"
+	run_with_msg "Mounting local filesystems:" "mount -a -t notmpfs,noproc,no${NET_FS// /,}"
+	# Mount all tmpfs devices after all physical
+	run_without_msg "mount -a -t tmpfs"
 
-		if [ -n "$OPTS" ]; then
-			OPTS="-o $OPTS"
-		fi
-
-		run_with_msg  " * Mounting $MOUNTPOINT"  "mount $MOUNTPOINT $OPTS"
 
-	done
 }
 
 
@@ -309,10 +299,10 @@ stop()
 
 	echo "Unmounting all filesystems:"
 
-	cat $MOUNTS | tac | while read TYPE PNT FS REST ; do
-	
+	tac $MOUNTS | while read TYPE PNT FS REST ; do
+
 		case $FS in
-			nfs|nfs4|smbfs|cifs) # we don't do net filesystems
+			nfs|nfs4|smbfs) # we don't do net filesystems
 				continue
 				;;
 		esac
@@ -325,7 +315,7 @@ stop()
 
 		echo  -n " * Umounting $PNT"
 		run_without_msg "sync ; sync" # Flush buffers
-	
+
 		ITERATION=1
 		UNMOUNT_ERROR=0
 
@@ -370,7 +360,7 @@ stop()
 			# unhook loopback device too
 			run_with_msg "Detaching loopback device $TYPE" "losetup -d $TYPE"
 		fi
-	
+
 	done
 
 	run_with_msg "Turning off swap" "swapoff -a"


More information about the Lunar-commits mailing list