Bug 47934

Summary: /etc/rc.diskless1 does not get valid mem disk size, mount fails
Product: Base System Reporter: chris <chris>
Component: i386Assignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.7-STABLE   
Hardware: Any   
OS: Any   

Description chris 2003-02-05 03:20:09 UTC
I was setting up a diskless client, using dhcpd to get info then
booting pxeboot then a kernel created for DISKLESS per a combination
of instructions in the handbook and Luigi's notes in the
/usr/share/examples/clone_root script.

The client gets an /etc/rc.diskless which fails to mount volumes
such as /var, which it's supposed to create and mount as a "memory
disk".

It's supposed to default to 4MB but this fails, and it's supposed to
be overridden by a "md_size" file in the template partition, but that
failst the same way. I don't see anywhere in the script where it
$md_size_$1 is set before invoking create_md() but the logic is
comparing "$md_size_$1" = "x" and thus erroneously compares "var" with
"x" and thus doesn't get the default.

Fix: 

I have a gross work-around that just jams a value into md_size before
doing the mount, but this isn't really a fix.

    create_md() {
	echo "RC.DISKLESS1 CREATE_MD='$1' size='$md_size_$1'"	
	if [ "x`eval echo \\$md_created_$1`" = "x" ]; then
	    if [ "x`eval echo \$md_size_$1`" = "x" ]; then
		md_size=8192
	    else
		md_size=`eval echo \\$md_size_$1`
	    fi
->	    # Force the size since we can't get it reliably!!
->	    md_size=8192
	    mount_md $md_size /$1
	    /bin/chmod 755 /$1
	    eval md_created_$1=created
	fi
    }
How-To-Repeat: 
execute $ROOT/etc/rc.diskless1 and see complaint:

    mount_mfs: /etc: bad file system size
Comment 1 732 2003-02-06 10:24:12 UTC
yep, i got this too. fix is trivial, we're just missing a backslash in 
the eval:

[lemon@yes ~]$ diff -u /etc/rc.diskless1 /tmp/rc.diskless1
--- /etc/rc.diskless1   Wed Feb  5 22:54:36 2003
+++ /tmp/rc.diskless1   Thu Feb  6 10:12:55 2003
@@ -83,7 +83,7 @@
  #
  create_md() {
      if [ "x`eval echo \\$md_created_$1`" = "x" ]; then
-       if [ "x`eval echo \$md_size_$1`" = "x" ]; then
+       if [ "x`eval echo \\$md_size_$1`" = "x" ]; then
             md_size=8192
         else
             md_size=`eval echo \\$md_size_$1`
Comment 2 Pawel Malachowski 2003-08-23 10:54:30 UTC
> yep, i got this too. fix is trivial, we're just missing a backslash in
> the eval:

Seems proposed patch was applied and PR can be closed (PR conf/49119
is already closed).

http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/Attic/rc.diskless1.diff?r1=1.5.2.10&r2=1.5.2.11&f=h


-- 
Pawe³ Ma³achowski
Comment 3 Simon L. B. Nielsen freebsd_committer freebsd_triage 2003-08-23 12:04:46 UTC
State Changed
From-To: open->closed

Close this PR since it indeed is a duplicate of conf/49119 which has 
been fixed. 

Thanks to Chris Shenton for the original submission, and thanks to 
Pawel Malachowski for letting us know that is PR can be closed.