<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Stephen Foskett, Pack Rat &#187; UNIX Archives  &#8211; Stephen Foskett, Pack Rat</title>
	<atom:link href="http://blog.fosketts.net/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fosketts.net</link>
	<description>Understanding the accumulation of data</description>
	<lastBuildDate>Fri, 10 Feb 2012 17:40:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
			<item>
		<title>How To Write To Windows NTFS Drives In Mac OS X 10.6 &#8220;Snow Leopard&#8221;</title>
		<link>http://blog.fosketts.net/2010/11/29/write-windows-ntfs-drive-mac-os-106-snow-leopard/</link>
		<comments>http://blog.fosketts.net/2010/11/29/write-windows-ntfs-drive-mac-os-106-snow-leopard/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 16:19:42 +0000</pubDate>
		<dc:creator>Stephen</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Terabyte home]]></category>
		<category><![CDATA[10.3]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[Dave Cutler]]></category>
		<category><![CDATA[fstab]]></category>
		<category><![CDATA[GoFlex]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[mount_ntfs]]></category>
		<category><![CDATA[nano]]></category>
		<category><![CDATA[NTFS]]></category>
		<category><![CDATA[NTFS-3G]]></category>
		<category><![CDATA[Panther]]></category>
		<category><![CDATA[Paragon]]></category>
		<category><![CDATA[Seagate]]></category>
		<category><![CDATA[Snow Leopard]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.fosketts.net/?p=4420</guid>
		<description><![CDATA[One of the daily hassles of using Apple Macintosh computers is the incompatibilities that arise with the broad Microsoft Windows world. Individual files often require conversion, but what about whole disks? Apple has long supported the universal and simplistic FAT filesystem, and added read-only support for NTFS back in 2003 in OS X 10.3 "Panther". Third-party software like Paragon's NTFS or the free NTFS-3G driver enabled read/write support, but a native solution was more desirable. Although 10.6 "Snow Leopard" includes NTFS write support, it is disabled by default. In this post, I'll discuss methods for activating this native NTFS write support, as well as the pros and cons of doing so!]]></description>
			<content:encoded><![CDATA[<p>One of the daily hassles of using Apple Macintosh computers is the incompatibilities that arise with the broad Microsoft Windows world. Individual files often require conversion, but what about whole disks? Apple has long supported the universal and simplistic FAT filesystem, and added read-only support for NTFS back in 2003 in OS X 10.3 &#8220;Panther&#8221;. Third-party software like Paragon&#8217;s NTFS or the free NTFS-3G driver enabled read/write support, but a native solution was more desirable. Although 10.6 &#8220;Snow Leopard&#8221; includes NTFS write support, it is disabled by default. In this post, I&#8217;ll discuss methods for activating this native NTFS write support, as well as the pros and cons of doing so!</p>
<h3>Introducing NTFS</h3>
<p>A filesystem is the basic scheme for organizing data on a hard disk drive. The common FAT filesystem, supported by just about every operating system, is just too basic for modern operating systems. Microsoft introduced the advanced NTFS filesystem with their Windows NT operating system in 1993. Borrowing from OS/2&#8242;s HPFS and VMS&#8217; Files-11, NTFS is a <a rel="nofollow" href="http://en.wikipedia.org/wiki/Journalling_filesystem" >journalling filesystem</a> with many features, including <a rel="nofollow" href="http://en.wikipedia.org/wiki/POSIX" >POSIX</a> links, <a rel="nofollow" href="http://en.wikipedia.org/wiki/Fork_(filesystem)" >alternate data streams</a>, <a rel="nofollow" href="http://en.wikipedia.org/wiki/Sparse_file" >sparse files</a>, <a rel="nofollow" href="http://en.wikipedia.org/wiki/Data_compression" >compression</a>, and <a rel="nofollow" href="http://en.wikipedia.org/wiki/Encrypting_File_System" >encryption.</a></p>
<p>Although just about everything Microsoft produces is maligned by UNIX and Mac geeks, this hatred is unwarranted in the case of the many storage advances coming out of Redmond. Microsoft may be fairly criticized for producing expensive, proprietary systems, but they have dome some amazing things with disks, and NTFS is arguably one of the most advanced filesystems in wide usage. Much of this credit goes to Windows NT architect <a rel="nofollow" href="http://en.wikipedia.org/wiki/Dave_Cutler"  target="_blank">Dave Cutler</a>, who also led development of DEC VMS, the RISC concepts that became <a rel="nofollow" href="http://en.wikipedia.org/wiki/DEC_Alpha"  target="_blank">Alpha</a>, and Microsoft&#8217;s <a rel="nofollow" href="http://en.wikipedia.org/wiki/Azure_Services_Platform"  target="_blank">Azure</a> cloud platform.</p>
<p>Although every version of Windows supports evolutions of the old FAT filesystem, modern iterations increasingly require NTFS. Windows XP allowed either FAT32 or NTFS for booting; Windows Vista could be forced to boot from FAT32; Windows 7 requires NTFS. Therefore, most PC hard disk drives, including external USB drives, now come formatted with NTFS by default.</p>
<h3>NTFS on Mac OS X</h3>
<p>This leads to issues for Mac users, especially when they dual-boot with Boot Camp or buy external hard disk drives. As mentioned, all versions of Mac OS X since 10.3 &#8220;Panther&#8221; have included read-only NTFS support, but those wanting full access had two options:</p>
<ol>
<li><a href="http://www.paragon-software.com/home/ntfs-mac/"  target="_blank">Paragon Software&#8217;s</a> NTFS for Mac OS X is a full and supported read/write solution. Although available for purchase separately, many hard disk drives like the <a rel="nofollow" href="http://www.amazon.com/Seagate-FreeAgent-Ultra-Portable-External-STAA1000100/dp/B003ELOSI2%3FSubscriptionId%3DAKIAJYEMQAFREVFYOMPQ%26tag%3DPackrat-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB003ELOSI2" >Seagate GoFlex</a> now include a free copy of Paragon NTFS.</li>
<li>The open source <a href="http://www.tuxera.com/community/ntfs-3g-download/"  target="_blank">NTFS-3G</a> driver has also been ported to Mac OS X, allowing read/write support for free.</li>
</ol>
<p>Mac OS X 10.6 &#8220;Snow Leopard&#8221; adds a third alternative: Native read/write support for NTFS. But it&#8217;s not as simple as that. Although early betas enabled read/write support by default, it was limited once again to read-only in the final releases.</p>
<p>It is possible and even simple) to enable read/write support with the native Snow Leopard drivers, but this is definitely an &#8220;at your own risk&#8221; proposition. Users have reported kernel panics when using these methods, and although I have not heard of data corruption, it is possible as well.</p>
<h3>The Manual Method: mount_ntfs</h3>
<p>Making disks available is called &#8220;mounting&#8221; in UNIX geek-speak, and mount commands in modern operating systems are <a rel="nofollow" href="http://www.youtube.com/watch?v=kZnztwiWZo4"  target="_blank">like ogres</a>: They have many layers. Plug in a drive, and Mac OS X makes it available for you using a layer cake of commands, but the bottom-most command is &#8220;mount&#8221;. This simple command-line utility takes a few arguments and attaches a raw disk device to a point in the unified filesystem tree.</p>
<p>When presented an NTFS drive, Mac OS X calls a utility called mount_ntfs that resides in the /sbin directory, and we can call it, too. Although OS X always tells mount_ntfs to mount NTFS drives read-only, we can tell it to enable writing as well by using the &#8220;-o rw&#8221; flag.</p>
<p>There&#8217;s just one problem: Where should we connect the NTFS file system? Mac OS X automatically creates a new directory (called a &#8220;mount point&#8221; in UNIX-speak) in /Volumes with the name of the filesystem. For example, the GoFlex drive I bought yesterday mounts as &#8220;/Volumes/FreeAgent GoFlex Drive&#8221; by default. But mount_ntfs won&#8217;t create this mount point, so we have to do it.</p>
<p>Here are the steps to mount an NTFS drive read/write from the command line:</p>
<ol>
<li>Plug in the drive and let Mac OS X mount it read-only.</li>
<li>Look in Finder to see the name of the drive. For example, my drive mounts with the name &#8220;FreeAgent GoFlex Drive&#8221; and this is what shows up on the desktop and in Frinder under &#8220;Devices&#8221;.</li>
<li>Open the Terminal application to get command-line access. We&#8217;ll use &#8220;sudo&#8221; which executes commands as the administrator instead of a regular user.</li>
<li>Type the following command in Terminal to get necessary information about the drive. Use the drive name you see in Finder in place of &#8220;drive name&#8221;, and make sure to use quotation marks around it since Terminal treats un-quoted spaces as separators rather than part of the name.
<pre>diskutil info "/Volumes/drive name"</pre>
</li>
<li>Record the &#8220;Device Node&#8221; entry, which will look something like &#8220;/dev/disk4s1&#8243;. This is where the raw partition is mapped by the disk subsystem, and where the filesystem driver will read its data.</li>
<div id="attachment_4421" class="wp-caption aligncenter" style="width: 310px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; display: block; margin-right: auto; margin-left: auto;"><a href="http://static.fosketts.net/wp-content/uploads/2010/11/Diskutil-info-GoFlex.png" ><img class="size-medium wp-image-4421" title="Diskutil info GoFlex" src="http://static.fosketts.net/wp-content/uploads/2010/11/Diskutil-info-GoFlex-300x246.png" alt="" width="300" height="246" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">The diskutil command gives us the &quot;Node Name&quot;, which we&#39;ll need momentarily</p></div>
<li>Eject the drive, using option-click in Finder or with the hdiutil command in Terminal:
<pre>hdiutil eject "/Volumes/drive name"</pre>
</li>
<li>Now you must create the mount point again. Type the following:
<pre>sudo mkdir "/Volumes/drive name"</pre>
</li>
<li>Finally, use mount_ntfs to mount the drive read/write using the following command. Use the node name you spotted above and the mount point you just created:
<pre>sudo mount_ntfs -o rw /dev/disk?s? "/Volumes/drive name"</pre>
</li>
<li>When you&#8217;re done, you can use the Finder, the hdiutil command, or just about anything else to eject the drive. Make sure your mount point is deleted as well!</li>
</ol>
<p>This method is great for occasional NTFS use, which is frankly all Mac users should need. If you intend to use a drive frequently, I highly recommend reformatting it with the native HFS+ filesystem since it will be fully-supported by the operating system.</p>
<h3>The Per-Drive Method</h3>
<p>Let&#8217;s say you have an NTFS drive you frequently need to mount read/write and find the above method too much of a hassle. Maybe it&#8217;s your Boot Camp drive, or perhaps it&#8217;s a USB hard disk drive you share with a Windows-using colleague. It is possible to tell Mac OS X to always mount a given NTFS drive read/write using its native driver using the following commands. However, I recommend investing in the Paragon driver for this use case, since it&#8217;s fully-supported!</p>
<p>Like all UNIX systems, Mac OS X uses a configuration file to determine what it should do with certain drives. This file, called &#8220;fstab&#8221; and located in &#8220;/etc&#8221;, is not present by default but will override the &#8220;read-only&#8221; flag on a per-drive basis if found. This allows a drive to always be mounted read/write without any hassle.</p>
<ol>
<li>Get the drive name as in step 2 above.</li>
<li>Open Terminal and type the following command to edit the /etc/fstab file:
<pre>sudo nano /etc/fstab</pre>
</li>
<div id="attachment_4422" class="wp-caption aligncenter" style="width: 310px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; display: block; margin-right: auto; margin-left: auto;"><a href="http://static.fosketts.net/wp-content/uploads/2010/11/Nano-fstab.png" ><img class="size-medium wp-image-4422" title="Nano fstab" src="http://static.fosketts.net/wp-content/uploads/2010/11/Nano-fstab-300x211.png" alt="" width="300" height="211" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Adding a line in /etc/fstab will make Mac OS X always mount a single drive in read/write mode</p></div>
<li>&#8220;Nano&#8221; is a command-line editing program. Add the following line to the file (and don&#8217;t forget the quotes around the drive name if it contains spaces!)
<pre>LABEL="drive name" none ntfs rw</pre>
</li>
<li>Now type control-x to save and exit, type y for yes, and hit enter.</li>
<li>After a reboot, Mac OS X should automatically mount any drive with that label as read/write</li>
</ol>
<p>Note that this can also be done using the NTFS UUID of the drive, but this isn&#8217;t present on every drive to LABEL works better. Also, some <a rel="nofollow" href="http://forums.macrumors.com/showthread.php?t=785376"  target="_blank">have reported</a> needing multiple reboots to make it work. I have no idea why.</p>
<h3>The Permanent Universal Method</h3>
<p>It is also <a href="http://blog.navisidhu.com/53-ntfs-write-snow-leopard/"  target="_blank">possible</a> to permanently modify how Mac OS X calls the mount_ntfs command to always mount every NTFS drive in read/write mode. Again, I will point out that this isn&#8217;t necessarily a great idea since Apple doesn&#8217;t support using the driver in this way. But here it is!</p>
<ol>
<li>Open Terminal. We won&#8217;t need the drive name or Node Name since this applies to every NTFS drive.</li>
<li>Rename the mount_ntfs command to something else by typing the following:
<pre>sudo mv /sbin/mount_ntfs /sbin/mount_ntfs_orig</pre>
</li>
<li>Create a shell script called mount_ntfs using the Nano editor:
<pre>sudo nano /sbin/mount_ntfs</pre>
</li>
<li>This script will simply call mount_ntfs with the &#8220;-o rw&#8221; flag every time it&#8217;s used. Type the following in Nano:
<pre>#!/bin/sh
/sbin/mount_ntfs_orig -o rw "$@"</pre>
</li>
<li>Type control-x to save and exit, type y for yes, and hit enter.</li>
<li>Now we&#8217;ll fix the permissions on this new file so it&#8217;s owned by root and group wheel:
<pre>sudo chown root:wheel /sbin/mount_ntfs</pre>
</li>
<li>Finally, we make the shell script executable:
<pre>sudo chmod 755 /sbin/mount_ntfs</pre>
</li>
<li>Now every time OS X encounters an NTFS drive, it will mount it read/write by calling this script rather than the &#8220;mount_ntfs&#8221; executable it thinks it&#8217;s using.</li>
</ol>
<p>Note that future OS updates might &#8220;break&#8221; this method by replacing the /sbin/mount_ntfs command, or it could cause other issues. But it works for now and doesn&#8217;t even require a reboot.</p>
<h3>Stephen&#8217;s Stance</h3>
<p>I&#8217;m hesitant to recommend that casual Mac users employ any of these methods to access NTFS drives. Each requires superuser access and careful typing. You can easily mess up your system this way, and unsupported uses of the NTFS driver might result in data loss.</p>
<p>If you aren&#8217;t comfortable with this kind of mucking-about or intend to frequently write to NTFS drives, I highly suggest installing NTFS-3G or Paragon&#8217;s NTFS driver. In fact, the best method is simply to go buy a <a rel="nofollow" href="http://www.amazon.com/Seagate-FreeAgent-Ultra-Portable-External-STAA1000100/dp/B003ELOSI2%3FSubscriptionId%3DAKIAJYEMQAFREVFYOMPQ%26tag%3DPackrat-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB003ELOSI2" >Seagate GoFlex drive</a> and use the Paragon driver that comes with it!</p>
<p>But hackers and geeks like me want to know how to do this. This is why I decided to document it here.<br />
<blockquote>Note: Some of these links include affiliate codes that help pay for this blog. For example, <a href="http://www.amazon.com/gp/product/B002Y27P3M?ie=UTF8&tag=packrat-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B002Y27P3M" target="_blank">buying an Amazon Kindle with this link</a> sends a few bucks my way! But I don't write this blog to make money, and am happy to link to sites and stores that don't pay anything. I like Amazon and buy tons from them, but you're free to buy whatever and wherever you want.</blockquote></p>
<div id="crp_related"><h3>You might also want to read these other posts...</h3><ul><li><a href="http://blog.fosketts.net/2009/08/06/access-ntfs-volumes-mac/"  rel="bookmark" class="crp_title">Access NTFS Volumes On Your Mac</a></li><li><a href="http://blog.fosketts.net/2008/09/03/os-x-custom-drive-icons-2-boot-camp-ntfs/"  rel="bookmark" class="crp_title">OS X Custom Drive Icons 2: Boot Camp and NTFS</a></li><li><a href="http://blog.fosketts.net/2008/08/27/custom-drive-icons-mac-os-x/"  rel="bookmark" class="crp_title">Custom Drive Icons in Mac OS X</a></li><li><a href="http://blog.fosketts.net/2010/07/26/boot-snow-leopard-64bit-mode/"  rel="bookmark" class="crp_title">How To Boot Snow Leopard in 64-Bit Mode</a></li><li><a href="http://blog.fosketts.net/2008/07/31/windows-server-2008-changes-storage/"  rel="bookmark" class="crp_title">Windows Server 2008 Changes Storage</a></li></ul></div><script src="http://feeds.feedburner.com/~s/sfoskett?i=http://blog.fosketts.net/2010/11/29/write-windows-ntfs-drive-mac-os-106-snow-leopard/" type="text/javascript" charset="utf-8"></script><hr />
<p><small>© sfoskett for <a href="http://blog.fosketts.net">Stephen Foskett, Pack Rat</a>, 2010. |
<a href="http://blog.fosketts.net/2010/11/29/write-windows-ntfs-drive-mac-os-106-snow-leopard/">How To Write To Windows NTFS Drives In Mac OS X 10.6 &#8220;Snow Leopard&#8221;</a>
<br/>
This post was categorized as <a href="http://blog.fosketts.net/category/everything/apple/" title="View all posts in Apple" rel="category tag">Apple</a>, <a href="http://blog.fosketts.net/category/everything/personal/" title="View all posts in Personal" rel="category tag">Personal</a>, <a href="http://blog.fosketts.net/category/everything/terabytehome/" title="View all posts in Terabyte home" rel="category tag">Terabyte home</a>. Each of my categories has its own feed if you'd like to filter out or focus on posts like this.<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://blog.fosketts.net/2010/11/29/write-windows-ntfs-drive-mac-os-106-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Tuning Lighttpd For Linux</title>
		<link>http://blog.fosketts.net/2009/06/29/tuning-lighttpd-linux/</link>
		<comments>http://blog.fosketts.net/2009/06/29/tuning-lighttpd-linux/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 15:17:41 +0000</pubDate>
		<dc:creator>Stephen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PAM]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Pingdom]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://blog.fosketts.net/?p=2126</guid>
		<description><![CDATA[As I mentioned on Friday, I&#8217;ve recently built a multi-server web hosting environment around lighttpd, MySQL, and Ubuntu Linux. Ironically, my lighttpd web server slowed to a crawl that very evening! It turns out that I had not properly tuned lighttpd to function in a Linux environment. I was surprised to find that the Ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned on Friday, I&#8217;ve recently built a <a href="http://blog.fosketts.net/2009/06/26/multiserver-web-host-environment/"  target="_blank">multi-server web hosting environment around lighttpd, MySQL, and Ubuntu Linux</a>. Ironically, my lighttpd web server slowed to a crawl that very evening! It turns out that I had not properly tuned lighttpd to function in a Linux environment. I was surprised to find that the Ubuntu package did not include basic Linux settings! I referred to the <a href="http://redmine.lighttpd.net/wiki/lighttpd/Docs:Performance"  target="_blank">lighttpd performance documentation</a> for help.<span id="more-2126"></span></p>
<h3>File Descriptors</h3>
<p>Anyone familiar with its internals will tell you that <strong>everything is a file to a UNIX operating system</strong>. It&#8217;s the philosophy behind the system: Network connections, storage systems, system parameters, and processes all have file interfaces, and each of these pseudo-files needs a unique file descriptor.</p>
<p>What does this mean for lighttpd? Well, every time a visitor accesses a page, lighttpd uses three file descriptors: An IP socket to the client, a fastCGI process socket, and a filehandle for the document accessed. Lighttpd stops accepting new connections when 90% of the available sockets are in use, restarting again when usage has fallen to 80%. With the default setting of 1024 file descriptors, <strong>lighttpd can handle a maximum of 307 connections</strong>. This is a lot. But it is possible to exceed this number under times of high load.</p>
<p>To prevent this from happening, we can double the limit without any trouble. <strong>Simply set &#8220;server.max-fds&#8221; to 2048 in /etc/lighttpd/lighttpd.conf</strong>.</p>
<p>Contrary to much of the advice I found on the Internet, lighttpd spawned by root does not appear to use the &#8220;nofile&#8221; limits set in /etc/security/limits.conf, since these are for PAM and only apply to full interactive logins. There is a system-wide limit that can be set in /etc/sysctl.conf, however. Check your default with &#8220;<strong>cat /proc/sys/fs/file-max</strong>&#8221; and make sure it&#8217;s over 10,000. Mine was set to 12640 so I left that alone.</p>
<h3>HTTP Keep-Alive</h3>
<p>One reason that file descriptors get used up so quickly is HTTP keep-alive. To improve performance, modern web servers keep client connections alive to handle multiple requests instead of building up and tearing down connections for each item in a page. <strong>Keep-alive is tremendously beneficial to performance, but tends to keep unnecessary connections alive, too</strong>. By default, lighttpd allows 16 keep-alive requests per connection, allows idle sessions to remain alive for 5 seconds, and gives reads and writes 1 minute and 6 minutes to complete, respectively.</p>
<p>Although <strong>lighttpd has pretty aggressive defaults</strong> (especially compared to Apache), a period of heavy traffic and a few slow clients could see many unused connections sticking around. The <strong>server.max-keep-alive-idle</strong> setting default of 5 seconds can be reduced to as low as 2, if you assume your clients are reasonably quick about requesting data, but a value of 3 or 4 is probably realistic. You may want to <em>increase</em> the <strong>server.max-keep-alive-requests</strong> value from the default of 16, but you probably don&#8217;t need to. The <strong>server.max-read-idle</strong> and <strong>server.max-write-idle</strong> settings are tempting targets, but these situations are usually fairly rare so let&#8217;s not monkey with them.</p>
<h3>Mechanics: Polling and Sending</h3>
<p>The best bang for your lighttpd buck is to tune the server to use better kernel resources to check for file changes and write data to the network. There are three critical items here, each of which is set to a conservative universal setting by default.</p>
<p>One of the major areas of UNIX development over the last decade was how to handle the tens of thousands of connections experienced by Internet servers. This &#8220;<a href="http://www.kegel.com/c10k.html"  target="_blank">C10K Problem</a>&#8221; is documented in excruciating detail if you&#8217;re interested, but the net of it is that <strong>each version of UNIX has an advanced mechanism to handle I/O events</strong>. Since kernel version 2.6, Linux has sys_epoll, a so-called edge-triggered polling mechanism which scales linearly with the number of connections. But lighttpd runs on many different flavors of UNIX, so it has to default to the older and less-scalable &#8220;level-triggered&#8221; poll system. To remedy this, <strong>set &#8220;server.event-handler&#8221; to &#8220;linux-sysepoll&#8221;</strong>.</p>
<p>Another mechanism that varies widely across UNIX systems is how to actually <strong>read and write data from the disk to the network</strong>. All systems include basic read() and write() calls, which transfer data into and out of system memory. Lighttpd defaults to using these to move data around. But Linux includes a more advanced call, sendfile, which can move data around without copying it into memory. We can enable this by setting <strong>&#8220;server.network-backend&#8221; to &#8220;linux-sendfile&#8221;</strong>, which ought to <a href="http://www.lighttpd.net/2007/2/3/raw-io-performance"  target="_blank">improve performance</a> for larger (multi-megabyte) files without impacting smaller ones.</p>
<p>Lighttpd attempts to improve performance further by caching the output of the UNIX stat() command. It includes a basic (&#8220;simple&#8221;) cache which keeps the result of file system calls in memory for one second. But many Linux distributions include more advanced accelerators: FAM was the original, and a lighter-weight workalike called Gamin is now included by default in Ubuntu&#8217;s lighttpd install. Therefore, we can improve stat calls simply by allowing lighttpd to use Gamin: Set<strong> &#8220;server.stat-cache-engine&#8221; to &#8220;fam&#8221;</strong> and you&#8217;re rolling!</p>
<p>One more useful tweak to consider, although it&#8217;s not included in the official lighttpd performance document, is not updating the &#8220;atime&#8221; parameter on served pages. This is a bit of a religious issue among some UNIX administrators, but I feel safe in saying that since my web server logs all accesses and I&#8217;m not using any kind of hierarchical storage system to store them, <strong>I don&#8217;t care when each php, html, and png file was last accessed</strong>. We can stop writing atime values by mounting the entire filesystem with &#8220;noatime&#8221;, but I like the more granular approach offered by lighttpd: Simply <strong>set &#8220;server.use-noatime&#8221; to &#8220;enable&#8221;</strong> and it won&#8217;t bother keeping this updated for the files it accesses. Everything else will continue as it always has but with reduced disk I/O.</p>
<h3>Summary</h3>
<p>Lighttpd has pretty good default settings, but a few might be tweaked if we need to respond to higher server loads. The more important area of tuning is simply enabling the advanced features of the 2.6.x Linux kernel and Ubuntu system we are using: <strong>Enable sys_epoll, sendfile, and Gamin and disable atime updates</strong>.</p>
<p>I&#8217;ll post more information as I stumble across it. I&#8217;m still learning, but my server performance as improved dramatically: Pingdom tools <a href="http://tools.pingdom.com/?url=http://blog.fosketts.net&amp;treeview=0&amp;column=objectID&amp;order=1&amp;type=0&amp;save=true"  target="_blank">reports</a> that <strong>it used to take upwards of half a minute to load my blog&#8217;s home page and it now loads in under seven seconds</strong>! That&#8217;s progress!</p>
<pre><code># Maximum number of file descriptors, default = 1024
server.max-fds = 2048
# Maximum number of request within a keep-alive session before the server terminates the connection, default = 16
server.max-keep-alive-requests = 16
# Maximum number of seconds until an idling keep-alive connection is dropped, default = 5
server.max-keep-alive-idle = 4
# Maximum number of seconds until a waiting, non keep-alive read times out and closes the connection, default = 60
server.max-read-idle = 60
# Maximum number of seconds until a waiting write call times out and closes the connection, default = 360
server.max-write-idle = 360
# Which event handler to use, default = poll
server.event-handler = "linux-sysepoll"
# How to handle network writes, default = writev
server.network-backend = "linux-sendfile"
# Requires FAM or Gamin to be installed, default = simple
server.stat-cache-engine = "fam"
# Whether to update the atime setting on file access, default = disable
server.use-noatime = "enable"
</code></pre>
<div id="crp_related"><h3>You might also want to read these other posts...</h3><ul><li><a href="http://blog.fosketts.net/2010/07/30/high-performance-memory-apache-php-virtual-private-server/"  rel="bookmark" class="crp_title">A High-Performance, Low-Memory Apache/PHP Virtual Private Server</a></li><li><a href="http://blog.fosketts.net/2009/06/26/multiserver-web-host-environment/"  rel="bookmark" class="crp_title">Setting Up a Multi-Server Web Hosting Environment</a></li><li><a href="http://blog.fosketts.net/2010/08/01/force-apache-redirect-canonical-hostnames-serveralias-friend/"  rel="bookmark" class="crp_title">How To Force Apache To Redirect To Canonical Hostnames, or ServerAlias Is Not Your Friend</a></li><li><a href="http://blog.fosketts.net/2009/02/07/apologies-404s/"  rel="bookmark" class="crp_title">Apologies For The 404s!</a></li><li><a href="http://blog.fosketts.net/2010/03/25/robocopy-multi-threaded/"  rel="bookmark" class="crp_title">Robocopy: Better, Faster, Stronger</a></li></ul></div><script src="http://feeds.feedburner.com/~s/sfoskett?i=http://blog.fosketts.net/2009/06/29/tuning-lighttpd-linux/" type="text/javascript" charset="utf-8"></script><hr />
<p><small>© sfoskett for <a href="http://blog.fosketts.net">Stephen Foskett, Pack Rat</a>, 2009. |
<a href="http://blog.fosketts.net/2009/06/29/tuning-lighttpd-linux/">Tuning Lighttpd For Linux</a>
<br/>
This post was categorized as <a href="http://blog.fosketts.net/category/everything/personal/" title="View all posts in Personal" rel="category tag">Personal</a>. Each of my categories has its own feed if you'd like to filter out or focus on posts like this.<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://blog.fosketts.net/2009/06/29/tuning-lighttpd-linux/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<series:name><![CDATA[Web Hosting]]></series:name>
	</item>
		<item>
		<title>AncientFS Opens Archaic Filesystems To Mac OS X</title>
		<link>http://blog.fosketts.net/2008/12/17/ancientfs-filesystem-mac-ox-x/</link>
		<comments>http://blog.fosketts.net/2008/12/17/ancientfs-filesystem-mac-ox-x/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 20:46:58 +0000</pubDate>
		<dc:creator>Stephen</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Computer History]]></category>
		<category><![CDATA[DECtape]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[MacFUSE]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://blog.fosketts.net/?p=1263</guid>
		<description><![CDATA[Just a quick note: Google&#8217;s Amit Singh recently introduced a new addition to the MacFUSE user-space filesystem software for OS X: AncientFS allows the Mac to read a host of archaic file systems and data container formats, from DECtape to Dump to the various flavors of the standard UNIX file system. This ought to be useful for [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note: Google&#8217;s Amit Singh recently <a href="http://www.osxbook.com/blog/2008/12/16/more-user-space-file-system-goodies/"  target="_blank">introduced</a> a new addition to the <a rel="nofollow" href="http://code.google.com/p/macfuse/"  target="_blank">MacFUSE</a> user-space filesystem software for OS X: <a href="http://osxbook.com/software/ancientfs/"  target="_blank">AncientFS</a> allows the Mac to read a host of archaic file systems and data container formats, from DECtape to Dump to the various flavors of the standard UNIX file system.</p>
<p>This ought to be useful for those of us who have standardized our desktops on OS X yet still maintain a variety of old data storage systems and archives.</p>
<div id="crp_related"><h3>You might also want to read these other posts...</h3><ul><li><a href="http://blog.fosketts.net/2008/02/27/zfs-super-file-system/"  rel="bookmark" class="crp_title">ZFS: Super File System!</a></li><li><a href="http://blog.fosketts.net/2009/09/11/bizarre-hfs-tricks-in-mac-os-x-10-6-snow-leopard/"  rel="bookmark" class="crp_title">Bizarre HFS+ Tricks in Mac OS X 10.6 Snow Leopard</a></li><li><a href="http://blog.fosketts.net/2007/09/18/google-revs-apps/"  rel="bookmark" class="crp_title">Google Revs Apps</a></li><li><a href="http://blog.fosketts.net/2011/01/06/bridge-veritas-thin-provisioning-api/"  rel="bookmark" class="crp_title">The Bridge: Veritas Thin (Provisioning) API</a></li><li><a href="http://blog.fosketts.net/2010/10/01/introduction-exfat/"  rel="bookmark" class="crp_title">An Introduction To exFAT</a></li></ul></div><script src="http://feeds.feedburner.com/~s/sfoskett?i=http://blog.fosketts.net/2008/12/17/ancientfs-filesystem-mac-ox-x/" type="text/javascript" charset="utf-8"></script><hr />
<p><small>© sfoskett for <a href="http://blog.fosketts.net">Stephen Foskett, Pack Rat</a>, 2008. |
<a href="http://blog.fosketts.net/2008/12/17/ancientfs-filesystem-mac-ox-x/">AncientFS Opens Archaic Filesystems To Mac OS X</a>
<br/>
This post was categorized as <a href="http://blog.fosketts.net/category/everything/apple/" title="View all posts in Apple" rel="category tag">Apple</a>, <a href="http://blog.fosketts.net/category/everything/computerhistory/" title="View all posts in Computer History" rel="category tag">Computer History</a>. Each of my categories has its own feed if you'd like to filter out or focus on posts like this.<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://blog.fosketts.net/2008/12/17/ancientfs-filesystem-mac-ox-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

