Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Sep 1995 19:38:44 +0200 (MET DST)
From:      Luigi Rizzo <>
To: (Seppo Kallio)
Subject:   Re: * Can I use DOS filesystem for SWAP? *
Message-ID:  <>
In-Reply-To: <v01530536ac7f411cc4ac@[]> from "Seppo Kallio" at Sep 15, 95 06:12:04 pm

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
> We have a lot of DOS PCs in labs and etc.
> The diskless FreeBSD+XFree would be a nice X server if it could swap to DOS
> file system file. Can FreeBSD use DOS file as SWAP space?

We have set up a configuration with shared root and /usr, and swap
on the windows swapfile. There are a few tricks to play to have a
shared root, while things are much easier for sharing /usr.  Note
that, to make things easy, I have to export the rootfs with root
read permissions. This is a security hole. To avoid this, you have
to change permissions to /sbin/init and find some better way to
access the master.passwd (maybe YP can help -- but I have never
used them).

You need to rebuild a kernel, as the default kernel does not have
MFS or "vn0".

Here follows a small step-by-step guide on what we did here. I
apologize for not producing this in .sgml format, but had no time
to learn the formatting instructions, and wanted to post these info
soon. Hope the details here can be useful, and somebody can include
them in the handbook.

Luigi Rizzo                     Dip. di Ingegneria dell'Informazione
email:       Universita' di Pisa
tel: +39-50-568533              via Diotisalvi 2, 56126 PISA (Italy)
fax: +39-50-568522    

Configuration of FreeBSD clients with shared / and /usr, swap on
local DOS filesystem



    Create/modify /etc/bootptab to include entries for the various
    clients. It is convenient to provade a template that can be
    shared between the various clients, e.g.

	#example bootptab 

    (remember to put the right values for "ha", the hardware
    address, and "ip", the ip address of the client.

    * Create a /tftpboot directory to hold the configuration files
      for the various clients [Note: many of the info in the config
      file could probably be derived from the parameters supplied
      by bootpd].
    * Create the cfg.xx.xx.xx.xx files in /tftpboot, for each of the
      clients, e.g.

	#example cfg.
	kernel /kernel

    * Modify /etc/inetd.conf to enable BOOTP and TFTP, e.g. add/uncomment
      the following lines

	#example inetd.conf
	bootps  dgram  udp wait root /usr/libexec/bootpd bootpd
	tftp  dgram  udp wait nobody /usr/libexec/tftpd tftpd -l /tftpboot

    * "kill -HUP" the inetd process


    * Modify /etc/exports to export the root and /usr directories for
      the clients, e.g.

	#example exports
	/usr /usr/diskless_root -ro -maproot=root:wheel client1 client2 ...

      Some operating systems (e.g. FreeBSD 2.X) allow you to define
      group of clients that have the same rights.

      WARNING: you are giving root access rights (although readonly) to
      all clients in the group. This is required, at least for the
      master.passwd file. If you don't like this, you have to use a
      different authentication mechanism (YP ?) 

    * kill -HUP the mountd process

  * Add, if necessary, the ip to hostname mappings for the clients
    in /etc/hosts.


    We assume that the clients share a (readonly) directory named
    /usr/diskless_root. The per-client files are in a separate
    filesystem, /var, which is mounted in a memory filesystem on each
    client and filled up at boot time.

    To create /usr/diskless_root, start as follows:

    * create a copy of the original rootfs:

	mkdir /usr/diskless_root
	cd /
	tar cvlf - . | ( cd /usr/diskless_root ; tar xvf - )

    * then do the following

	cd /usr/diskless_root
	mkdir dos	# mountpoint for the local dos filesystem
	/dev/MAKEDEV dev/vn0	# device entry for mfs

    * modify etc/sysconfig, by setting the following fields
      appropriately for the clients:
	+ network interfaces
	+ disable nfs_server and other services

    * modify etc/inetd.conf to remove unwanted services (e.g.

    * modify etc/fstab as appropriate for the clients. They should
      use NFS-mounted root and /usr, a dos partition, and a memory
      filesystem. Note that the root partition is specified as rw in
      the fstab, although exported readonly by the server.

	#example fstab
	...  /      nfs     rw             0   0                  /usr   nfs     ro             1   1
	/dev/wd0s1                      /dos   msdos   rw             0   0
	/dev/null                       /var   mfs     rw,-T=myformat 0   0

    * modify etc/disktab to add a myformat entry. This is used by
      mount_mfs to derive information on the size and geometry of the
      partition. These info could be probably given in "fstab", but I
      was too lazy to figure out the parameters.

	    :pb#12288:ob#0:tb=swap: \

    * move writable files into /var. Some files/directories in the
      root partition are moved to /var where they can be written.
      In /usr/diskless_root do the following:

	    mv tmp var/tmp
	    ln -s /var/tmp tmp
	    mv dev var/dev
	    ln -s /var/dev
	    mv root var/root
	    ln -s /var/root

    * Create a tar archive with all the files which go to the /var
      partition, as follows (within /usr/diskless_root):

	    tar cvf - var | gzip -9 > files.tgz

    * modify etc/rc to do some diskless-related actions: basically,
      identify a diskless machine, mount the filesystems in the right
      order, create the /var partition in /mfs, extract the files, etc.
      [IMHO, this change might well go into the standard rc]

	#example rc
	DISKLESS=NO	# default behaviour
	swapon -a
	if [ "x`hostname`" = "x" ] # netboot sets the hostname
		mount -a -t nonfs
		mount -a -t nomfs
		vnconfig - e /dev/vn0 /dos/windows/win386.swp swap
		mount -a -t mfs
		(cd /; gzcat files.tgz | tar xvf - )


    The kernel for a diskless machine should contain at least
    the following, non-standard, entrues:

	options         MFS                     #Memory Filesystem
	pseudo-device   vn   # Vnode driver

    plus all required devices for operation. Make a new kernel with the
    above options, and copy it to /usr/diskless_root/kernel


  The swap area can be built by creating a file of suitable size
  (same or bigger of what defined in "myformat" above). An example (in

	cd \windows
	echo "swapfile...." >a
	copy a+a+a+a b	# b=64
	copy b+b+b+b a	# b=256
	copy a+a+a+a b	# b=1K
	copy b+b+b+b a	# b=4K
	copy a+a+a+a b	# b=16K
	copy b+b+b+b a	# b=64K
	copy a+a+a+a b	# b=256K
	copy b+b+b+b a	# b=1M
	copy a+a+a+a b	# b=4M
	copy b+b+b win386.swp	# 12M
	del b

  Then you just have to run!

	Luigi Rizzo (

Want to link to this message? Use this URL: <>