Jump to content

Need help with Mandriva shutdown [solved]


Recommended Posts

I have a critical bug: https://qa.mandriva.com/show_bug.cgi?id=54143

Using Mandriva 2010.0.

 

To try and work around the problem for now, I created a LVM umount script:

#!/bin/bash
#
# chkconfig: 12345 99 70
# description: Unmount LVM partitions before it hangs the PC.

### BEGIN INIT INFO
# Provides: safe-lvm-umount
# Default-Start: 12345 1 2 3 4 5
# Default-Stop: 06 0 6
# Short-Description: Unmount LVM partitions before it hangs the PC.
### END INIT INFO

# Source function library
. /etc/rc.d/init.d/functions

function countLVM() {
mount | grep /dev/mapper/ | wc -l
}

if [[ $(countLVM) -gt 0 ]]; then
case "$1" in
	stop)
		LVMmounts="$(mount | sed -nr 's#/dev/mapper/.* on (.*) type .*#\1#p')"
		{ \
			echo "$LVMmounts"
			mount \
			| grep -Ef <(sed 's#^.*$# on \0/.+ type #' <<<"$LVMmounts") \
			| sed -nr 's#.* on (.*) type .*#\1#p'
		} \
		| sort -ru \
		| while read mountpoint; do
			action "Unmounting $mountpoint..." umount "$mountpoint"
		done
		gprintf "Unmounting LVM partitions..."
		RETVAL=$(countLVM)
		[ $RETVAL -eq 0 ] && success || failure
		echo
		;;
	*)
		gprintf "Usage: %s stop\n" "$0"
		;;
esac
else
{
	echo "No LVM partition mounted:"
	mount
} | sed 's/^/safe_lvm_umount... /'
fi

exit ${RETVAL:-0}

First two comments:

— The strange “12345†runlevel in Default-Start is a probably useless bug work-around I picked from popfile, in hope it would help, but it doesn't change anything. Same for Default-Stop.

— The whole “else {…} | sed …†block was added to still get something on screen even if no LVM partitions are mounted. I don't need it but I try to debug my problem…

 

I enabled my script as needed:

[yves@sedentaire ~]$ find /etc/rc.d -name "*safe-lvm-umount" | xargs ls -1
/etc/rc.d/init.d/safe-lvm-umount
/etc/rc.d/rc0.d/K70safe-lvm-umount
/etc/rc.d/rc1.d/S99safe-lvm-umount
/etc/rc.d/rc2.d/S99safe-lvm-umount
/etc/rc.d/rc3.d/S99safe-lvm-umount
/etc/rc.d/rc4.d/S99safe-lvm-umount
/etc/rc.d/rc5.d/S99safe-lvm-umount
/etc/rc.d/rc6.d/K70safe-lvm-umount
/etc/rc.d/rc7.d/K70safe-lvm-umount

 

And yet… whatever I do, my script is NEVER called on shutdown! I always get this:

[EDIT: I removed the screenshot; here's the relevant part:]
Unmounting file systems: umount2: Device or resource busy
umount: /ici: device is busy.
       (In some cases useful info about processes that use
        the device is found by lsof(8) or fuser(1))
umount2: Device or resource busy                              [FAILED]
[/EDIT]

 

What should I do to make sure the script is run? The script is good because the PC doesn't hang if I run it before calling shutdown.

 

Yves.

Edited by theYinYeti
Link to comment
Share on other sites

Is this script enabled using the chkconfig command?

 

chkconfig --add safe-lvm-umount

 

for example? You can check:

 

chkconfig --list | grep -i lvm

 

to see if it appears. Only thing I can think of right now.

Link to comment
Share on other sites

I want to integrate as much as possible with Mandriva's scripts, because I don't want to create a custom launcher for each and every desktop/panel combination that I, or my wife, or my son, use… That's why I try the rc.d route.

 

My script is indeed enabled using chkconfig --add.

 

Yves.

 

Edit: it is enabled, since I see the “Usage: safe-lvm-umount stop†message in boot logs.

Edited by theYinYeti
Link to comment
Share on other sites

I managed to solve my issue by reverting the way the script works (invert start and stop).

 

So the script is now:

#!/bin/bash
#
# chkconfig: 067 00 99
# description: Unmount LVM partitions before it hangs the PC.

### BEGIN INIT INFO
# Provides: safe-lvm-umount
# Default-Start: 067 0 6 7
# Short-Description: Unmount LVM partitions before it hangs the PC.
### END INIT INFO

# Source function library
. /etc/rc.d/init.d/functions

function countLVM() {
mount | grep /dev/mapper/ | wc -l
}

if [[ $(countLVM) -gt 0 ]]; then
case "$1" in
	start)
		LVMmounts="$(mount | sed -nr 's#/dev/mapper/.* on (.*) type .*#\1#p')"
		{ \
			echo "$LVMmounts"
			mount \
			| grep -Ef <(sed 's#^.*$# on \0/.+ type #' <<<"$LVMmounts") \
			| sed -nr 's#.* on (.*) type .*#\1#p'
		} \
		| sort -ru \
		| while read mountpoint; do
			action "Unmounting $mountpoint..." umount "$mountpoint"
		done
		gprintf "Unmounting LVM partitions..."
		RETVAL=$(countLVM)
		[ $RETVAL -eq 0 ] && success || failure
		echo
		;;
	*)
		gprintf "Usage: %s start\n" "$0"
		;;
esac
fi

exit ${RETVAL:-0}

 

And accordingly:

[yves@sedentaire ~]$ find /etc/rc.d -name "*safe-lvm-umount" | xargs ls -1
/etc/rc.d/init.d/safe-lvm-umount
/etc/rc.d/rc0.d/S00safe-lvm-umount
/etc/rc.d/rc1.d/K99safe-lvm-umount
/etc/rc.d/rc2.d/K99safe-lvm-umount
/etc/rc.d/rc3.d/K99safe-lvm-umount
/etc/rc.d/rc4.d/K99safe-lvm-umount
/etc/rc.d/rc5.d/K99safe-lvm-umount
/etc/rc.d/rc6.d/S00safe-lvm-umount
/etc/rc.d/rc7.d/S00safe-lvm-umount

 

Side-note: for some reason, “chkconfig --add safe-lvm-umount†made the link in rc3.d/ a S00 instead of a K99, and I had to correct it by hand…

Now it works as intended. Still, I wish I understood why the former method did not!

 

Yves.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...