Unix Technical Forum

Root on NFS with separate filesystems for /bin, /sbin,...

This is a discussion on Root on NFS with separate filesystems for /bin, /sbin,... within the Linux Operating System forums, part of the Unix Operating Systems category; --> Hi, I'm trying to build a diskless linux box, booting through tftp and with root on NFS from another ...


Go Back   Unix Technical Forum > Unix Operating Systems > Linux Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008, 06:43 PM
Bob
 
Posts: n/a
Default Root on NFS with separate filesystems for /bin, /sbin,...

Hi,

I'm trying to build a diskless linux box, booting through tftp and with root
on NFS from another linux box. I would like to have the diskless box use the
same kernel and the same /sbin, /bin and /lib as the server, so that
upgrades to the server are automatically propagated to the diskless box.

Therefore the /sbin, /bin and /lib directories are not in the root
filesystem of the diskless box, but instead mounted read-only from the
server's /bin,.. by NFS. Problem is that the diskless box tries to boot with
only the root filesystem mounted and cannot find /sbin/init for example.

Is there a way to force additional filesystems to be mounted before
/sbin/init is run? Of course /bin/mount is not available either but maybe
there's an additional boot option which could do this?

I figured initrd was meant to overcome just these kinds of problems. So I
got the diskless box to boot using the server's initrd image. But somehow it
then tries to boot from the server's IDE RAID partitions, even though I pass
'root=/dev/nfs' as a boot parameter. So apparently the initrd overrules the
'root=' parameter? I don't understand this. Do I need to prepare a special
initrd for the diskless box and can I do this on the server?

Of course I could just copy the server's /bin,.. directories to the root
filesystem of the diskless box (tried and it works) but I'd prefer to mount
them from the server.

Would appreciate even the smallest hint. Thanks,

Bob

PS: running debian sarge, devfs enabled.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-17-2008, 06:43 PM
Menno Duursma
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...

On Mon, 26 Jan 2004 11:53:33 +0100, Bob wrote:

> Hi,


Hello.

> I'm trying to build a diskless linux box, booting through tftp and with root
> on NFS from another linux box. I would like to have the diskless box use the
> same kernel and the same /sbin, /bin and /lib as the server, so that
> upgrades to the server are automatically propagated to the diskless box.


[...]

> Of course I could just copy the server's /bin,.. directories to the root
> filesystem of the diskless box (tried and it works) but I'd prefer to mount
> them from the server.


Then try "mount --bind /bin /path/to/nfs/export". On failing that, try
"--rbind" (which i never used) or, making some links.

> Would appreciate even the smallest hint. Thanks,


man mount
man ln

> Bob
>
> PS: running debian sarge, devfs enabled.


That's fine.

--
-Menno.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-17-2008, 06:43 PM
Harry Phillips
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...

Bob wrote:
> Hi,
>
> I'm trying to build a diskless linux box, booting through tftp and with root
> on NFS from another linux box. I would like to have the diskless box use the
> same kernel and the same /sbin, /bin and /lib as the server, so that
> upgrades to the server are automatically propagated to the diskless box.
>


Check out the "Linux Terminal Server Project" at http://www.ltsp.org

--
Regards,
Harry Phillips
--- Failure is not an option,
it comes bundled with your Microsoft product.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-17-2008, 06:44 PM
root
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...

On Mon, 26 Jan 2004 11:53:33 +0100, Bob wrote:

> Hi,
>
> I'm trying to build a diskless linux box, booting through tftp and with
> root on NFS from another linux box. I would like to have the diskless box
> use the same kernel and the same /sbin, /bin and /lib as the server, so
> that upgrades to the server are automatically propagated to the diskless
> box.
>
> Therefore the /sbin, /bin and /lib directories are not in the root
> filesystem of the diskless box, but instead mounted read-only from the
> server's /bin,.. by NFS. Problem is that the diskless box tries to boot
> with only the root filesystem mounted and cannot find /sbin/init for
> example.
>
> Is there a way to force additional filesystems to be mounted before
> /sbin/init is run? Of course /bin/mount is not available either but maybe
> there's an additional boot option which could do this?
>
> I figured initrd was meant to overcome just these kinds of problems. So I
> got the diskless box to boot using the server's initrd image. But somehow
> it then tries to boot from the server's IDE RAID partitions, even though I
> pass 'root=/dev/nfs' as a boot parameter. So apparently the initrd
> overrules the 'root=' parameter? I don't understand this. Do I need to
> prepare a special initrd for the diskless box and can I do this on the
> server?
>
> Of course I could just copy the server's /bin,.. directories to the root
> filesystem of the diskless box (tried and it works) but I'd prefer to
> mount them from the server.
>
> Would appreciate even the smallest hint. Thanks,
>


Hard links ???

ln not ln -s ???

Make a directory in the tree for the new client, then hard-link in what
you want from the existing structure .....

That way you get a single mount point for the diskless client. Just an
idea.

Jon


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-17-2008, 06:44 PM
Bob
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...

> > Of course I could just copy the server's /bin,.. directories to the root
> > filesystem of the diskless box (tried and it works) but I'd prefer to

mount
> > them from the server.

>
> Then try "mount --bind /bin /path/to/nfs/export". On failing that, try
> "--rbind" (which i never used) or, making some links.


But then the diskless box would have write access to /bin on the server,
which I want to avoid.

I tried to add the -r or -oro options to the mount command, but these are
apparently ignored with --bind and it's still remounted read/write. Same
problem of course if I use hard links.

Ideally, the root filesystem of the diskless box is mounted read/write, and
/bin, /sbin, /lib and /usr mounted read-only.

Thanks
Bob


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-17-2008, 06:44 PM
Robert Nichols
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...

In article <bv2rje$1u5$1@news.cistron.nl>, Bob <nospam@nospam.com> wrote:
:
:I'm trying to build a diskless linux box, booting through tftp and with root
n NFS from another linux box. I would like to have the diskless box use the
:same kernel and the same /sbin, /bin and /lib as the server, so that
:upgrades to the server are automatically propagated to the diskless box.
:
:Therefore the /sbin, /bin and /lib directories are not in the root
:filesystem of the diskless box, but instead mounted read-only from the
:server's /bin,.. by NFS. Problem is that the diskless box tries to boot with
nly the root filesystem mounted and cannot find /sbin/init for example.
:
:Is there a way to force additional filesystems to be mounted before
:/sbin/init is run? Of course /bin/mount is not available either but maybe
:there's an additional boot option which could do this?

No practical way to do that early mounting, AFAIK. What you _can_ do
is give the diskless client its own minimal /sbin, /bin, and /lib
directories in its root file system and then mount the server's
directories over those once NFS is running. You could then restart
any services that had been started from the original binaries and even
execute "init U" to replace the running init binary if need be (not
that init gets updated very often).

Have you thought about how you'll handle /lib/modules?

--
Bob Nichols AT interaccess.com I am "rnichols"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-17-2008, 06:44 PM
Bill Marcum
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...

["Followup-To:" header set to alt.os.linux.]
On Mon, 26 Jan 2004 11:53:33 +0100, Bob
<nospam@nospam.com> wrote:
> Hi,
>
> I'm trying to build a diskless linux box, booting through tftp and with root
> on NFS from another linux box. I would like to have the diskless box use the
> same kernel and the same /sbin, /bin and /lib as the server, so that
> upgrades to the server are automatically propagated to the diskless box.
>
> Therefore the /sbin, /bin and /lib directories are not in the root
> filesystem of the diskless box, but instead mounted read-only from the
> server's /bin,.. by NFS. Problem is that the diskless box tries to boot with
> only the root filesystem mounted and cannot find /sbin/init for example.
>
> Is there a way to force additional filesystems to be mounted before
> /sbin/init is run? Of course /bin/mount is not available either but maybe
> there's an additional boot option which could do this?
>

Create /bin and /sbin directories containing only the files needed to
boot, then later you can mount the filesystems from the server.

--
Absurd Procrustean Egghead Cornstarch Variant Bill Marcum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-17-2008, 06:44 PM
Bob
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...

> No practical way to do that early mounting, AFAIK. What you _can_ do
> is give the diskless client its own minimal /sbin, /bin, and /lib
> directories in its root file system and then mount the server's
> directories over those once NFS is running.


That's what I ended up doing, it works now!

So here's my diskless-client-with-root-on-nfs-and-binaries-from-server
mini-howto:

Minimal root filesystem for diskless client (mounted over nfs at boot time):
# ls -lR bin sbin lib
bin:
total 712
-rwxr-xr-x 1 root root 628684 Jan 26 19:40 bash
-rwxr-xr-x 1 root root 12216 Jan 26 19:40 echo
-rwsr-xr-x 1 root root 76888 Jan 26 19:40 mount

lib:
total 1688
-rwxr-xr-x 1 root root 90144 Jan 26 19:44 ld-linux.so.2
-rw-r--r-- 1 root root 1243076 Jan 26 19:44 libc.so.6
-rw-r--r-- 1 root root 9796 Jan 26 19:48 libdl.so.2
-rw-r--r-- 1 root root 254544 Jan 26 19:46 libncurses.so.5
-rw-r--r-- 1 root root 73452 Jan 26 19:51 libnsl.so.1
-rw-r--r-- 1 root root 25860 Jan 26 19:49 libwrap.so.0

sbin:
total 132
-rwxr-xr-x 1 root root 57612 Jan 26 19:39 ifconfig
-rwxr-xr-x 1 root root 279 Jan 26 20:06 init2 (see below)
-rwxr-xr-x 1 root root 11920 Jan 26 19:40 portmap
-rwxr-xr-x 1 root root 46680 Jan 26 19:39 route

etc:
(cp -a initially from /etc of the nfs server, edit fstab and the network
scripts)

var:
(copy from the server)


init2 contains:
#!/bin/bash

/bin/echo "this is init2:"
/bin/mount /proc
/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
/sbin/portmap
/bin/mount /sbin
/bin/mount /usr
/bin/mount /lib
/bin/mount /bin
/usr/bin/killall portmap
exec /sbin/init

(/sbin, /usr,.. are listed in fstab). This mounts the real /bin,...
directories over the minimalist ones.


Pass an init=/sbin/init2 paramater to the kernel when booting. I used
PXELINUX; this is my /tftpboot dir:

# ls -lR /tftpboot
/tftpboot/:
total 16
-rw-r--r-- 1 root root 11168 Jun 11 2003 pxelinux.0
drwxr-xr-x 2 root root 4096 Jan 27 10:18 pxelinux.cfg

/tftpboot/pxelinux.cfg:
total 2556
-rw-r--r-- 1 root root 239 Jan 27 10:18 default
-rw-r--r-- 1 root root 11168 Jun 11 2003 pxelinux.0
-rw-r--r-- 1 root root 1294839 Jan 26 08:47 vmlinuz-2.6.0


/tftpboot/pxelinux.cfg/default contains this:
prompt 1
default boot_tftp
display messages
timeout 5
label boot_tftp
kernel /pxelinux.cfg/vmlinuz-2.6.0
append root=/dev/nfs nfsroot=192.168.10.1:/nfsroot/<my root
dir>,rsize=8192,wsize=8192,rw ip=dhcp init=/sbin/init2


ISC dhcpd3 config contains:
group {
next-server 192.168.10.1;
filename "/pxelinux.0";
host my_diskless_client_1 {
hardware ethernet 00:40:63:........;
fixed-address 192.168.10.240;
}
}


Kernel should have compiled-in support for the network card, IP kernel level
autoconfiguration (DHCP), NFS and root-on-NFS.

I've been looking for the 'root-on-nfs' option in the kernel config for
hours; it turned out to be visible only if IP autoconfiguration is enabled..

Hope this helps somebody else.
Bob


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-17-2008, 06:49 PM
wb
 
Posts: n/a
Default Re: Root on NFS with separate filesystems for /bin, /sbin,...



Bob wrote:

> Kernel should have compiled-in support for the network card, IP kernel level
> autoconfiguration (DHCP), NFS and root-on-NFS.
>
> I've been looking for the 'root-on-nfs' option in the kernel config for
> hours; it turned out to be visible only if IP autoconfiguration is enabled..
>
> Hope this helps somebody else.
> Bob
>
>


Hi Bob,
Glad to hear your good progress.

FYI however,

You may want to visit:

the Etherboot-users@lists.sourceforge.net mailing list

project and

Linux Terminal Server Project" at http://www.ltsp.org

And poke around.

At one time ( last year) there was pressure to remove the
root/NFS/DHCP support from upcoming releases .. and I haven't followed
the result of the conflict.

What Kernel are you running ?


Good Luck.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com