Skip to contentSkip to conversation

UPS shutdown on system with lvm volume for root

linux-lvm David Mathog 2 participants 2 messages Jul 15, 2008

lore
Share & tools
lore
#0 lore raw

I am trying to use nut on a Centos 5.0 system. On this system "/" is a 1.4 Tb LVM volume composed of two 700Gb partitions (striped). Nut is set up completely except for the final modification to the /etc/init.d/halt script. So far I have made this change:

< command=/sbin/halt
< if [ -f /var/run/killpower -a -r /etc/ups/upsmon.conf -a -f /etc/sysconfig/ups ] ; then
< /usr/local/ups/sbin/upsdrvctl shutdown
---

Quoted 1 line

if [ "$command" = /sbin/halt -a -r /etc/ups/upsmon.conf -a -f

/etc/killpower -a -f /etc/sysconfig/ups ] ; then

Quoted 4 lines

. /etc/sysconfig/ups
if [ "$SERVER" = "yes" -a "$MODEL" = "upsdrvctl" ] ; then /sbin/upsdrvctl shutdown
elif [ "$SERVER" = "yes" -a "$MODEL" != "NONE" -a -n "$MODEL" -a -n

"$DEVICE" ] ; then

Quoted 2 lines

$MODEL $OPTIONS_HALT -k $DEVICE
fi

However, I'm worried that this might corrupt the LVM metadata. The "upsdrvctl shutdown" is equivalent to pulling the server's power cord out. Because of this, elsewhere in the nut documentation it suggested doing

mdadm --readonly <device>

before the upsdrvctl shutdown. However, I do not believe that the present system is using mdadm.

Is a similar command necessary for lvm? Or will the lvm volume have been remounted readonly "automagically" by this section of the halt script, which precedes the above changes by a couple of lines?

# Remount read only anything that's left mounted.

# echo $"Remounting remaining filesystems readonly"
mount | awk '{ print $3 }' | while read line; do
fstab-decode mount -n -o ro,remount $line
done

It is important that the logical volume is shut down nicely on a power failure event, since it takes a very long time to fsck it, and that should not be needed when power is restored from a controlled UPS initiated shutdown. Additionally, swap is also a logical volume, so it might need special attention too.

In a normal shutdown the upsdrvctl is never called and the halt proceeds to:
--------------------

# First, try kexec. If that fails, fall back to rebooting the old way. [ -n "$kexec_command" ] && $kexec_command -e >& /dev/null

HALTARGS="-d"
[ -f /poweroff -o ! -f /halt ] && HALTARGS="$HALTARGS -p"

exec $command $HALTARGS

---------------------------

Is anything in there required for the lvm to be seen as clean on the next boot???

Thanks,

David Mathog
[email protected]
Manager, Sequence Analysis Facility, Biology Division, Caltech

#1 lore raw
Quoted 9 lines · David Mathog

Is a similar command necessary for lvm? Or will the lvm volume have been remounted readonly "automagically" by this section of the halt script, which precedes the above changes by a couple of lines?

# Remount read only anything that's left mounted.

# echo $"Remounting remaining filesystems readonly"
mount | awk '{ print $3 }' | while read line; do
fstab-decode mount -n -o ro,remount $line
done

The above makes all mounted filesystems readonly, including those on logical volumes. There is no "mounting" for LVM itself. Under normal operations, the metadata does not change. If the system is in the middle of a pvmove - well - making the metadata suddenly readonly won't exactly help matters. Ideally, LVM should update metadata in a manner that leaves it consistent should the system crash in the middle. The current LVM strives toward that goal. But there shouldn't be any LVM updating going on during a shutdown. There is no LVM metadata updated in normal operations.

Snapshots will update the COW table. Mounting the filesystems read-only should freeze that. And again, COW updates are designed to be interruptable.

Quoted 2 lines

It is important that the logical volume is shut down nicely on a power failure event, since it takes a very long time to fsck it, and that

Even if you lose power before the mount readonly, you don't need a full fsck for journalled filesystems.

If you are using Xen, then virtual machines may be updating their filesystems. The standard shutdown for Xen will either shutdown each VM or suspend each VM to disk. Suspending to disk is actually the fastest approach.

You don't need to worry about swap.

Signature · 4 lines
	      Stuart D. Gathman <[email protected]>
    Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flammis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.