Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 33676 - halt.sh does not mount filesystems read-only
Summary: halt.sh does not mount filesystems read-only
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High critical (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-17 07:40 UTC by Take Vos
Modified: 2004-11-30 21:40 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
changed halt.sh which solves the problem (for me) (halt.sh,4.49 KB, text/x-sh)
2003-12-08 15:24 UTC, dalas.revo
Details
patch for /etc/init.d/halt.sh baselayout-1.8.6.13-r1 (halt.sh.patch,376 bytes, patch)
2004-04-03 14:23 UTC, Raimar Sandner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Take Vos 2003-11-17 07:40:04 UTC
halt.sh does not mount filesystems read-only, beause it uses the -f option 
during remounting. This options means (from the mount man-page) "fake", as 
in does not do anything. 
 
sys-apps/baselayout-1.8.6.12 
 

Reproducible: Always
Steps to Reproduce:
Comment 1 dalas.revo 2003-12-08 15:24:42 UTC
Created attachment 21897 [details]
changed halt.sh which solves the problem (for me)
Comment 2 dalas.revo 2003-12-08 15:25:11 UTC
i noticed the not mounting r/o, too. i suffered from massive corruption of my root partition, all others were mounted r/o. but i think that (at least in 1.8.6.12-r2 the problem is another one:
if you look at these lines:
mount_readonly() {
	local x=
	local retval=0
	
	for x in `awk '$1 != "none" { print $2 }' /proc/mounts | sort -r`
	do
		mount -n -o remount,ro ${x} &>/dev/null
		retval=$((${retval} + $?))
	done

	return ${retval}
}

you see that it in fact doesn't use the -f option, at least in this function which i believe is responsible for mounting read-only.
what i did to solve my problem was this:
a few lines below there is the procedure for mounting it read-only:

ebegin "Remounting remaining filesystems readonly"
# Get better results with a sync and sleep
sync; sync
sleep 1
if ! mount_readonly
then
	killall5 -9  &>/dev/null
	sync; sync
	sleep 1
	if ! mount_readonly
	then
		eend 1
		sync; sync
		[ -f /etc/killpower ] && ups_kill_power
		/sbin/sulogin -t 10 /dev/console
	else
		eend 0
	fi
else
	eend 0
fi


the comment "# Get better results with a sync and sleep" lead me to the assumption that the problems were possibly just due to the fact that sleep was too short.

i changed the two "sleep 1" to "sleep 4" and my problems were gone. Of course it takes three more seconds to shut down my box, but i don't care because from this time i never had any problems with not cleanly unmounted devices anymore.

i attach my new halt.sh.

revo
Comment 3 Richard Morris 2004-02-15 06:39:24 UTC
I had a couple of computers that failed to shut down cleanly, hanging at the same point with baselayout  1.8.6.13. This making the change from `sleep 1` to `sleep 4` has fixed both boxes.
Comment 4 Raimar Sandner 2004-04-03 14:23:57 UTC
Created attachment 28642 [details, diff]
patch for /etc/init.d/halt.sh baselayout-1.8.6.13-r1

There is another problem with remounting filesystems readonly if the root
filesystem is encrypted with loop-AES. The initrd used to enter the passphrase
at boottime cannot be unmounted (according to the README in the loop-AES
package). Therefore it appears in /proc/mounts at the time mount_readonly() is
called.

The problem here: /innitrd is (usually) not listed in /etc/fstab, and since the
awk commando only returns the directory names of the mounted filesystems, mount
exits with an error.

This patch tries to fix the situation by letting awk return devicename and
directoryname, so no fstab is needed to resolve the device. It works for me.
Comment 5 Aron Griffis (RETIRED) gentoo-dev 2004-08-01 16:38:42 UTC
This makes zero sense.  Forget increasing the sleep time, there's no reason that sleep should be necessary between syncing and attempting to remount the filesystems read-only.  Of course the sync itself is also silly (nevermind being doubled!), at least prior to attempting to remount the filesystems.  There's no reason to apply this patch, it just is masking a deeper problem.

Please don't misunderstand; I am sorry to hear about filesystem corruption, and I appreciate the work you have put into debugging the problem.  But this approach is not the right one and the problem will just come up again for somebody else.

What filesystem are you guys running, and what kernel versions?
Comment 6 Raimar Sandner 2004-08-12 08:11:30 UTC
Thes patch doesn't mess with sleep times. It addresses another problem when using loop-AES.
Comment 7 Jérémie Delente 2004-09-30 14:56:18 UTC
Hi,

i have the same problem, system hangs when it reaches the remounting remaining filesystem read-only.

it happens with kernel 2.6.8-ck8, and in fact since 2.6.7(all, i've tried mm, ck, develloppement, gentoo-dev...) but works perfectly with 2.6.6-rc3-love4, i have not tried on 2.6.6 kernel.

My root partition is reiserfs (3.6), boot is in ext2, my baselayout is now in version 1.10.4 with sysvinit-2.85.

hope it will help you, Aron
Comment 8 SpanKY gentoo-dev 2004-09-30 17:13:27 UTC
do you guys use prelink ?
Comment 9 Jérémie Delente 2004-10-01 02:43:49 UTC
ok, i have prelink installed (version 20040317), but my CFLAGS don't call -fPIC nor -DPIC by default.

emerge info
Portage 2.0.50-r11 (default-x86-1.4, gcc-3.3.4, glibc-2.3.3.20040420-r1, 2.6.6-rc3-love4)
=================================================================
System uname: 2.6.6-rc3-love4 i686 Intel(R) Pentium(R) M processor 1700MHz
Gentoo Base System version 1.5.3
Autoconf: sys-devel/autoconf-2.59-r4
Automake: sys-devel/automake-1.8.5-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-Os -march=pentium3 -msse2 -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-Os -march=pentium3 -msse2 -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://trumpetti.atm.tut.fi/gentoo/ http://gentoo.mirror.sdv.fr/ http://ds.thn.htu.se/linux/gentoo/ http://www.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X acpi alsa atapi avi berkdb bitmap-fonts cdr crypt cups directfb dvd encode esd fbcon flash foomaticdb gdbm ggi gif gphoto2 gpm gtk gtk2 imlib java jpeg lcms libg++ libwww mad mikmod mmx motif mpeg ncurses nls nvidia oggvorbis opengl oss pam pdflib perl png python quicktime readline reiserfs slang socks5 spell sse ssl svga tcpd tiff video_cards_nvidia x86 xml2 xmms xprint xv zlib"
Comment 10 Jérémie Delente 2004-10-01 02:44:21 UTC
ok, i have prelink installed (version 20040317), but my CFLAGS don't call -fPIC nor -DPIC by default.

emerge info
Portage 2.0.50-r11 (default-x86-1.4, gcc-3.3.4, glibc-2.3.3.20040420-r1, 2.6.6-rc3-love4)
=================================================================
System uname: 2.6.6-rc3-love4 i686 Intel(R) Pentium(R) M processor 1700MHz
Gentoo Base System version 1.5.3
Autoconf: sys-devel/autoconf-2.59-r4
Automake: sys-devel/automake-1.8.5-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-Os -march=pentium3 -msse2 -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-Os -march=pentium3 -msse2 -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://trumpetti.atm.tut.fi/gentoo/ http://gentoo.mirror.sdv.fr/ http://ds.thn.htu.se/linux/gentoo/ http://www.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X acpi alsa atapi avi berkdb bitmap-fonts cdr crypt cups directfb dvd encode esd fbcon flash foomaticdb gdbm ggi gif gphoto2 gpm gtk gtk2 imlib java jpeg lcms libg++ libwww mad mikmod mmx motif mpeg ncurses nls nvidia oggvorbis opengl oss pam pdflib perl png python quicktime readline reiserfs slang socks5 spell sse ssl svga tcpd tiff video_cards_nvidia x86 xml2 xmms xprint xv zlib"
Comment 11 Jérémie Delente 2004-10-08 08:14:09 UTC
i have tested if it was a hotplug(running with udev034) issue because i have it on default runlevel) so i put it in boot runlevel and no changes :(

but i have noticed this: when it freezes, by pressing return you get a prompt and a ps aux shows these 2 process
root  ...    Ss   /bin/bash  /sbin/rc shutdown
root  ...    D    /bin/bash  /sbin/rc shutdown

hope it will help
Comment 12 Jérémie Delente 2004-10-13 07:45:49 UTC
like it is said in bug 58839, i have commented the ligne halt -w &>/dev/null in /etc/init.d/halt.sh and no it works fine.
Comment 13 SpanKY gentoo-dev 2004-11-30 21:40:55 UTC
we have multiple things being thrown around here so i'll resolve a few and punt this bug

- use 1.11.x
- halt.sh does not call 'mount -f' anymore (if it ever did) ... it does call 'umount -f', but -f means diff things with mount and umount
- Aron's comment about sleep times was not directed at the suggested loop-aes fix but rather the original halt.sh patch
- the loop-aes patch should have a new bug filed where we can analyze that fix properly (and without all the noise)
- Bug 58839 is unrelated to this