Code needs to be implemented in the /etc/conf.d/local.stop to unmount everything..not just what gentoo mounts by itself Reproducible: Always Steps to Reproduce: 1. Mount some file systems, shut down computer Problem fixed, developed a program to auto-unload all file systems when shutting down one's computer. Best place I could figure it would get to a lot of people is here. The code is in C++, the link is below (since it's pretty long and probably isn't a good idea pasting all of it here) http://server.thedarktrumpet.com/demount.cpp g++ demount.cpp -o demount Copy it to /sbin/ Edit /etc/conf.d/local.stop and add the line /sbin/demount This may help with some file system issues, and maybe want to be included in the next version of gentoo, or something.
Created attachment 13604 [details] demount code Code for the program/patch/whatever.
1) What version baselayout ? 2) If it does not unmount cdrom, etc, it is a bug. We already have code in /etc/init.d/halt.sh that should do this, so no need for a hack ... we should rather fix halt.sh if it is broken.
1. 1.8.6.8-r1 2. From what I've had experience tolerating, the code doesn't unmount anything - but I only looked at the hard drive mount/dismount issue of it. I run software raid, and if sub hard drives don't unmount, the main one won't either - meaning a faulty shut down. I can look at the cdrom issue if you wish by editing my code to ommit the cdrom - let me know if you need it. I can understand if you want to fix the perl code - my experience in perl is a bit limited in some ways, so I probably can't do much with it - but overall, it shouldn't be hard to have this code translated to perl *shrug*
my mistake, looked like it would be some perl code - it's just a script. Looking at it, I don't seeit unmounting anything there...well - here is the code I'm talking about: umount -at tmpfs &> /dev/null if checkserver then if [ -n "`swapon -s 2> /dev/null`" ] then # We try to deactivate swap first because it seems # to need devfsd running to work (this is not done # on nodes). TheTERM and KILL stuff will zap # devfsd, so... ebegin "Deactivating swap" swapoff -a &> /dev/null eend $? fi # We need to properly terminate devfsd to save the permissions if [ -n "`ps --no-heading -C 'devfsd'`" ] then ebegin "Stopping devfsd" killall -15 devfsd &> /dev/null eend $? fi fi That looks like it only unmounts a few filesystems, devfsd, swap, and tmpfs. That's one of the reasons why my code doesn't have unmount stuff for those three devices - (look at the if statement dealing with the different filesystems). *shrug* though - doesn't look like it unmounts sub hard drives, such as a loopback mount, or a mount of a partition (/dev/hda -> /mnt/winnt) or anything like that. Maybe something can be fixed there, or include this program and a call to it within the unmounting of the 3 filesystems in the code?
Please attach your halt.sh. If I look at mine, then here is loop stuff unmounted: --------------------------------------------------------- # Credits for next function to unmount loop devices, goes to: # # Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> # Modified for RHS Linux by Damien Neil # # # Unmount file systems, killing processes if we have to. # Unmount loopback stuff first remaining="`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts | sort -r`" [ -n "${remaining}" ] && { sig= retry=3 while [ -n "${remaining}" -a "${retry}" -gt 0 ] do if [ "${retry}" -lt 3 ] then ebegin "Unmounting loopback filesystems (retry)" umount ${remaining} &> /dev/null eend $? "Failed to unmount filesystems this retry" else ebegin "Unmounting loopback filesystems" umount ${remaining} &> /dev/null eend $? "Failed to unmount filesystems" fi for dev in ${remaining} do losetup ${dev} &> /dev/null && { ebegin " Detaching loopback device ${dev}" /sbin/losetup -d ${dev} &> /dev/null eend $? "Failed to detach device ${dev}" } done remaining="`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts | sort -r`" [ -z "${remaining}" ] && break /bin/fuser -k -m ${sig} ${remaining} &> /dev/null sleep 5 retry=$((${retry} - 1)) sig=-9 done } --------------------------------------------------------- Here is non critical filesystems: --------------------------------------------------------- # Try to unmount all filesystems (no /proc,tmpfs,devfs,etc). # This is needed to make sure we dont have a mounted filesystem # on a LVM volume when shutting LVM down ... ebegin "Unmounting filesystems" no_unmount="`mount | awk '{ if (($5 ~ /^(proc|sysfs|devfs|tmpfs|usb(dev)?fs)$/) || ($1 ~ /^(rootfs|\/dev\/root)$/) || ($3 = "/")) print $3 }' | sort | uniq`" for x in `awk '{ print $2 }' /proc/mounts | sort -r | uniq` do do_unmount="yes" for y in ${no_unmount} do [ "${x}" = "${y}" ] && do_unmount="no" done if [ "${do_unmount}" = "yes" ] && \ [ "${x}" != "/" -a "${x}" != "/dev" -a "${x}" != "/proc" -a \ "${x}" != "/sys" ] then umount -f -r ${x} &> /dev/null fi done eend 0 --------------------------------------------------------- Here is final unmounting (no LVM, etc): --------------------------------------------------------- ebegin "Remounting remaining filesystems readonly" # Get better results with a sync and sleep sync;sync sleep 1 sync sleep 1 umount -a -r -n -t nodevfs,noproc,nosysfs,notmpfs &>/dev/null if [ "$?" -ne 0 ] then killall5 -9 &> /dev/null umount -a -r -n -l -d -f -t nodevfs,noproc,nosysfs &> /dev/null if [ "$?" -ne 0 ] then eend 1 sync; sync [ -f /etc/killpower ] && ups_kill_power checkserver && /sbin/sulogin -t 10 /dev/console else eend 0 fi else eend 0 fi ---------------------------------------------------------
Looks like the same stuff i have in my halt.sh, but it still doesn't unmount some of my stuff. For example, I have /dev/hda1 mounted to /mnt/winnt - and /dev/hda5 mounted to /mnt/storage. Neither of them get unmounted with the stock code - it usually gives an error unmounting the root file system stating that it's busy or something. It doesn't give that any more with the hack that I made but *shrug* - not sure if anyone else is having this problem. To help elaborate on the setup I have: IDE - Raid 0 -- Drive1:Partition3 raid drive 0 Drive2:Partition1 raid drive 1 Output from fdisk /dev/hda Disk /dev/hda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 2569 20635461 7 HPFS/NTFS /dev/hda2 2570 2582 104422+ 83 Linux /dev/hda3 2583 7447 39078112+ 83 Linux /dev/hda4 7448 9729 18330165 f Win95 Ext'd (LBA) /dev/hda5 7512 9729 17816053+ b Win95 FAT32 /dev/hda6 7448 7511 514079 83 Linux Partition table entries are not in disk order Output from fdisk /dev/hdc omega root # fdisk -l /dev/hdc Disk /dev/hdc: 40.0 GB, 40020664320 bytes 255 heads, 63 sectors/track, 4865 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdc1 1 4865 39078081 83 Linux omega root # The sub /dev/ entries don't get unmounted for some reason on my system with the stock code, the devfs, proc, etc do get unmounted correctly.
What is the output of 'mount' and 'cat /proc/mounts' ? It unmounts even network devices this side, as well as stacked loop/whatever mounts. I am guessing you do not want to try and resolve the issue with current unmount code - would be appreciated if you would help ... ?
Oh well.
Checked out something interesting, since I reported this problem til now, I received some sort of emerge update that must have rewritten my shutdown stuff. Just for kicks today, I took off my program to see what would happen, and everything unmounted correctly. Sorry bout the delay on this, haven't been in Linux very much lately because of SWG (Star Wars Galaxies). Been addicted to it since it came out, and forgot about the problems I was having :)