Professional Web Applications Themes

Root on NFS with separate filesystems for /bin, /sbin,... - Linux Setup, Configuration & Administration

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 ...

  1. #1

    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.


    Bob Guest

  2. #2

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

    Bob wrote: 

    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.

    Harry Guest

  3. #3

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

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

    Hello.
     

    [...]
     

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

    man mount
    man ln
     

    That's fine.

    --
    -Menno.

    Menno Guest

  4. #4

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

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

    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


    root Guest

  5. #5

    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 [/ref]
    mount 
    >
    > Then try "mount --bind /bin /path/to/nfs/export". On failing that, try
    > "--rbind" (which i never used) or, making some links.[/ref]

    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


    Bob Guest

  6. #6

    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
    <com> wrote: 
    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 Mar
    Bill Guest

  7. #7

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

    In article <bv2rje$1u5$cistron.nl>, Bob <com> wrote:
    :
    :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?

    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"
    Robert Guest

  8. #8

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

    > No practical way to do that early mounting, AFAIK. What you _can_ do 

    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


    Bob Guest

Similar Threads

  1. Replies: 2
    Last Post: February 9th, 10:08 PM
  2. Replies: 4
    Last Post: August 14th, 07:40 AM
  3. root filesystems on a bootable USB CDROM
    By Byron A Jeff in forum Linux Setup, Configuration & Administration
    Replies: 2
    Last Post: June 28th, 01:09 PM
  4. /sbin to verbose
    By Tim Lance in forum Mac Applications & Software
    Replies: 0
    Last Post: June 24th, 12:52 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139