NFSv4 with User-Mode Linux

This page is about how to setup and run the Linux NFSv4 kernel implementation as a User-Mode Linux process. These steps below worked for me. (Note: (host) means that the commands should be executed on the host, while (uml) means that the commands should be executed in the UML system.)
  1. (host) Download and install the "UML kit" from The User-Mode Linux download page. For example, try user_mode_linux-2.4.18.36um-0.i386.rpm if you can deal with RPMs. This package contains a normal kernel, a set of userspace tools, kernel modules, and documentation.
  2. (host) Download a root filesystem. I recommend using a root filesystem which includes a full development environment. For example, try root_fs.rh-6.2-full.pristine.20020312.bz2. Bunzip2 this file, and make a link called root_fs to the file.
  3. (host) Try to boot the precompiled UML kernel. I use a commandline like this: /usr/bin/linux single eth0=tuntap,,,192.168.0.140 umid=citiuml
  4. (uml) Verify that the network works. On my system, I simple do service network start, which brings up the network in the UML system, and creates a tap0 interface in the host system. Try to ping the UML system from the host, and the other way around. With the root filsystem root_fs.rh-6.2-full.pristine.20020312.bz2, the UML IP will be 192.168.0.141.
  5. (host) Create a directory to be shared between the host and UML system:
    mkdir /citiuml
  6. (uml) Create a mountpoint the for shared directory:
    mkdir /citiuml
  7. (uml) Add this line to the top of /etc/rc.d/rc.sysinit: mount none /citiuml -t hostfs -o /citiuml
  8. (uml) Replace /lib/modules with a link:
    mv /lib/modules /lib/modules.org
    ln -s /citiuml/lib/modules /lib/modules
  9. (host) Compile a v4-enabled kernel. You should be able to follow the instructions on http://www.citi.umich.edu/projects/nfsv4/june_2002_rel, under "Download and install", with the following exceptions:
  10. (host) Try booting the new v4 kernel:
    ./linux single eth0=tuntap,,,192.168.0.140 umid=citiuml
  11. (host) Download the NFSv4 utilities and the Kerberos dist into /citiuml.
  12. (uml) The root filesystems misses make, byacc and libtermcap-devel. Install them, for example from ftp://ftp.funet.fi/pub/Linux/mirrors/redhat/redhat/linux/6.2/en/os/i386/RedHat/RPMS.
  13. The NFSv4 utilities needs header files from the Linux kernel. By using hostfs, it's possible to mount the v4 kernel tree into /usr/src/linux. Add this line to /etc/fstab:
    none /usr/src/linux hostfs /path/to/your/v4kernel
    
    Run mount -a.
  14. Change arcitecture of your kernel tree by running:
    make symlinks
    
  15. (uml) Compile Kerberos and the NFSv4 utilities in /citiuml, by following the instructions on http://www.citi.umich.edu/projects/nfsv4/june_2002_rel.
  16. (uml) Create an /etc/exports. See http://www.citi.umich.edu/projects/nfsv4/june_2002_rel/exports.html.
  17. (uml) Start the network and the v4 server:
     service network start
     service portmap start
     service nfs4 start
    

Notes

I use single-mode all the time, because the xterm-based virtual consoles does not work for me.

Make sure the user running "linux" has permissions in /citiuml.

If you want to re-compile the kernel or the kernel modules, you must change arcitecture of your kernel tree with:

make menuconfig ARCH=um

Running multiple UML instances

Sometimes it's useful to run multiple UML instances. For example, it's practical to run one server and one client "machine". This can be done by using UMLs copy-on-write (COW) layering capability. Quick setup:
  1. Rename root_fs to root_fs_backing
  2. Start the first machine with:
    ./linux single eth0=tuntap,,,192.168.0.140 umid=citiuml1 ubd0=root_fs_1,root_fs_backing
    
  3. Start the second machine with:
    ./linux single eth0=tuntap,,,192.168.0.140 umid=citiuml2 ubd0=root_fs_2,root_fs_backing
    
    (The argument ,root_fs_backing is only required the first time.)
  4. Change IP adress of one instance.

Links

www.nfsv4.org
NFS Version 4 Open Source Reference Implementation (The Linux v4 implementation)
The User-mode Linux Kernel Home Page

You can reach me via astrand at lysator dot liu dot se.

Valid HTML 4.0!