Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 186542 - baselayout 1.12.9-r2 has problems with read-only NFS root
Summary: baselayout 1.12.9-r2 has problems with read-only NFS root
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-25 03:03 UTC by aero1967
Modified: 2016-01-08 03:27 UTC (History)
5 users (show)

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


Attachments
Checkroot script modified to avoid spots which cause NFSROOT boots with rdonly / to fail (checkroot-modified,3.26 KB, text/plain)
2007-07-25 03:06 UTC, aero1967
Details
representative fstab file for a machine with a read-only NFSROOT as described initially (fstab-for-gentoo-bugrept,1.59 KB, text/plain)
2007-07-25 04:54 UTC, aero1967
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aero1967 2007-07-25 03:03:48 UTC
I am using release 2007.0 on a mix of AMD64 and 686-class machines.  In this configuration, the machines use a shared readonly 2007.0 installation over NFSROOT (each arch has its own installation and directory), and only /var and /tmp are on local partitions.  The server and clients are using NFSv3 exclusively, no NFsv2 or v4.

The default init scripts do not cope well with NFS roots and especially if / or /etc is read-only.  I should note that /etc/conf.d/hostname is a symlink to a file on /var (unique hostnames for each machine), and /etc/mtab is a symlink to /proc/mounts , so other than the init script issue, these machines can work fine.

In this configuration, portmap is in the "default" runlevel, as is netmount.

The problems:

1. checkroot's test to see if / is read-only:

        # Should we mount root rw ?  the touch check is to see if the / is
        # already mounted rw in which case there's nothing for us to do
        if mount -vf -o remount / 2> /dev/null | \

doesn't seem to work properly in this environment -- the then branch always gets followed, and an attempt is made to remount root as r/w , which of course fails.  I have had to modify checkroot to just bypass this check in order for my machines to boot properly.

2. For some reason on the i686 machines, the check to see if /etc is readonly in the section of the code that creates /etc/mtab seems to outright fail the script.  On AMD64, it gives errors but continues.  I have modified checkroot to just exit before getting to this stage.

3. localmount just uses "mount -at", without checking to see if /etc readonly.  Consequently, mount gives warning messages that -n should be used.  This not a fatal error, but certainly annoying / a problem.

Also, do I have the correct init scripts in the boot or default runlevels for an NFS root?  The gentoo-diskless howto just uses netmount, but within the netmount script, it mentions portmap should be loaded.  However, there are also init scripts for rpc.statd and nfsmount, and I'm not sure between {netmount, portmap, rpc.statd and nfsmount} init scripts, which should be loaded at what runlevel for an NFS root (nor were the forums of great help -- additional documentation would be really appreciated).
Comment 1 aero1967 2007-07-25 03:06:27 UTC
Created attachment 125948 [details]
Checkroot script modified to avoid spots which cause NFSROOT boots with rdonly / to fail
Comment 2 aero1967 2007-07-25 03:07:56 UTC
Comment on attachment 125948 [details]
Checkroot script modified to avoid spots which cause NFSROOT boots with rdonly / to fail

This is not meant to show how to actually fix the script, just what I did in my case to go around the problem spots.
Comment 3 SpanKY gentoo-dev 2007-07-25 04:30:19 UTC
if your /etc is readonly, then make /etc/mtab a symlink to /proc/mounts

post your actual /etc/fstab ... it should of course have an entry declaring / as ro
Comment 4 aero1967 2007-07-25 04:53:15 UTC
(In reply to comment #3)
> if your /etc is readonly, then make /etc/mtab a symlink to /proc/mounts
> 
> post your actual /etc/fstab ... it should of course have an entry declaring /
> as ro
> 

As I mentioned in my initial submission, that is exactly what I had done.

I'm attaching a representative /etc/fstab .
Comment 5 aero1967 2007-07-25 04:54:19 UTC
Created attachment 125952 [details]
representative fstab file for a machine with a read-only NFSROOT as described initially
Comment 6 SpanKY gentoo-dev 2007-07-25 11:32:57 UTC
what version of util-linux are you using ?

seems to be a bug in util-linux, not baselayout
Comment 7 aero1967 2007-07-25 17:43:19 UTC
(In reply to comment #6)
> what version of util-linux are you using ?
> 
> seems to be a bug in util-linux, not baselayout
> 

util-linux-2.12r-r7
Comment 8 SpanKY gentoo-dev 2007-07-28 05:08:13 UTC
yeah, this is a bug in util-linux which has been fixed upstream already ... however, ive been pondering the code and i believe i can simplify the logic while working around the bug in the process
Comment 9 aero1967 2007-07-30 20:47:49 UTC
Even if problems 1. and 2. are due to bugs in util-linux, it doesn't have any impact on localmount as-is, since there is no logic there to check for a read-only /etc .

Also, could you clarify which NFS-related initscripts should be in the boot and default runlevels for an NFSROOT configuration?
Comment 10 Adam Piątyszek 2008-02-05 09:44:00 UTC
Hi!

I have a similar setup as aero1967, however I use pure diskless nodes. The /etc and /tmp partitions are remounted rw on top of ro ones using aufs trick.

Anyway I confirm that since a recent upgrade of baselayout (1.12.9-r2 -> 1.12.10-r5) and util-linux (2.12r-r8 -> 2.13-r2) I had problems with booting my diskless nodes via NFS, due to this remounting try in checkroot. So, I had to comment the following lines from the init script:

#	if mount -vf -o remount / 2> /dev/null | \
#	   awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }' && \
#	   ! touch -c / >& /dev/null
#	then
#		ebegin "Remounting root filesystem read/write"
#		mount -n -o remount,rw / &> /dev/null
#		if [[ $? -ne 0 ]] ; then
#			eend 2 "Root filesystem could not be mounted read/write 
:("
#			if [[ ${RC_FORCE_AUTO} != "yes" ]] ; then
#				sulogin ${CONSOLE}
#			fi
#		else
#			eend 0
#		fi
#	fi

So, is it a bug in util-linux-2.13-r2 or in the latest stable baselayout?


As for aero1967's questions:

(In reply to comment #0)
> Also, do I have the correct init scripts in the boot or default runlevels for
> an NFS root?  The gentoo-diskless howto just uses netmount, but within the
> netmount script, it mentions portmap should be loaded.  However, there are also
> init scripts for rpc.statd and nfsmount, and I'm not sure between {netmount,
> portmap, rpc.statd and nfsmount} init scripts, which should be loaded at what
> runlevel for an NFS root (nor were the forums of great help -- additional
> documentation would be really appreciated).

I use the "netmount" init script in the boot runlevel. However, with the latest update of nfs-utils (net-fs/nfs-utils-1.0.12-r1 -> net-fs/nfs-utils-1.1.0-r1) I had to add "nolock" option to nfs fstab entries, because without this the "netmount" complained about missing rpc.statd service and does not mount the NFS filesystems. So I would also be glad to hear from some experts how to setup NFS services in Gentoo for mounting root file system via NFS.

BR,
/Adam