SliTaz SliTaz Forum

You are not logged in.

#1 2013-01-20 16:22:41

tkoun
Member
Registered: 2012-12-04
Posts: 21

proposal for a more complete rc.shutdown script

After having observed some bizare error output during shutdown I opted for the following rc.shutdown script in slitaz-boot-scripts package

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

#!/bin/sh

#

# /etc/init.d/rc.shutdown : Executed on system shutdown or reboot

#

. /etc/init.d/rc.functions

. /etc/rcS.conf

log=/var/log/shutdown.log

# Clear and quiet shutdown

clear && echo "System is going down for reboot or halt."

uptime

# Store last alsa settings.

echo "Store last alsa settings..."

if [ -x /usr/sbin/alsactl ]; then

    alsactl store

fi

# Stop all daemons started at boot time.

echo "Stop all daemons started at boot time..."

for daemon in $RUN_DAEMONS

do

    if [ -x /etc/init.d/$daemon ]; then

        /etc/init.d/$daemon stop

    fi

done

if [ "$SCREEN" != "text" ] && [ "$LOGIN_MANAGER" ]; then

    echo -n "Stopping dbus daemon..."

    /etc/init.d/dbus stop

    echo -n "Stopping login manager daemon..."

    /etc/init.d/$LOGIN_MANAGER stop

fi

if [ "$UDEV" == "yes" ]; then

    echo "Stopping udev daemon..."

    udevadm control --exit

    echo "Udevadm waiting for the event queue to finish..."

    udevadm settle --timeout=120

fi

# Stop networking

echo -n "Stopping the network interfaces..."

/etc/init.d/network.sh stop

# Sync all filesystems.

echo "Sync all filesystems..."

sync

# Swap off.

echo "Swap off..."

/sbin/swapoff -a

# Kill all processes.

echo "Kill all processes..."

killall5

# Umount filesystems.

echo "Unmount filesystems..."

/bin/umount -a -r

Offline

#2 2013-01-20 19:15:17

mojo
Administrator
Registered: 2011-03-29
Posts: 2,174

Re: proposal for a more complete rc.shutdown script

Thanks for trying, unclean shutdown on cooking persists.

On reboot:

Checking filesystem: /dev/sda1

/dev/sda1 was not cleanly unmounted, check forced.

/dev/sda1: 11308/68256 files (5.2% non-contiguous), 97173/272640 blocks

Offline

#3 2013-01-21 01:44:03

tkoun
Member
Registered: 2012-12-04
Posts: 21

Re: proposal for a more complete rc.shutdown script

also to avoid hanging at shutdown due to network mounts unmounted after stopping the network

the following needs to be added before network.sh stop

# Unmount network filesystems before stopping the network

echo "Unmounting network filesystems CIFS/NFS etc..."

umount -t cifs,nfs,nfs4,smbfs,ncp,ncpfs,coda,ocfs2,gfs -a -f -l

@mojo

hmm... does moving the sync just before the final umount (thus after the killall) fixes your issue?

Offline

#4 2013-01-22 03:42:13

mojo
Administrator
Registered: 2011-03-29
Posts: 2,174

Re: proposal for a more complete rc.shutdown script

@tkoun

Unclean shutdown persists.

Offline

#5 2013-01-22 09:14:52

tkoun
Member
Registered: 2012-12-04
Posts: 21

Re: proposal for a more complete rc.shutdown script

@mojo

it can be tricky to debug the shutdown sequence.

have you tried to shutdown from a tty console to see if you get the same ?

I'd first disable the graphic login in rcS.conf and then reboot to get to the tty console prompt and login. then sync and poweroff and see if the problem with sda1 is still there.

if you still get "/dev/sda1 was not cleanly unmounted, check forced." you should also check the options used by umount; if there is the -f option and sda1 is kept busy by some process then this may cause sda1 to be "not cleanly unmounted"; you should try to find this process... is it some daemon which is not stopped ?

first I'd remove the -f and look for some error message from the umount command

I'd then put

ps aux > /root/shutdbg-ps.log

lsof > /root/shutdbg-lsof.log

just before the umount command in rc.shutdown and I'd inspect the logs to find some clue of a process keeping sda1 busy.

Offline

#6 2014-08-07 13:21:26

paskali
Member
Registered: 2014-06-29
Posts: 5

Re: proposal for a more complete rc.shutdown script

Hi, after some attempts i think to have found a possible solution at the problems in rc.shutdown

script; at the end, before umount all file system:

[c]# Umount filesystems.
/bin/umount -a -r 2>/dev/null[/c]
insert these lines:

[c]while [ -e /run/udev ]; do
        rm -r /run/udev
done[/c]
so:

[c]#!/bin/sh
# /etc/init.d/rc.shutdown - This script is used by /etc/inittab to stop
# all daemons and shutdown the system.
#
. /etc/init.d/rc.functions
. /etc/rcS.conf

log=/var/log/shutdown.log

# Bold info message with uptime
clear && echo "System is going down for reboot or halt." > $log
uptime >> $log

# Store last alsa settings.
if [ -x /usr/sbin/alsactl ]; then
        alsactl store
fi

# Stop all daemons started at boot time.
for daemon in $RUN_DAEMONS
do
        if [ -x /etc/init.d/$daemon ]; then
                /etc/init.d/$daemon stop >> $log
        fi
done

# Sync all filesystems.
sync

# Swap off.
/sbin/swapoff -a

# Kill all processes.
killall5

while [ -e /run/udev ]; do
        rm -r /run/udev
done

# Umount filesystems.
/bin/umount -a -r 2>/dev/null[/c]
Regards

Pasquale

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.018 seconds, 7 queries executed - Memory usage: 1.54 MiB (Peak: 1.77 MiB) ]