LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-02-2012, 07:47 PM   #16
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600

Quote:
Originally Posted by brianL View Post
it's always /etc/mtab that is the unattached inode that ends up in /lost+found.
OK, so what in the /etc/rc* modifies /etc/mtab on shutdown?
 
Old 07-03-2012, 03:25 AM   #17
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
Strange, but the last four bootups have been without error. Perhaps it's cured itself?
Quote:
Originally Posted by unSpawn View Post
OK, so what in the /etc/rc* modifies /etc/mtab on shutdown?
I can't find anything in /etc/rc.d/rc.6 that modifies mtab on shutdown. And the mtab from /lost+found looks exactly like the one from /etc:
#9177226 from /lost+found:
Code:
/dev/sda1 / ext4 rw,commit=0 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
And here's /etc/mtab, from an error free boot:
Code:
/dev/sda1 / ext4 rw,commit=0 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
 
Old 07-03-2012, 07:38 PM   #18
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Generally, fstab is just stored permanently on disk as a wish list of what you want mounted or might be mounted, but mtab is generated on the fly by the kernel as list of what's actually mounted at any given moment.
Losing mtab shouldn't be an issue.

Having said that, maybe you could try using the old-skool technique of throwing a couple of 'sync' cmds into the shutdown process, thus forcing the disks to be updated before unmounting them.
 
Old 07-04-2012, 02:58 AM   #19
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
Booted up OK again.
Thanks, Chris. There are 3 sync commands in there already:
Code:
#! /bin/sh
#
# rc.6		This file is executed by init when it goes into runlevel
#		0 (halt) or runlevel 6 (reboot). It kills all processes,
#		unmounts file systems and then either halts or reboots.
#
# Version:	@(#)/etc/rc.d/rc.6	2.47 Sat Jan 13 13:37:26 PST 2001
#
# Author:	Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
# Modified by:  Patrick J. Volkerding, <volkerdi@slackware.com>
#

# Set the path.
PATH=/sbin:/etc:/bin:/usr/bin

# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
  . /etc/rc.d/rc.sysvinit
fi

# Set linefeed mode to avoid staircase effect.
/bin/stty onlcr

echo "Running shutdown script $0:"

# Find out how we were called.
case "$0" in
	*0)
		command="halt"
		;;
	*6)
		command=reboot
		;;
	*)
		echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
		exit 1
		;;
esac

# Save the system time to the hardware clock using hwclock --systohc.
if [ -x /sbin/hwclock ]; then
  # Check for a broken motherboard RTC clock (where ioports for rtc are
  # unknown) to prevent hwclock causing a hang:
  if ! grep -q -w rtc /proc/ioports ; then
    CLOCK_OPT="--directisa"
  fi
  if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
    echo "Saving system time to the hardware clock (UTC)."
    /sbin/hwclock $CLOCK_OPT --utc --systohc
  else
    echo "Saving system time to the hardware clock (localtime)."
    /sbin/hwclock  $CLOCK_OPT --localtime --systohc
  fi
fi

# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
  /etc/rc.d/rc.local_shutdown stop
fi

# Stop the Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
  /etc/rc.d/rc.httpd stop
fi

# Stop the MySQL database:
if [ -r /var/run/mysql/mysql.pid ]; then
  . /etc/rc.d/rc.mysqld stop
fi

# Stop the Samba server:
if [ -x /etc/rc.d/rc.samba ]; then
  . /etc/rc.d/rc.samba stop
fi

# Shut down the NFS server:
if [ -x /etc/rc.d/rc.nfsd ]; then
  /etc/rc.d/rc.nfsd stop
fi

# Shut down the SSH server:
if [ -x /etc/rc.d/rc.sshd ]; then
  /etc/rc.d/rc.sshd stop
fi

# Shut down the SASL authentication daemon:
if [ -x /etc/rc.d/rc.saslauthd ]; then
  /etc/rc.d/rc.saslauthd stop
fi

# Shut down OpenLDAP:
if [ -x /etc/rc.d/rc.openldap ]; then
  /etc/rc.d/rc.openldap stop
fi

# Stop D-Bus:
if [ -x /etc/rc.d/rc.messagebus ]; then
  sh /etc/rc.d/rc.messagebus stop
fi

# Kill any processes (typically gam) that would otherwise prevent
# unmounting NFS volumes:
unset FUSER_DELAY
for dir in $(/bin/mount | grep 'type nfs' | cut -d ' ' -f 3 ) ; do
  echo "Killing processes holding NFS mount $dir open..."
  # Background this to prevent fuser from also blocking shutdown:
  /usr/bin/fuser -k -m $dir &
  FUSER_DELAY=5
done
# If fuser was run, let it have some delay:
if [ ! -z "$FUSER_DELAY" ]; then
  sleep $FUSER_DELAY
fi

# Unmount any NFS, SMB, or CIFS filesystems:
echo "Unmounting remote filesystems."
/bin/umount -v -a -l -f -r -t nfs,smbfs,cifs

# Try to shut down pppd:
PS="$(ps ax)"
if echo "$PS" | /bin/grep -q -w pppd ; then
  if [ -x /usr/sbin/ppp-off ]; then
    /usr/sbin/ppp-off
  fi
fi

# Bring down the networking system, but first make sure that this
# isn't a diskless client with the / partition mounted via NFS:
if ! /bin/mount | /bin/grep -q 'on / type nfs' ; then
  if [ -x /etc/rc.d/rc.inet1 ]; then
    . /etc/rc.d/rc.inet1 stop
  fi
fi

# In case dhcpcd might have been manually started on the command line,
# look for the .pid file, and shut dhcpcd down if it's found:
if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then
  /sbin/dhcpcd -k 1> /dev/null 2> /dev/null
  # A little time for /etc/resolv.conf and/or other files to
  # restore themselves.
  sleep 2
fi

# Shut down PCMCIA devices:
if [ -x /etc/rc.d/rc.pcmcia ]; then
  . /etc/rc.d/rc.pcmcia stop
  # The cards might need a little extra time here to deactivate:
  /bin/sleep 5
fi

# Turn off process accounting:
if [ -x /sbin/accton -a -r /var/log/pacct ]; then
  /sbin/accton off
fi

# Terminate acpid before syslog:
if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
  . /etc/rc.d/rc.acpid stop
fi

# Kill all processes.
# INIT is supposed to handle this entirely now, but this didn't always
# work correctly without this second pass at killing off the processes.
# Since INIT already notified the user that processes were being killed,
# we'll avoid echoing this info this time around.
if [ ! "$1" = "fast" ]; then # shutdown did not already kill all processes
  /sbin/killall5 -15 
  /bin/sleep 5
  /sbin/killall5 -9
fi

# Try to turn off quota.
if /bin/grep -q quota /etc/fstab ; then
  if [ -x /sbin/quotaoff ]; then
    echo "Turning off filesystem quotas."
    /sbin/quotaoff -a
  fi
fi

# Carry a random seed between reboots.
echo "Saving random seed from /dev/urandom in /etc/random-seed."
# Use the pool size from /proc, or 512 bytes:
if [ -r /proc/sys/kernel/random/poolsize ]; then
  /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null
else
  /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null
fi
/bin/chmod 600 /etc/random-seed

# Before unmounting file systems write a reboot or halt record to wtmp.
$command -w

# Clear /var/lock/subsys.
if [ -d /var/lock/subsys ]; then
  rm -f /var/lock/subsys/*
fi

# Turn off swap:
echo "Turning off swap."
/sbin/swapoff -a
/bin/sync

echo "Unmounting local file systems."
/bin/umount -v -a -t no,proc,sysfs

echo "Remounting root filesystem read-only."
/bin/mount -v -n -o remount,ro /

# This never hurts:
/bin/sync

# Close any volumes opened by cryptsetup:
if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then
  cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do
    # NOTE: we only support LUKS formatted volumes (except for swap)!
    LUKS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f1 -d' ')
    DEV=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f2 -d' ')
    OPTS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f4 -d' ')
    if /sbin/cryptsetup isLuks $DEV 2>/dev/null ; then
      echo "Locking LUKS crypt volume '${LUKS}':"
      /sbin/cryptsetup luksClose ${LUKS}
    elif echo $OPTS | grep -wq swap ; then
      # If any of the volumes was used as encrypted swap,
      # then run mkswap on the underlying device -
      # in case other Linux installations on this computer should use it:
      echo "Erasing encrypted swap '${LUKS}' and restoring normal swap on ${DEV}:"
      /sbin/cryptsetup remove ${LUKS}
      mkswap $DEV
    fi
  done
fi

# Deactivate LVM volume groups:
if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then
  echo "Deactivating LVM volume groups:"
  /sbin/vgchange -an --ignorelockingfailure
fi

# This never hurts again (especially since root-on-LVM always fails
# to deactivate the / logical volume...  but at least it was
# remounted as read-only first)
/bin/sync

# sleep 3 fixes problems with some hard drives that don't
# otherwise finish syncing before reboot or poweroff
/bin/sleep 3

# This is to ensure all processes have completed on SMP machines:
wait

if [ -x /sbin/genpowerd ]; then
  # See if this is a powerfail situation:
  if /bin/egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then
    # Signal UPS to shut off the inverter:
    /sbin/genpowerd -k
    if [ ! $? = 0 ]; then
      echo
      echo "There was an error signaling the UPS."
      echo "Perhaps you need to edit /etc/genpowerd.conf to configure"
      echo "the serial line and UPS type."
      # Wasting 15 seconds of precious power:
      /bin/sleep 15
    fi
  fi
fi

# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
if [ "$command" = "reboot" ]; then
  echo "Rebooting."
  /sbin/reboot
else
  /sbin/poweroff
fi
 
Old 07-04-2012, 07:27 PM   #20
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Indeed, but the point is to have at least 2 syncs (some recommended 3 due to built-in HW buffering etc) as literally the last cmds just before reboot or power off eg old-skool shutdown was
Code:
sync
sync
sync  #(optionally)
shutdown -h now
Any time you do something, you (potentially) un-sync the disk(s) version of reality from the RAM version...

Eg taking the end of your script
Code:
# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
if [ "$command" = "reboot" ]; then
  echo "Rebooting."
  sync
  sync
  /sbin/reboot
else
  sync
  sync
  /sbin/poweroff
fi
 
1 members found this post helpful.
Old 07-05-2012, 02:17 AM   #21
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
Thanks again, Chris.
Got the error again this morning, so I've put the extra syncs in /etc/rc.d/rc.6. Since it's not a regular occurrence, I'll have to see what happens over the next week of bootups. Fingers, toes, and eyes crossed.
 
Old 07-05-2012, 03:36 AM   #22
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by brianL View Post
There are 3 sync commands in there already:
Not only that but at the bottom of the script it also performs an explicit '/bin/mount -v -n -o remount,ro /' to ensure /etc/mtab doesn't get updated by mount. As writing /etc/mtab happens on "remount,ro" it still shouldn't be impossible to troubleshoot but it might require looking at system calls and logging them where a log file still can be written to (as in remote). You might find that requiring a bit too much work. As a temporary workaround, how about linking mtab to something on an expendable file system like /dev/shm? (Won't work if /etc/mtab is hard-coded in the 'mount' binary and in a way it ignores substitutes anyway.)
 
Old 07-05-2012, 03:58 AM   #23
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
Not only that but at the bottom of the script it also performs an explicit '/bin/mount -v -n -o remount,ro /' to ensure /etc/mtab doesn't get updated by mount. As writing /etc/mtab happens on "remount,ro" it still shouldn't be impossible to troubleshoot but it might require looking at system calls and logging them where a log file still can be written to (as in remote). You might find that requiring a bit too much work. As a temporary workaround, how about linking mtab to something on an expendable file system like /dev/shm? (Won't work if /etc/mtab is hard-coded in the 'mount' binary and in a way it ignores substitutes anyway.)
Thanks, unSpawn. Too much work, and beyond my present level of knowledge. I wouldn't want to tinker with the system too much, since this error has only shown up in the last month or so, it wasn't there right after installation of Slackware 13.37.
 
Old 07-05-2012, 08:26 AM   #24
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Nevertheless you need to pursue an explanation of such "unexplained behavior," which sounds frankly suspicious to me. Very suspicious ...

Very very suspicious ...
 
Old 07-05-2012, 08:32 AM   #25
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
If it sounds suspicious, what do you suspect may be causing it? I ran rkhunter last week, and it found nothing.
I would like to find an explanation, definitely. When the error first cropped up, I did a websearch, and all similar problems seem to have been cleared up with a manual fsck.

Last edited by brianL; 07-05-2012 at 08:35 AM.
 
Old 07-07-2012, 08:12 AM   #26
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
The extra syncs didn't work. Two more bootups: yesterday with error, today OK.
 
Old 07-08-2012, 06:40 AM   #27
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by brianL View Post
If it sounds suspicious, what do you suspect may be causing it?
I agree. Dropping clues slash hints would have been helpful.


Quote:
Originally Posted by brianL View Post
I ran rkhunter last week, and it found nothing.
...because RKH doesn't know about any /etc/mtab-modifying malware. Not that I would suspect yours is a case of malware anyway.


Quote:
Originally Posted by brianL View Post
I would like to find an explanation, definitely. When the error first cropped up, I did a websearch, and all similar problems seem to have been cleared up with a manual fsck.
We're talking about writing /etc/mtab on shutdown slash reboot and beyond the point any unprivileged user-initiated applications survive so I strongly doubt doing a web search or anything else would influence this behaviour. Do you perchance have FUSE installed? If you don't would you be willing to install it temporarily? If you can then FUSE-loggedfs may help us show (example) in more detail what's going on.
 
Old 07-08-2012, 10:08 AM   #28
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
Yes, FUSE is already installed. And I've managed to get loggedfs installed after a bit of a struggle. Now all I have to do is work out what to do next.
Thanks, unSpawn.
 
Old 07-08-2012, 11:26 AM   #29
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
0) Save the default configuration XML as /etc/loggedfs.conf
Code:
<?xml version="1.0" encoding="UTF-8"?>
<loggedFS logEnabled="true" printProcessName="true">
	<includes>
		<include extension=".*" uid="*" action=".*" retname=".*"/>
	</includes>
	<excludes>
		<!-- Do not log getattr operations -->
		<exclude extension=".*" uid="*" action="getattr" retname=".*"/>
	</excludes>
</loggedFS>
*Could narrow it down to only write ops but lets just see.
1) Insert the line
Code:
/full/path/to/loggedfs -fp -c /etc/loggedfs.conf -l /etc/
in /etc/rc.d/rc.6. IMO best put it right after the last 'sync' to start with.
2) Reboot should show loggedfs kicks in writing to stdout (http://loggedfs.sourceforge.net/loggedfs.html).
 
Old 07-08-2012, 11:43 AM   #30
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298

Original Poster
Blog Entries: 61

Rep: Reputation: Disabled
Thanks again, unSpawn. Will try this, added to /etc/rc.d/rc.6:
Code:
/usr/bin/loggedfs -fp -c /etc/loggedfs.conf -l /home/brian/rc6.log
Does that look OK?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unattached inode, connect to lost+found, ref count is 2 should be 1 anon091 Linux - Newbie 2 02-17-2012 07:37 AM
questions abt inode.inode gurus plz have a look aceone Red Hat 7 05-22-2011 12:11 PM
Thousands of "unattached inode" entries freezing fsck. Nothsa Linux - General 4 05-11-2008 04:56 PM
Unattached Inode? Killean Slackware 8 05-17-2006 04:38 PM
How to repair File System Error - unattached inode 37138 ch.keller Linux - Software 1 07-21-2004 07:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration