<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Felipe Alfaro Solana &#187; NFS</title>
	<atom:link href="http://www.felipe-alfaro.org/blog/category/nfs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.felipe-alfaro.org/blog</link>
	<description>A little bit of technology, security and networking with Linux, FreeBSD and Mac OS X, plus some personal opinions.</description>
	<lastBuildDate>Sun, 23 Oct 2011 16:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Configuring a diskless Ubuntu</title>
		<link>http://www.felipe-alfaro.org/blog/2007/12/09/configuring-a-diskless-ubuntu/</link>
		<comments>http://www.felipe-alfaro.org/blog/2007/12/09/configuring-a-diskless-ubuntu/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 02:30:02 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[DHCP]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[PXE]]></category>
		<category><![CDATA[TFTP]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.felipe-alfaro.org/blog/2007/12/09/configuring-a-diskless-ubuntu/</guid>
		<description><![CDATA[This post is not about doing a PXE-based network installation of Ubuntu. There are already many posts describing how to do this. This post is about setting up an Ubuntu workstation in diskless mode, such as the workstation boots via PXE and the root filesystem is mounted over NFS. The process consists on the following [...]]]></description>
			<content:encoded><![CDATA[<p>This post is not about doing a PXE-based network installation of Ubuntu. There are already many posts describing how to do this. This post is about setting up an Ubuntu workstation in diskless mode, such as the workstation boots via PXE and the root filesystem is mounted over NFS.</p>
<p>The process consists on the following main steps:</p>
<ol>
<li>Setting up the DHCP server</li>
<li>Setting up the TFTP server and configuring PXE boot</li>
<li>Setting up the NFS server</li>
<li>Bootstrapping a Ubuntu installation into the client&#8217;s root filesystem</li>
<li>Booting up the diskless workstation</li>
</ol>
<h2>1. Setting up the DHCP server</h2>
<p>PXE-enabled workstations need to get an additional option during the DHCP negotiation that will point them to a TFTP server where the PXE-compatible boot loader code can be downloaded. Configuring <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html"><code>dnsmasq</code></a> to hand this option to clients is just as easy as adding the following line to <code>/etc/dnsmasq.conf</code>:</p>
<div>
<pre>
dhcp-boot=pxelinux.0,tftp.lan,10.42.242.13
</pre>
</div>
<p>and restarting the <code>dnsmasq</code> service.</p>
<h2>2. Setting up the TFTP server and configuring PXE boot</h2>
<p>Now that DHCP has been configured, the next step is setting up the TFTP server. The TFTP server will be used by PXE-compatible clients to download the PXE boot loader code, and also the Linux kernel and Linux initial RAM disk.</p>
<p>I will use H. P. Anvin&#8217;s TFTP server as it&#8217;s widely used and works fairly well:</p>
<div>
<pre>
root@tftp.lan:# apt-get install tftpd-hpa
</pre>
</div>
<p><code>tftpd-hpa</code> does not integrate automatically with <code>xinetd</code> so if you want to run the TFTP server under <code>xinetd</code>, you will have to create the following file, which was ported from the <code>inetd</code> description that is created automatically in <code>/etc/inetd.conf</code> when <code>tftpd-hpa</code> is installed:</p>
<div>
<pre>
service tftp
{
        disable         = no
        id              = chargen-dgram
        socket_type     = dgram
        protocol        = udp
        user            = root
        wait            = yes
        server          = /usr/sbin/in.tftpd
        server_args     = -s /var/lib/tftpboot/
}
</pre>
</div>
<p>then restarting the <code>xinetd</code> service.</p>
<p>Configuring PXE boot is just a matter of copying the PXE boot loader code, a configuration file, the Linux kernel and initial RAM disks under the TFTP root. First, install <code>syslinux</code> and copy the PXE boot loader code to the TFTP server root:</p>
<div>
<pre>
root@tftp.lan:# apt-get install syslinux
root@tftp.lan:# cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot/
root@tftp.lan:# mkdir /var/lib/tftpboot/pxelinux.cfg
</pre>
</div>
<p>The Linux PXE boot loader code, <code>syslinux</code>, expects that a configuration file describing what kernel, its boot parameters, and the initial RAM disk to use to be stored within a directory named <code>pxelinux.cfg</code> just under the TFTP server root.</p>
<p>Client-specific config files can be created (based on the client MAC address, for example). We will create a config file that is suitable for any client. This configuration file is called <code>default</code> and can be created by running the following commands:</p>
<div>
<pre>
root@tftp.lan:# KERNEL_VERSION=2.6.22-14-generic
root@tftp.lan:# NFS_IPADDR=$(host nfs.lan | cut -d' ' -f4)
root@tftp.lan:# cat &gt; /var/lib/tftpboot/pxelinux.cfg/default &lt;&lt; EOF
> LABEL linux
> KERNEL vmlinuz-${KERNEL_VERSION}
> APPEND root=/dev/nfs initrd=initrd.img-${KERNEL_VERSION} nfsroot=${NFS_IPADDR}:/home/nfsroot ip=dhcp rw
> EOF
</pre>
</div>
<h2>3. Setting up the NFS server</h2>
<p>In this step, we will configure the NFS server and export the directory where the client&#8217;s root filesystem will be stored.</p>
<p>Let&#8217;s start by installing the NFS server packages:</p>
<div>
<pre>
root@nfs.lan:# apt-get install nfs-kernel-server nfs-common
</pre>
</div>
<p>I will use <code>/home/nfsroot</code> as the root for the client&#8217;s root filesystem</p>
<div>
<pre>
root@nfs.lan:# mkdir /home/nfsroot
</pre>
</div>
<p>Next, add the following line to <code>/etc/exports</code> in order to export the the client&#8217;s root filesystem:</p>
<div>
<pre>
/home/nfsroot *,gss/krb5(rw,no_subtree_check,async,no_root_squash)
</pre>
</div>
<p>Then re-export all the filesystems:</p>
<div>
<pre>
root@nfs.lan:# exportfs -avr
</pre>
</div>
<h2>4. Bootstrapping a Ubuntu installation into the client&#8217;s root filesystem</h2>
<p>The following steps will bootstrap the installation of a minimal Ubuntu Hardy Heron GNU/Linux system into the client&#8217;s root:</p>
<div>
<pre>
root@nfs.lan:# debootstrap --arch i386 hardy \
  /home/nfsroot http://ch.archive.ubuntu.com/ubuntu/
</pre>
</div>
<p>Only the minimum required packages will be downloaded from the Internet and installed into <code>/home/nfsroot</code>. The output of the previous command should look like this:</p>
<div>
<pre>
I: Retrieving Release
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...
I: Found additional required dependencies: libdb4.6
I: Checking component main on http://ch.archive.ubuntu.com/ubuntu...
I: Retrieving adduser
I: Validating adduser
...
I: Base system installed successfully.
</pre>
</div>
<p>Once the system has been bootstrapped, we need to populate <code>fstab</code>. At least, <code>/proc</code> and <code>/</code> must get mounted, but other filesystems might be referenced in this file too, like additional NFS exports, swap files, and so on. The difference with respect a traditional, disk-based Ubuntu installation, is that the root filesystem gets mounted via NFS by the intial RAM disk, and is referenced by the kernel&#8217;s <code>/dev/nfs</code> block device.</p>
<p>The contents of <code>/home/nfsroot/etc/fstab</code> should look like this:</p>
<div>
<pre>
# /etc/fstab: static file system information.
#
# &lt;file system&gt; &lt;mount point&gt; &lt;type&gt; &lt;options&gt; &lt;dump&gt; &lt;pass&gt;
proc            /proc         proc   defaults       0      0
/dev/nfs        /             nfs    defaults       0      0
</pre>
</div>
<p>Another difference with a traditional Ubuntu system is that we don&#8217;t want the network interfaces be managed by Network Manager. In fact, the main (probably Ethernet) network interface was already configured by the kernel based on PXE&#8217;s supplied configuration. Letting Nework Manager reconfigure or manage this network interface might mean losing the connection to the NFS server and, thus, rendering the system unusable.</p>
<p>To stop Network Manager from managing the main network interface, the contents of <code>/home/nfsroot/etc/network/interfaces</code> must look like this:</p>
<div>
<pre>
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface, commented out for NFS root
iface eth0 inet manual
</pre>
</div>
<p>Finally, we will give the client a generic name. This can be done by storing that generic name into /etc/hostname:</p>
<div>
<pre>
root@nfs.lan:# echo client.lan &gt; /home/nfsroot/etc/hostname
</pre>
</div>
<h2>Booting up the diskless workstation</h2>
<p>Once everything is set up, the last thing to do is testing that the diskless workstation is able to boot via PXE. The mechanics of booting via PXE depend on the machine. On some machines, it&#8217;s just a matter of pressing ESC to get into a menu that allows to override the boot device. On others, the same can be done by pressing F12 during the POST. On most modern systems it&#8217;s possible to reconfigure the system to always boot from the network.</p>
<p>If the client is able to boot from PXE successfully, this is what you will briefly see on your screen:</p>
<div>
<pre>
CLIENT MAC ADDR: 00 11 22 33 44 55 66  GUID: 00000000 0000 0000 0000 000000000000
CLIENT IP: 192.168.0.2  MASK: 255.255.255.0  DHCP IP: 192.168.0.1
GATEWAY IP: 192.168.0.1

PXELNUX 3.36 Debian-2007-08-30  Copyright (C) 1994-2007 H. Peter Anvin
UNDI data segment at:   00094140
UNDI data segment size: 94B0
UNDI code segment at:   0009D5F0
UNDI code segment size: 20B0
PXE entry point found (we hope) at 9D5F:0106
My IP address seems to be C0A80001 192.168.0.2
ip=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0
TFTP prefix:
Tring to load: pxelinux.cfg/00-01-02-03-04-05
Tring to load: pxelinux.cfg/C0A80001
Tring to load: pxelinux.cfg/C0A8000
Tring to load: pxelinux.cfg/C0A800
Tring to load: pxelinux.cfg/C0A80
Tring to load: pxelinux.cfg/C0A8
Tring to load: pxelinux.cfg/C0A
Tring to load: pxelinux.cfg/C0
Tring to load: pxelinux.cfg/C
Tring to load: pxelinux.cfg/default
boot:
Loading vmlinuz...
</pre>
</div>
<p>If the system boots up, we will be dropped into a text-mode console where we can log in as <code>root</code> with no password. Of course, the first thing you should do is creating a password for the <code>root</code> user, but if you have been able to get to this point, you probably know how to do it <img src='http://www.felipe-alfaro.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Once you are logged in as your in your new diskless workstation, you will probably want to add more functionality. For example, installing the <a href="http://www.openssh.org">OpenSSH</a> server, or the packages for the typical Ubuntu desktop system. Before you do that, we will need to add more Ubuntu repositories to <code>/etc/apt/sources.list</code>. This is how mine looks like:</p>
<div>
<pre>
deb http://ch.archive.ubuntu.com/ubuntu/ feisty main restricted
deb-src http://ch.archive.ubuntu.com/ubuntu/ feisty main restricted
deb http://ch.archive.ubuntu.com/ubuntu/ feisty-updates main restricted
deb-src http://ch.archive.ubuntu.com/ubuntu/ feisty-updates main restricted
deb http://ch.archive.ubuntu.com/ubuntu/ feisty universe
deb-src http://ch.archive.ubuntu.com/ubuntu/ feisty universe
deb http://ch.archive.ubuntu.com/ubuntu/ feisty multiverse
deb-src http://ch.archive.ubuntu.com/ubuntu/ feisty multiverse
deb http://ch.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse
deb-src http://ch.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu feisty-security main restricted
deb-src http://security.ubuntu.com/ubuntu feisty-security main restricted
deb http://security.ubuntu.com/ubuntu feisty-security universe
deb-src http://security.ubuntu.com/ubuntu feisty-security universe
deb http://security.ubuntu.com/ubuntu feisty-security multiverse
deb-src http://security.ubuntu.com/ubuntu feisty-security multiverse
</pre>
</div>
<p>Finally, I decided to install OpenSSH, OpenNTPD and the typical Ubuntu desktop:</p>
<div>
<pre>
root@client.lan:# apt-get update
root@client.lan:# apt-get install openssh-server openntpd ubuntu-desktop
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2007/12/09/configuring-a-diskless-ubuntu/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Leopard, NFS, Automounter and Finder</title>
		<link>http://www.felipe-alfaro.org/blog/2007/11/21/leopard-nfs-automounter-and-finder/</link>
		<comments>http://www.felipe-alfaro.org/blog/2007/11/21/leopard-nfs-automounter-and-finder/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 00:32:34 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[NFS]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2007/11/21/leopard-nfs-automounter-and-finder/</guid>
		<description><![CDATA[The AutoFS service in Leopard, also known as automount, is configured by means of text files stored in /etc and the automount command-line utility. The standard automount configuration also allows for local directory service lookups and thus can also be configured by using Directory Utility. The configuration of the automounter starts with the master configuration [...]]]></description>
			<content:encoded><![CDATA[<p>The AutoFS service in Leopard, also known as <code>automount</code>, is configured by means of text files stored in <code>/etc</code> and the <code>automount</code> command-line utility. The standard <code>automount</code> configuration also allows for local directory service lookups and thus can also be configured by using Directory Utility.</p>
<p>The configuration of the automounter starts with the master configuration file, <code>/etc/auto_master</code> The contents of this file look like this:</p>
<div>
<pre>
#
# Automounter master map
#
+auto_master		# Use directory service
/net			-hosts		-nobrowse,nosuid
/home			auto_home	-nobrowse
/Network/Servers	-fstab
/-			-static
</pre>
</div>
<p>Here is a brief description of each one:</p>
<ul>
<li>
<code>/net			-hosts		-nobrowse,nosuid</code></p>
<p>This configures automount of NFS servers in <code>/net</code>. Automounting is done for any resolvable host name (it doesn&#8217;t have to have an entry in <code>/etc/hosts</code> and it&#8217;s browsable under <code>/net</code>. The problem is that <code>/net</code> is not linked from the sidebar in Finder, and thus not very useable except from the command-line.</p>
</li>
<li>
<code>/home			auto_home	-nobrowse</code></p>
<p>This configures automounting of home directories via a directory service, as configured in <code>/etc/auto_home</code>.
</li>
<li>
<code>/Network/Servers	-fstab</code></p>
<p>This line states that all mount entries defined in <code>/etc/fstab</code> should be mounted in <code>/Network/Servers</code>. However, this is not entirely true  as mount entries listed in <code>/etc/fstab</code> have to specify an absolute mount point, or else <code>automount</code> will complain. Since mount entries specify an absolute mount point, and it won&#8217;t be overridden by <code>automount</code><code>, in order to make Finder show the entries in the sidebar it is recommended that the mount point is located in a subdirectory within </code><code>/Networ/</code>.</p>
<p>For example, this how my <code>/etc/fstab</code> file looks like:</p>
<div>
<pre>
media:/export /Network/media nfs nosuid,nodev 0 0
</pre>
</div>
</li>
<li>
<code>/-			-static</code></p>
<p>This entry is very similar to the previous one, but instead of using <code>/etc/fstab</code> as the source of mount entries, this one uses the local directory service instead. Entries can be configured using Directory Utility, and stored as a plist file in <code>/var/db/dslocal/nodes/Default/mounts</code>.</p>
<p>Here is an example of a file named <code>/var/db/dslocal/nodes/Default/mounts/media.lan\:%2Fexport.plist</code>:</p>
<div>
<pre>
&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
	&lt;key&gt;dir&lt;/key&gt;
	&lt;array&gt;
		&lt;string&gt;/Network/media&lt;/string&gt;
	&lt;/array&gt;
	&lt;key&gt;generateduid&lt;/key&gt;
	&lt;array&gt;
		&lt;string&gt;1895C8D3-7DBF-4857-8D61-04080DFA5B55&lt;/string&gt;
	&lt;/array&gt;
	&lt;key&gt;name&lt;/key&gt;
	&lt;array&gt;
		&lt;string&gt;media.lan:/export&lt;/string&gt;
	&lt;/array&gt;
	&lt;key&gt;opts&lt;/key&gt;
	&lt;array&gt;
		&lt;string>nosuid&lt;/string&gt;
		&lt;string>nodev&lt;/string&gt;
	&lt;/array&gt;
	&lt;key&gt;vfstype&lt;/key&gt;
	&lt;array&gt;
		&lt;string&gt;nfs&lt;/string&gt;
	&lt;/array&gt;
&lt;/dict&gt;
&lt;/plist&gt;
</pre>
</div>
</li>
</ul>
<p>Reloading the <code>automount</code> configuration is just as simple as running:</p>
<pre>automount -vc</pre>
<p><code>automount</code> will reload its configuration and will automatically mount any entry listed in <code>/etc/fstab</code>. Additionally, the Finder will display an <em>All&#8230;</em> link in the sidebar that makes very easy to get to the automounted volumes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2007/11/21/leopard-nfs-automounter-and-finder/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

