<?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>My Galagzee! &#187; freebsd</title>
	<atom:link href="http://my.galagzee.com/tag/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://my.galagzee.com</link>
	<description>Tech in a Galagzee, Not So Far Away.</description>
	<lastBuildDate>Fri, 20 Jan 2012 18:46:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>FreeBSD: Installed ports in chronological order</title>
		<link>http://my.galagzee.com/2012/01/20/freebsd-installed-ports-in-chronological-order/</link>
		<comments>http://my.galagzee.com/2012/01/20/freebsd-installed-ports-in-chronological-order/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 18:46:41 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[chronologically]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[installed]]></category>
		<category><![CDATA[ports]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=519</guid>
		<description><![CDATA[An easy way to list the installed ports in FreeBSD in chronological order (most recent first):]]></description>
			<content:encoded><![CDATA[<p>An easy way to list the installed ports in FreeBSD in chronological order (most recent first):</p>
<pre class="brush: bash; title: ; notranslate">
ls -latT /var/db/pkg | less
</pre>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2012/01/20/freebsd-installed-ports-in-chronological-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NFS automount evolves</title>
		<link>http://my.galagzee.com/2011/12/19/nfs-enforcer/</link>
		<comments>http://my.galagzee.com/2011/12/19/nfs-enforcer/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 20:54:28 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[automount]]></category>
		<category><![CDATA[enforcer]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[self-healing]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=503</guid>
		<description><![CDATA[I&#8217;ve updated the NFS automount script that provides &#8220;self-healing&#8221; NFS mounts. The script now allows a mount to be defined as read-write or read-only, and then subsequently monitors that the share is mounted as R/W or R/O (of course, it &#8230; <a href="http://my.galagzee.com/2011/12/19/nfs-enforcer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated the NFS automount script that provides &#8220;self-healing&#8221; NFS mounts. The script now allows a mount to be defined as read-write or read-only, and then subsequently monitors that the share is mounted as R/W or R/O (of course, it can&#8217;t mount a share that has been shared as R/O as R/W). Both Linux (tested on CentOS 6.1) and FreeBSD versions are provided.</p>
<p>Since various systems can provide cross-mounts via NFS, and they may be started/rebooted at the same time, various shares may or may not be available at each system&#8217;s boot time. By utilizing this script the mounts become available soon after the respective share becomes available (simply adjust the run frequency in crontab to the needs of your specific application). Also, by not adding the NFS mount points in fstab the boot process is not delayed by a share that is not [yet] available.</p>
<p>First for CentOS/Linux:</p>
<pre class="brush: bash; collapse: true; light: false; title: ; toolbar: true; notranslate">
#!/bin/sh

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin

# set mount/remount request flags
mount=false
remount=false

# remote system name
remotesystem=&quot;$1&quot;

# rw/ro
if [ &quot;$2&quot; = &quot;rw&quot; ]; then
    mountmode=&quot;-w&quot;
else
    mountmode=&quot;-r&quot;
fi

# remote share name
remoteshare=&quot;$3&quot;

# local mount point
mountpoint=&quot;$4&quot;

# file to indicate local mount status
testfile=${mountpoint}/&quot;$5&quot; 

# rw test file
rw_testfile=${mountpoint}/nfs_enforcer_rw_testfile

# command locations
pingcmd=/bin/ping
showmountcmd=/usr/sbin/showmount
grepcmd=/bin/grep
mountcmd=/bin/mount
umountcmd=/bin/umount
statcmd=/usr/bin/stat
touchcmd=/bin/touch
rmcmd=/bin/rm

# --- end variables ---

# make sure the mountpoint is not stale
statresult=`${statcmd} ${mountpoint} 2&gt;&amp;1 | ${grepcmd} &quot;Stale&quot;`

if [ &quot;${statresult}&quot; != &quot;&quot; ]; then
   #result not empty: mountpoint is stale; remove it
   ${umountcmd} -f ${mountpoint}
fi

# ping the remote system (2 sec timeout)
${pingcmd} -w2 -c1 -q ${remotesystem} &gt; /dev/null 2&gt;&amp;1

# make sure the remote system is reachable
if [ &quot;$?&quot; -eq &quot;0&quot; ]; then

   # query the availability of the remote share; not empty result indicates OK
   offsiteshare=`${showmountcmd} -e ${remotesystem} | ${grepcmd} &quot;${remoteshare}&quot;`
   if [ &quot;${offsiteshare}&quot; != &quot;&quot; ] ; then

      # make sure the local mount point (directory) exists (so that [re-]mount, if necessary, is valid)
      if [ -d ${mountpoint} ] ; then

         localmount=`${mountcmd} | ${grepcmd} &quot;${mountpoint}&quot;`

         # make sure the share test file is _not_ present (to make sure the mountpoint is inactive)
         if [ ! -f ${testfile} ] ; then

            # make sure the local mountpoint is inactive (double checking)
            if [ &quot;${localmount}&quot; = &quot;&quot; ] ; then

               # all set to go; request mount
               mount=true
            fi

         else 

            # make sure the local mountpoint is active (double checking)
            if [ &quot;${localmount}&quot; != &quot;&quot; ] ; then

               # attempt to create a test file..
               ${touchcmd} ${rw_testfile} &gt; /dev/null  2&gt;&amp;1

               # ..and test its existence; first handle RW mounted shares:
               if [ -f ${rw_testfile} ] ; then

                  # share was RO requested
                  if [ &quot;$2&quot; = &quot;ro&quot; ]; then
                     remount=true
                  fi

                  # Delete the testfile
                  ${rmcmd} ${rw_testfile}

               # hanle RO mounted shares:
               else

                  # share was RW requested
                  if [ &quot;$2&quot; = &quot;rw&quot; ]; then
                     remount=true
                  fi
               fi
            fi
         fi
      fi
   fi
fi

# perform remount (unmount, request mount)
if $remount ; then
   ${umountcmd} -f ${mountpoint}
   mount=true
fi

# perform mount when so requested
if $mount ; then
   ${mountcmd} ${mountmode} -t nfs ${remotesystem}:${remoteshare} ${mountpoint}
fi

exit 0
</pre>
<p>Then for FreeBSD/UNIX:</p>
<pre class="brush: bash; collapse: true; light: false; title: ; toolbar: true; notranslate">
#!/bin/sh

SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin

# set mount/remount request flags
mount=false
remount=false

# remote system name
remotesystem=&quot;$1&quot;

# rw/ro
if [ &quot;$2&quot; = &quot;rw&quot; ]; then
    mountmode=&quot;-w&quot;
else
    mountmode=&quot;-r&quot;
fi

# remote share name
remoteshare=&quot;$3&quot;

# local mount point
mountpoint=&quot;$4&quot;

# file to indicate local mount status
testfile=${mountpoint}/&quot;$5&quot; 

# rw test file
rw_testfile=${mountpoint}/nfs_enforcer_rw_testfile

# command locations
pingcmd=/sbin/ping
showmountcmd=/usr/bin/showmount
grepcmd=/usr/bin/grep
mountcmd=/sbin/mount
umountcmd=/sbin/umount
statcmd=stat
touchcmd=/usr/bin/touch
rmcmd=/bin/rm

# --- end variables ---

# make sure the mountpoint is not stale
statresult=`${statcmd} ${mountpoint} 2&gt;&amp;1 | ${grepcmd} &quot;Stale&quot;`

if [ &quot;${statresult}&quot; != &quot;&quot; ]; then
   #result not empty: mountpoint is stale; remove it
   ${umountcmd} -f ${mountpoint}
fi

# ping the remote system (2 sec timeout)
remoteping=`${pingcmd} -c1 -o -q -t2 ${remotesystem} | grep &quot; 0.0%&quot;`

# make sure the remote system is reachable
if [ &quot;${remoteping}&quot; != &quot;&quot; ] ; then

   # query the availability of the remote share; not empty result indicates OK
   offsiteshare=`${showmountcmd} -e ${remotesystem} | ${grepcmd} &quot;${remoteshare}&quot;`
   if [ &quot;${offsiteshare}&quot; != &quot;&quot; ] ; then

      # make sure the local mount point (directory) exists (so that [re-]mount, if necessary, is valid)
      if [ -d ${mountpoint} ] ; then

         localmount=`${mountcmd} | ${grepcmd} &quot;${mountpoint}&quot;`

         # make sure the share test file is _not_ present (to make sure the mountpoint is inactive)
         if [ ! -f ${testfile} ] ; then

            # make sure the local mountpoint is inactive (double checking)
            if [ &quot;${localmount}&quot; = &quot;&quot; ] ; then

               # all set to go; request mount
               mount=true
            fi

         else

            # make sure the local mountpoint is active (double checking)
            if [ &quot;${localmount}&quot; != &quot;&quot; ] ; then

               # attempt to create a test file..
               ${touchcmd} ${rw_testfile} &gt; /dev/null  2&gt;&amp;1

               # ..and test its existence; first handle RW mounted shares:
               if [ -f ${rw_testfile} ] ; then

                  # share was RO requested
                  if [ &quot;$2&quot; = &quot;ro&quot; ]; then
                     remount=true
                  fi

                  # Delete the testfile
                  ${rmcmd} ${rw_testfile}

               # hanle RO mounted shares:
               else

                  # share was RW requested
                  if [ &quot;$2&quot; = &quot;rw&quot; ]; then
                     remount=true
                  fi
               fi
            fi
         fi
      fi
   fi
fi

# perform remount (unmount, request mount)
if $remount ; then
   ${umountcmd} -f ${mountpoint}
   mount=true
fi

# perform mount when so requested
if $mount ; then
   ${mountcmd} ${mountmode} -t nfs ${remotesystem}:${remoteshare} ${mountpoint}
fi

exit 0
</pre>
<p>You should run the automount script from a runfile, like so:</p>
<pre class="brush: plain; title: ; notranslate">
#!/bin/sh

NFS_ENFORCE=/usr/local/sbin/nfs_enforcer

# Separate the following parameters with spaces:
#
# - nfs enforcer command (set above)
# - remote system name (must be resolvable)
# - read/write (rw) or read-only (ro); NOTE: share may be read-only regardless of how this is set
# - remote share name (from remote's /etc/exports)
# - local mount point (existing local directory)
# - share test file (an immutable file on the share)

# e.g.
# $NFS_ENFORCE dbsysvm rw /nfs4shares/conduit /mnt/dbsys_conduit .conduit@dbsysvm
# or (for local remount read-only)
# $NFS_ENFORCE localhost ro /var/web/projects/repository /mnt/rorepo .repository@localhost

$NFS_ENFORCE localhost ro /var/web/projects/repository /mnt/rorepo .repository@localhost

exit 0
</pre>
<p>..and call the the above runfile from crontab:</p>
<pre class="brush: plain; title: ; notranslate">
*/10  *  *  *  *  root  /usr/local/sbin/nfs_enforcer.batch &gt; /dev/null
</pre>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2011/12/19/nfs-enforcer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Things I didn&#8217;t know about ESXi</title>
		<link>http://my.galagzee.com/2010/06/06/vmware-n00b-%e2%80%93-things-i-didnt-know-about-esxi/</link>
		<comments>http://my.galagzee.com/2010/06/06/vmware-n00b-%e2%80%93-things-i-didnt-know-about-esxi/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 04:11:25 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[virtual]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=408</guid>
		<description><![CDATA[I&#8217;m setting up a development server using vmware ESXi virtual server running CentOS 5.5 x64 and FreeBSD 8.0 x64. Currently, the second installation pass is in progress. Being fresh to ESX/ESXi there were couple of things I didn&#8217;t realize: First &#8230; <a href="http://my.galagzee.com/2010/06/06/vmware-n00b-%e2%80%93-things-i-didnt-know-about-esxi/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m setting up a development server using vmware ESXi virtual server running CentOS 5.5 x64 and FreeBSD 8.0 x64. Currently, the second installation pass is in progress. Being fresh to ESX/ESXi there were couple of things I didn&#8217;t realize:</p>
<p>First (the reason for the reinstall), if there is plenty of hard drive space available, it&#8217;s good idea not to deplete it all for the sytem installations. I split a 1.3Tb RAID 5 array between the two operating systems until I realized that 1) you can&#8217;t shrink vmfs partitions and 2) by consuming all hard drive space one limits the flexibility of the system down the line. Let&#8217;s say you want to install a newer version of an operating system and decide to do a fresh install. You need space for it while you want to keep the old version around at least long enough to migrate settings and data over.</p>
<p>Second, while I was aware of that ESXi doesn&#8217;t offer console access beyond the &#8220;yellow and grey&#8221; terminal, I didn&#8217;t realize you have no access to the VM consoles, either. So, with CentOS or FreeBSD installed, the only way to access their consoles is via the vSphere client (someone correct me if I&#8217;m wrong — I wish I were as I&#8217;d like to have local console access to the guest OS&#8217;es).</p>
<p>Finally, <a href="https://go.vmware.com/">VMware Go</a> &#8220;doesn&#8217;t currently support ESXi servers with multiple datastores&#8221;. So if you have, say, a 3ware/LSI/AMCC RAID controller which isn&#8217;t currently supported under ESXi as a boot device but which you likely still want to use as a datastore, you&#8217;ll end up with at least two datastores. So vSphere is really the only way to go for VM management also for this reason (since LSI provides a vmware-specific driver, one may also be able to direct-connect the LSI RAID array to the VM without it being an ESXi datastore, but that&#8217;s not the configuration I&#8217;m looking for—the boot device is small and houses just ESXi while the VMs and their associated datastores are located on the array).</p>
<p>In the end everything&#8217;s working quite well. I like the flexibility virtualization offers.. and consolidation is useful even in a small environment (one dev machine is less than two or three dev machines <img src='http://my.galagzee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2010/06/06/vmware-n00b-%e2%80%93-things-i-didnt-know-about-esxi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Explorations in the World of Linux</title>
		<link>http://my.galagzee.com/2009/09/05/explorations-in-the-world-of-linux/</link>
		<comments>http://my.galagzee.com/2009/09/05/explorations-in-the-world-of-linux/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 03:55:02 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[bsd]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=375</guid>
		<description><![CDATA[I&#8217;ve been a FreeBSD admin for the past decade, and during this time have become quite familiar with the *BSD system. It has its quirks, but overall it&#8217;s very clean and easy to maintain. From time to time – usually &#8230; <a href="http://my.galagzee.com/2009/09/05/explorations-in-the-world-of-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a FreeBSD admin for the past decade, and during this time have become quite familiar with the *BSD system. It has its quirks, but overall it&#8217;s very clean and easy to maintain. </p>
<p>From time to time – usually when I&#8217;ve been getting ready to upgrade to the next major revision of FreeBSD – I&#8217;ve taken some time to research what the current pros and cons are for FreeBSD vs. some Linux distro. Always, in the end, FreeBSD has won.  However, a development project I&#8217;m starting to work on will utilize <a href="http://www.zend.com/en/products/server/" target="_blank">Zend Server</a>, which is only supported on handful of common Linux distros and on Windows (which is, by default, not an option as I strongly maintain that Windows is not suitable as a web server platform). There is, of course, Linux compatibility layer in FreeBSD, but as Zend doesn&#8217;t currently support it as a platform for Zend Server, I wouldn&#8217;t feel comfortable using it in a production environment.</p>
<p>So even though I find FreeBSD superior to Linux in many ways, I&#8217;ve now spent some time getting acquainted with Linux. I first started with Red Hat, then moved to CentOS which is the Linux distribution I&#8217;m currently testing. Now it&#8217;s not <em>bad</em>, per se, but I frequently come back to the thought: &#8220;Why would someone, anyone prefer THIS over a BSD system?!&#8221;  The package management with yum, rpm, and the GUI overlays is easy enough, but <em>it&#8217;s chaotic!</em> Having to enable and disable repos, set their priorities, etc. seems unnecessarily complicated. On the FreeBSD side there is the <a href="http://en.wikipedia.org/wiki/Ports_collection" target="_blank">ports collection</a> which provides most of the software that one can imagine ever needing.  The odd few items that either aren&#8217;t available in ports, or whose configuration is somehow not complete enough through ports can be easily compiled from the source tarball. Everything&#8217;s quite easy to keep track of, and to duplicate if one&#8217;s building a new system.</p>
<p>I&#8217;m sure some of this feeling stems from the fact that I have been using a BSD system for so long, and from the fact that I probably don&#8217;t yet know Linux well enough (say, to build the system from a scratch..). But as far as I can tell, package management <em>is</em> done with yum and rpm (on CentOS, say), by adjusting repository priorities, and enabling/disabling repositories. That is messy!</p>
<p>Well, I now have a functional development server running Zend Server with Apache, Subversion, and MySQL, and as the vendor (Zend) dictates the rules, I must continue development on Linux. Perhaps in six months time I&#8217;ll have more favorable comments about it as compared to FreeBSD&#8230; but I sort of doubt it.  My guess is I&#8217;ll just learn to live with it, every now and then wistfully glancing to the direction of the BSD server.</p>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2009/09/05/explorations-in-the-world-of-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deleting all network interface aliases</title>
		<link>http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/</link>
		<comments>http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 06:13:21 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[deleting IP aliases]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[netstart]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=313</guid>
		<description><![CDATA[I recently needed to move bunch of aliased IPs from one FreeBSD server to another. Adding aliases to /etc/rc.conf and then running ./netstart while in /etc adds new multiplexed IPs to the system all right, but if you need to &#8230; <a href="http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently needed to move bunch of aliased IPs from one FreeBSD server to another. Adding aliases to /etc/rc.conf and then running ./netstart while in /etc <em>adds</em> new multiplexed IPs to the system all right, but if you need to remove aliased IPs, running /etc/netstart won&#8217;t remove them even if the aliases have been removed from /etc/rc.conf. Perhaps there is some easy single command that culls the active alias IPs to those specified in /etc/rc.conf, but I&#8217;m not aware of it.  The following command can be used to quickly delete all aliased IPs for a specific interface (here &#8220;em0&#8243;):</p>
<p><strong>ifconfig | grep &#8220;0xffffffff&#8221; | awk &#8216;{ print $2 }&#8217; | xargs -n 1 ifconfig em0 delete</strong></p>
<p>For this to work, the netmasks of the aliases and the master IP for the inteface must differ. The netmasks of the aliases are usually set to 255.255.255.255 (hence &#8220;0xffffffff&#8221;) while the netmask of the master IP is usually something different, specific to your network, e.g. 255.255.255.128 (&#8220;0xffffff80&#8243;).</p>
<p>Once the above command has been run, /etc/netstart can then be executed to load the remaining or reconfigured aliases (if any) from /etc/rc.conf.</p>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeBSD Full / Incremental Filesystem Dump Shell Script</title>
		<link>http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/</link>
		<comments>http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 05:19:25 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[automatic]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[incremental]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=232</guid>
		<description><![CDATA[A FreeBSD shell script to dump filesystems with full, and automatically incremented incremental backups to a given directory location. <a href="http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I wanted to automate filesystem dumps on my servers running FreeBSD 7.2.  After some searching I came across Vivek Gite&#8217;s <a href="http://bash.cyberciti.biz/backup/freebsd-dump-filesystem-shell-script/" target="_blank">FreeBSD Full / Incremental <strong>Tape</strong> Backup Shell Script</a> which gave me a lot of ideas.  Since I&#8217;m not using tape as the backup target I wanted to make a script specifically for that purpose while at the same time improve handling of some error conditions (such as, most importantly, checking for a missing level 0 dump before proceeding with an incremental dump) and add some new features such as autoincrement the dump level so that the dump level is not tied to specific day of the week.</p>
<p>Here&#8217;s my version of the script.  While it bears some resemblance to Vivek&#8217;s script, it is largely rewritten.  Read the script header for more information.</p>
<p><strong>NOTE!</strong> In his <a href="http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/#comment-9988">comment</a> <em>James</em> pointed out a possible bug in the script.  The displayed script indeed had a problem: it was missing a backslash in front of the first dollar sign at:</p>
<p>eval &#8220;local fspath=<strong>\</strong>$${fsname}path&#8221;</p>
<p>This was caused by the script display plugin in WordPress that treated the backslash as an escape character (<a href="http://wordpress.org/support/topic/256742?replies=12#post-1168286" target="_blank">this has now been fixed</a>). To be on the safe side, please <strong><a href="http://my.galagzee.com/wp-content/uploads/2009/08/autodump-1.5a.tar">download the script as a tarball</a>.</strong> To further validate the integrity of the tarball, it should produce a md5 hash of 732ac44f11ba4484be4568e84929bb6a. </p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh

# Autodump 1.5a (released 01 August 2009)
# Copyright (c) 2009 Ville Walveranta
#
# A FreeBSD shell script to dump filesystems with full, and automatically
# incremented incremental backups to a given directory location; this script
# was written with the intent of saving the filesystem dumps not onto a tape
# device but on another hard drive such as a different filesystem on the same
# computer. The resulting dump files can be copied offsite with a separate
# cron job.
#
# This script creates the necessary directory structure below the defined
# 'BASEDIR' as well as the necessary log file. This script also ensures that
# the level 0 dump exists before creating an incremental dump; if it doesn't
# the script automatically erases the incremental files for the current week
# (if any exist) and starts over with a level 0 dump. This way you can start
# using the script on any day of the week and level 0 dump is automatically
# created on the first run.
#
# When ran daily (such as from a cron job), the script creates level 0 dump
# on every Monday (beginning the ISO week), or Sunday (beginning of the U.S.
# week) and an incremental dump on all the other days of each week. The dumps
# are compressed with gzip and saved below the 'BASEDIR' to an automatically
# created directory whose name is derived from the list given in 'FSNAMES'.
# Each week's dumps are organized into subfolders with name YYYY-WW ('WW'
# being the current week). By default three most recent weekly dumps
# (level 0 + incrementals) are retained.
#
# The script maintains each weekly folder's date at the _beginning_ date
# of the dump (i.e. Monday or Sunday of the current week) at 00:00, not
# at the most recent incremental's date/time.
#
# By default the root (/) and usr (/usr) filesystems are dumped. To add more
# add a &quot;friendly name&quot; to the 'FSNAMES' list (it is used for the weekly folder
# names, for dump filenames, and to reference the corresponding mount point
# variable); then add the corresponding mount point variable (i.e. if you
# add &quot;var&quot; to 'FSNAMES', then add a variable varpath=/var). The &quot;path&quot;
# ending of the mount point variable name is required.
#
# Since the number of incremental dumps is limited to nine (level 0 +
# incremental levels 1-9), the script will allow maximum of one dump
# to be created per day. However, since the level incrementing is dynamic
# you can start the script on any day of the week, and run it on any
# number of days during the rest of the week and you'll always get
# level 0 plus the incremental dumps in sequential order. However, The
# new weekly folder is always created on Monday or Sunday (as chosen by
# you). Note that the script determines whether &quot;today's&quot; dump exists
# based on the modification date stamp of the most recent dump. Hence
# it is a good idea to run this script in the early hours of each day
# rather than in the very end of each day. Running the script, for
# example, at 23:50 has the potential to push longer dump processes
# over the midnight and so potentially cause the next day's dump to
# be skipped.
#
# Written for FreeBSD 7.2 but should work on most BSD and *NIX systems with
# minor modifications.
# -------------------------------------------------------------------------
# Copyright (c) 2009 Ville Walveranta
# &lt;http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script&gt;
# This script is licensed under GNU GPL version 2.0 or above, and is provided
# 'as-is' with no warranty which is to say that I'm not liable if it wipes out
# your hard drive clean or doesn't back up your precious data. However, to the
# best or my knowledge it is working as expected -- I'm using it myself. <img src='http://my.galagzee.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
# -------------------------------------------------------------------------
# This script was inspired by
# FreeBSD Full / Incremental Tape Backup Shell Script
# by nixCraft project / Vivek Gite
# at &lt;http://bash.cyberciti.biz/backup/freebsd-dump-filesystem-shell-script/&gt;
# -------------------------------------------------------------------------

#### GLOBAL VARIABLES ###############################################

WEEKSTARTS=Mon      # Accepted values are &quot;Mon&quot; (ISO standard) or &quot;Sun&quot; (U.S.)
KEEPDUMPS=30        # in days; this is evaluated on the weekly level per start
                    # of the week, so '30' keeps 3-4 weekly dumps
BASEDIR=/bak/dumps
GLOBALDUMPOPTS=Lua  # add 'n' for wall notifications
LOGFILE=/var/log/dump.log

# to add more filesystems to be dumped add the dump name in 'FSNAMES'
# and add the corresponding mount point variable (dumpname+path=mountpoint)
FSNAMES=&quot;root usr&quot;  # this is used for dump directory name
                    # and to ID the path from a variable below
rootpath=/
usrpath=/usr

#####################################################################

DUMP=/sbin/dump
GZIP=/usr/bin/gzip
LOGGER=/usr/bin/logger

WEEKDAY=$(date +&quot;%a&quot;)
DATE=$(date +&quot;%Y%m%d&quot;)
HUMANDATE=$(date +&quot;%d-%b-%Y&quot;)
HUMANDATE=`echo $HUMANDATE | tr '[:lower:]' '[:upper:]'`
HUMANTIME=$(date +&quot;%H:%M (%Z)&quot;)
TODAYYR=$(date +&quot;%Y&quot;)
TODAYMO=$(date +&quot;%m&quot;)
TODAYDT=$(date +&quot;%d&quot;)

# datestamp at midnight today
TODAYSTARTSTAMP=$(date -j +%s &quot;${TODAYYR}${TODAYMO}${TODAYDT}0000&quot;)

# default lastdump to midnight today; it will be checked
# and and adjusted later
LASTDUMP=$TODAYSTARTSTAMP

# do not crete world-readable dumps!
umask 117

# make sure the logfile exists
if [ ! -e $LOGFILE ] ; then
   touch $LOGFILE
   chmod 660 $LOGFILE
fi

# make sure that entire week's incremental dumps are deposted
# in the same directory, even when a week spans new year
# NOTE: When the ending year has a partial 53rd week, there
# won't be a dump folder for the first week of the new year.
# The incremental dumps instead complete the 53rd week folder,
# even when the 1st week of the new year begins mid-week.
# However, the dates of the incremental dump files in the
# 53rd week folder correctly reflect the dates of the
# beginning year.
adjust_date(){
   local dateoffset=$1
   local epochnow=$(date +%s)
   local offsetsecs=`expr $dateoffset &quot;*&quot; 86400`
   local newepoch=`expr $epochnow &quot;-&quot; $offsetsecs`
   local year=`date -r $newepoch +&quot;%Y&quot;`

   if [ &quot;$WEEKSTARTS&quot; = &quot;Mon&quot; ] ; then
      local week=`date -r $newepoch +&quot;%W&quot;`
   else
      local week=`date -r $newepoch +&quot;%U&quot;`
   fi
   NEWEPOCHISO=`date -r $newepoch +&quot;%Y%m%d0000&quot;`

   #system week starts from `0', there is no calendar week `0'
   week=`expr $week &quot;+&quot; 1`
   YWEEK=${year}-${week}
}

# determines the 'distance' from the level 0 dump in days
if [ &quot;$WEEKSTARTS&quot; = &quot;Mon&quot; ] ; then
   case $WEEKDAY in
      Mon) adjust_date 0;;
      Tue) adjust_date 1;;
      Wed) adjust_date 2;;
      Thu) adjust_date 3;;
      Fri) adjust_date 4;;
      Sat) adjust_date 5;;
      Sun) adjust_date 6;;
      *) ;;
   esac
else
   case $WEEKDAY in
      Sun) adjust_date 0;;
      Mon) adjust_date 1;;
      Tue) adjust_date 2;;
      Wed) adjust_date 3;;
      Thu) adjust_date 4;;
      Fri) adjust_date 5;;
      Sat) adjust_date 6;;
      *) ;;
   esac
fi

mk_auto_dump(){

   local fsname=$1

   # get the current filesystem's path
   # as defined in the corresponding variable
   eval &quot;local fspath=\$${fsname}path&quot;

   # composite the dump path
   local dumppath=${BASEDIR}/${fsname}/${YWEEK}

   # make sure the dump directory for this week exists;
   # this automatically creates a new dump directory on
   # every Monday or Sunday (as selected by 'WEEKSTARTS')
   [ ! -d $dumppath ] &amp;&amp; mkdir -p $dumppath

   # get name of the last file in the current dump directory
   local lastfile=`ls -ltr $dumppath | grep -v &quot;^d&quot; | tail -n 1 | awk '{ print $9 }'`

   # assume that the 'lastfile', if it exists, was not created today
   local dumped_today=false

   # if a file exists, check its modification date;
   # if it is at or after 00:00 today, set a flag to skip the dump
   if [ &quot;$lastfile&quot; != &quot;&quot; ] ; then
      local fq_lastfile=${dumppath}/$lastfile
      if [ -e $fq_lastfile ] ; then
         # get the last modification time for the most recently created dumpfile
         LASTDUMP=`stat -f %m $fq_lastfile`
         if [ $LASTDUMP -ge $TODAYSTARTSTAMP ] ; then
            local dumped_today=true
         fi
      fi

      # get the first and the last dump level for this directory
      local levelcommand=&quot;ls $dumppath | sed -e 's/^[[:digit:]]*\_//' | sed -e 's/\..*$//'&quot;
      local firstlevel=`eval $levelcommand | head -n 1`
      local lastlevel=`eval $levelcommand | tail -n 1`

      # make sure level zero dump exists;
      # if it doesn't, start over
      if [ &quot;$firstlevel&quot; != &quot;0&quot; ] ; then
         # it doesn't matter if a previous dump exists from today
         # since we're starting over as level 0 dump is missing
         local dumped_today=false
         local dumplevel=0
         rm -f $dumppath/*.gz
      else
         # otherwise just increment the dump level
         # for levels 1-6, i.e. normally Tuesday thru Sunday
         local dumplevel=`expr $lastlevel &quot;+&quot; 1`
      fi
   else
      # no dump exists in this week's folder; reset level to '0'
      local dumplevel=0
   fi

   # skip the entire dump process if a dumpfile has
   # already been created for this filesystem today
   if [ &quot;$dumped_today&quot; = &quot;false&quot; ] ; then  

      # define the dump filename
      local dumpfn=${DATE}_${dumplevel}

      echo ---------------- &gt;&gt; $LOGFILE
      echo &gt;&gt; $LOGFILE
      echo BEGINNING LEVEL $dumplevel DUMP OF \'$fsname\' \(${fspath}\) FILESYSTEM ON $HUMANDATE AT $HUMANTIME &gt;&gt; $LOGFILE
      echo &gt;&gt; $LOGFILE
      echo Creating a snapshot of \'$fspath\'.. &gt;&gt; $LOGFILE
      # execute the dump
      $DUMP -$dumplevel -$GLOBALDUMPOPTS -f ${dumppath}/${dumpfn} $fspath &gt;&gt; $LOGFILE 2&gt;&amp;1
      local dumpresult=$?

      if [ &quot;$dumpresult&quot; != &quot;0&quot; ] ; then
         # log the dump result to syslog
         $LOGGER &quot;$DUMP LEVEL $dumplevel DUMP OF $fsname (${fspath}) FAILED!&quot;

         echo &quot;*** DUMP FAILED - LEVEL $dumplevel DUMP of $fsname (${fspath}) ***&quot; &gt;&gt; $LOGFILE
         echo &gt;&gt; $LOGFILE
      else
         # log the dump result to syslog
         $LOGGER &quot;LEVEL $dumplevel DUMP of $fsname (${fspath}) COMPLETED SUCCESSFULLY!&quot;

         echo &gt;&gt; $LOGFILE
         # compress the dump
         echo Compressing the dumpfile \'${dumpfn}\'.. &gt;&gt; $LOGFILE
         $GZIP -v ${dumppath}/${dumpfn} &gt;&gt; $LOGFILE 2&gt;&amp;1
         echo DONE &gt;&gt; $LOGFILE
         echo &gt;&gt; $LOGFILE

         # make sure dumps are not world readable (security risk!)
         echo Updating dumpfile \'${dumpfn}.gz\' permissions.. &gt;&gt; $LOGFILE
         chmod -v -v 440 ${dumppath}/${dumpfn}.gz &gt;&gt; $LOGFILE 2&gt;&amp;1
         echo DONE &gt;&gt; $LOGFILE
         echo &gt;&gt; $LOGFILE

         # reset current dump dir's timestamp to that of the level 0 dump
         touch -t ${NEWEPOCHISO} ${dumppath}

         # delete old dumps
         echo Deleting old \'$fsname\' dumpfiles.. &gt;&gt; $LOGFILE
         find $BASEDIR/$fsname -mtime +$KEEPDUMPS -maxdepth 1 -print -exec rm -rf {} \; &gt;&gt; $LOGFILE 2&gt;&amp;1
         echo DONE &gt;&gt; $LOGFILE
         echo &gt;&gt; $LOGFILE
      fi
   else
      local lastdump_readable=`date -j -r $LASTDUMP +&quot;%H:%M&quot;`
      local lastdump_readableZ=`date -j -r $LASTDUMP +&quot;%Z&quot;`
      local lastdumpmsg=&quot;Autodump for filesystem '$fsname' ($fspath) has already been executed today at $lastdump_readable ($lastdump_readableZ).&quot;
      echo $lastdumpmsg
      $LOGGER $lastdumpmsg
   fi
}

# Dump filesystems defined in 'FSNAMES'
#
# Monday or Sunday (as selected by 'WEEKSTARTS') starts with
# the level 0 dump, with incrementals created through the rest of
# the week (autoincremented). If the level 0 dump is missing in
# the current week's folder for filesystem currently being backed
# up, it is created automatically instead of an incremental dump,
# no matter what day of the week it is.
for f in $FSNAMES
do
   mk_auto_dump $f
done
</pre>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>FreeBSD vs the world</title>
		<link>http://my.galagzee.com/2009/06/22/freebsd-vs-the-world/</link>
		<comments>http://my.galagzee.com/2009/06/22/freebsd-vs-the-world/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 00:59:58 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=225</guid>
		<description><![CDATA[As I upgraded few FreeBSD installations to FreeBSD 7.2 over the last couple of days, I took the customary stroll to see how FreeBSD continues to stack up against the Linux distributions.  And once again I determined it does so &#8230; <a href="http://my.galagzee.com/2009/06/22/freebsd-vs-the-world/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As I upgraded few FreeBSD installations to FreeBSD 7.2 over the last couple of days, I took the customary stroll to see how FreeBSD continues to stack up against the Linux distributions.  And once again I determined it does so very well.  I&#8217;ve been a devout FreeBSD user for almost a decade, and every time I take a look at the Linux world I come back to the same conclusion: I like the fact that there is just one FreeBSD. It&#8217;s very well managed and its QA is excellent (not to mention its TCP stack is famed for being the most stable, and its ports collection rivals anything offered by Linux).</p>
<p>Here&#8217;re couple of useful sites for those wondering which OS to choose:</p>
<p><a href="http://polishlinux.org/choose/comparison/?distro1=FreeBSD&amp;distro2=Debian" target="_blank">Polishlinux.org &#8211; Compare distros: FreeBSD vs. Debian</a> &#8211; Comparison data is up to date and there are a lot of good user comments to sift through. You can also choose other distros to compare to.</p>
<p><a href="http://en.wikipedia.org/wiki/Comparison_of_BSD_operating_systems" target="_blank">Wikipedia &#8211; Comparison of BSD operating systems</a></p>
<p>And lastly, a good example of why the sheer number of Linux distros is disorienting: <a href="http://distrowatch.com/" target="_blank">DistroWatch</a> lists at least a few hundred Linux distros (plus couple of BSD derivatives).</p>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2009/06/22/freebsd-vs-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing bcron on FreeBSD 7.0</title>
		<link>http://my.galagzee.com/2008/06/30/installing-bcron-on-freebsd-70/</link>
		<comments>http://my.galagzee.com/2008/06/30/installing-bcron-on-freebsd-70/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 23:42:46 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[bcron]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[install]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=77</guid>
		<description><![CDATA[bcron is a better cron (though the &#8220;b&#8221; in the name probably comes from the first name of its writer, Bruce Guenter).  It was created with security in mind, and is especially well suited for multi-user systems where the individual &#8230; <a href="http://my.galagzee.com/2008/06/30/installing-bcron-on-freebsd-70/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.untroubled.org/bcron/" target="_blank">bcron</a> is a better cron (though the &#8220;b&#8221; in the name probably comes from the first name of its writer, Bruce Guenter).  It was created with security in mind, and is especially well suited for multi-user systems where the individual users need to be given access to their respective crontabs. With bcron this can be accomplished without compromising the system security.  Here&#8217;s a quote from the bcron page:</p>
<blockquote><p>This is bcron, a new cron system designed with secure operations in mind.  To do this, the system is divided into several seperate programs, each responsible for a seperate task, with strictly controlled communications between them.  The user interface is a drop-in replacement for similar systems (such as vixie-cron), but the internals differ greatly.</p></blockquote>
<p>As of writing of this bcron can not be found in the FreeBSD 7.0 ports system. Fortunately its installation is fairly straightforward.  Yet the included documentation is rather spartan so I provide a more complete outline below.</p>
<ol>
<li><strong>Install latest bglibs if not yet installed</strong>** bglibs is best to install from a <a href="http://www.untroubled.org/bglibs/" target="_blank">downloaded tarball</a> rather than from the ports (while the ports version installs the libs in a more logical location at /usr/local/lib/bglibs/ the programs that utilize the library (bcron, ucspi-unix, etc.) have difficulty locating it.
<p>** few symlinks are required (these refer to the locations bglibs installs itself when compiled from the tarball rather than from the ports):</p>
<p>/usr/local/bglibs -&gt; /usr/local/lib/bglibs<br />
/usr/local/bglibs/lib/libbg-sysdeps.so.2 -&gt; /usr/local/lib/libbg-sysdeps.so.2<br />
/usr/local/bglibs/lib/libbg.so.2 -&gt; /usr/local/lib/libbg.so.2</li>
<li><strong>Install </strong><strong>ucspi-unix if not yet installed </strong>as bcron components communicate via UNIX sockets.<strong> </strong>This requires bglibs and also compiles and installs well using a <a href="http://www.untroubled.org/ucspi-unix/" target="_blank">downloaded tarball</a> (it&#8217;s also available in ports at /usr/ports/sysutils/ucspi-unix, but I prefer to compile it from the downloaded tarball).</li>
<li><strong>Make sure /var has been moved off the root to /usr/var</strong> before proceeding. See an <a href="http://my.galagzee.com/index.php/2008/06/28/moving-var-tmp-off-the-root-in-freebsd/" target="_self">older post</a> for details.</li>
<li><strong>Make sure <a href="http://my.galagzee.com/index.php/2008/06/30/installing-daemontools-service-supervisor-on-freebsd-70/" target="_self">daemontools (and hence supervise) has been installed</a></strong> and is operational as bcron will be started with it.</li>
<li><strong>Create a system user &#8220;cron&#8221; </strong>(for example by using <strong>vipw</strong> command) <strong>and group &#8220;cron&#8221; </strong>(by editing /etc/group). This user/group will own all the crontab files (though not /etc/crontab as it&#8217;s system crontab and needs to be owned by root:wheel).<em> </em><em> </em><em> </em><br />
<em><br />
user:</em><br />
cron:*:50:50::0:0:BCron Sandbox:/nonexistent:/usr/sbin/nologin</p>
<p><em>group:</em><br />
cron:*:50:</li>
<li><strong>Create the spool &amp; tmp directories: </strong><br />
mkdir -p /var/spool/cron/crontabs /var/spool/cron/tmp<br />
mkfifo /var/spool/cron/trigger<br />
sh<br />
for i in crontabs tmp trigger; do<br />
chown cron:cron /var/spool/cron/$i<br />
chmod go-rwx /var/spool/cron/$i<br />
done</li>
<li><strong>Create the configuration directory /usr/local/etc/bcron:</strong>mkdir -p /usr/local/etc/bcron** You can put any common configuration settings into this directory (it is an &#8220;ENVDIR&#8221;), like alternate spool directories in BCRON_SPOOL.</li>
<li><strong>Create the bcron service directories (there are three services) and add the scripts below it:
<p></strong>mkdir -p /var/bcron/supervise/bcron-sched/log<br />
mkdir /var/bcron/supervise/bcron-spool<br />
mkdir /var/bcron/supervise/bcron-update</p>
<p>Set their permissions to 1750 for security purposes (no world access, sticky bit):</p>
<p>chmod 1750 /var/bcron/supervise/bcron-sched<br />
chmod 1750 /var/bcron/supervise/bcron-spool<br />
chmod 1750 /var/bcron/supervise/bcron-update</p>
<p>Make all the run and log/run scripts executable by root, readable by group:</p>
<p>chmod 740 /var/bcron/supervise/bcron-sched/run<br />
chmod 740 /var/bcron/supervise/bcron-sched/log/run<br />
chmod 740 /var/bcron/supervise/bcron-spool/run<br />
chmod 740 /var/bcron/supervise/bcron-update/run</p>
<p>and make log bcron-sched subdir accessible by root, group:</p>
<p>chmod 750 /var/bcron/supervise/bcron-sched/log</p>
<p><strong>RUN SCRIPTS:</strong><br />
<span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-sched/run:</em></span></p>
<p>#!/bin/sh<br />
exec 2&gt;&amp;1<br />
exec envdir /usr/local/etc/bcron bcron-start | multilog t /var/log/bcron</p>
<p><span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-sched/log/run:</em></span></p>
<p>#!/bin/sh<br />
exec &gt;/dev/null 2&gt;&amp;1<br />
exec \<br />
multilog t /var/log/bcron</p>
<p><span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-spool/run:</em></span></p>
<p>#!/bin/sh<br />
exec &gt;/dev/null 2&gt;&amp;1<br />
exec \<br />
envdir /usr/local/etc/bcron \<br />
envuidgid cron \<br />
sh -c &#8216;<br />
exec \<br />
unixserver -U ${BCRON_SOCKET:-/var/run/bcron-spool} \<br />
bcron-spool<br />
&#8216;</p>
<p><span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-update/run:</em></span></p>
<p>#!/bin/sh<br />
exec &gt;/dev/null 2&gt;&amp;1<br />
exec \<br />
bcron-update /etc/crontab</li>
<li><strong>Kill the deafult cron daemon and add the following to rc.conf so it won&#8217;t restart on reboot:</strong>
<p>#disable default cron; bcron is used instead (started by supervise)<br />
cron_enable=&#8221;NO&#8221;</li>
<li><strong>Symlink bcron services&#8217; primary supervise directories to under /var/service to start bcron services (you can also use svc-add command if you have installed supervise-scripts):</strong><br />
ln -s /var/bcron/supervise/bcron-sched /var/service/bcron-sched<br />
ln -s /var/bcron/supervise/bcron-spool /var/service/bcron-spool<br />
ln -s /var/bcron/supervise/bcron-update /var/service/bcron-update</li>
<li><strong>Set /etc/crontab permissions to 600, and make sure it&#8217;s owned by the root.</strong><br />
chmod 600 /etc/crontab<br />
chown root:wheel /etc/crontab</p>
<p>** For other users the owner of the crontab file in their respective home folders would be <strong>cron:cron</strong>.</li>
<li><strong>Edit /etc/crontab and test that it gets updated</strong>. Note that there is a brief delay, perhaps one minute or so, after you save the crontab until the change becomes effective. Also note that the default shell for the crontab is /bin/sh. You might want to change it to something more powerful like c-shell (/bin/csh) or bash (/bin/bash) that you&#8217;re familiar with. You may also want to augment the default path, for example, by including /usr/local/bin for user-installed commands.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2008/06/30/installing-bcron-on-freebsd-70/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving var, tmp Off the Root in FreeBSD</title>
		<link>http://my.galagzee.com/2008/06/28/moving-var-tmp-off-the-root-in-freebsd/</link>
		<comments>http://my.galagzee.com/2008/06/28/moving-var-tmp-off-the-root-in-freebsd/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 21:41:44 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[/tmp]]></category>
		<category><![CDATA[/var]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[moving]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=76</guid>
		<description><![CDATA[One one of the first things I do on a newly installed FreeBSD system is to move /var and /tmp to under /usr. Since I usually allocate about 4Gb for the root slice and the rest of a disk—usually several &#8230; <a href="http://my.galagzee.com/2008/06/28/moving-var-tmp-off-the-root-in-freebsd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One one of the first things I do on a newly installed FreeBSD system is to move <strong>/var</strong> and <strong>/tmp</strong> to under <strong>/usr</strong>. Since I usually allocate about 4Gb for the root slice and the rest of a disk—usually several hundred gigabytes—goes to <strong>/usr</strong> (well, there&#8217;s also the swap slice that takes few gigabytes) having <strong>/var</strong> and <strong>/tmp</strong> there is more comfortable as some log files, database files, or some temp files can sometimes grow to multi-gigabyte size and exhaust the root space.</p>
<p>Below is a simple procedure to move the <strong>/var</strong> to <strong>/usr/var</strong> and <strong>/tmp</strong> to <strong>/usr/var/tmp</strong>. This is best to do early on in a new system installation since many services tend to hook into <strong>/tmp</strong> and/or <strong>/var</strong>, and may thus lock files in those directories making the move more difficult. If you&#8217;re making this move on an established system, at least stop all the services that might interfere with the process (such as database services). It might even be a good idea to boot into a single user mode (if you do so, remember to correctly mount your disks before proceeding). I usually do this early in a new system install, before installing any major services, or at least before scripting them to run.</p>
<ol>
<li><strong>Move /var to /usr/var</strong><br />
<code><br />
mkdir /usr/var<br />
cd /var<br />
tar cvf - . | (cd /usr/var; tar xvf - )<br />
cd /<br />
chflags -R noschg /var<br />
rm -rf /var<br />
ln -s /usr/var /var<br />
</code></li>
<p></p>
<li><strong>Move /tmp to /usr/var/tmp</strong><br />
<code><br />
mkdir /usr/var/tmp<br />
cd /tmp<br />
tar cvf - . | (cd /usr/var/tmp; tar xvf - )<br />
cd /<br />
chflags -R noschg /tmp<br />
rm -rf /tmp<br />
ln -s /usr/var/tmp /tmp<br />
chmod -h 777 /tmp<br />
chmod 1777 /usr/var/tmp<br />
</code></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2008/06/28/moving-var-tmp-off-the-root-in-freebsd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FreeBSD 7.0-RELEASE Kernel Optimization</title>
		<link>http://my.galagzee.com/2008/06/28/freebsd-70-release-kernel-optimization/</link>
		<comments>http://my.galagzee.com/2008/06/28/freebsd-70-release-kernel-optimization/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 09:18:11 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[RELEASE-7.0]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=75</guid>
		<description><![CDATA[Below is my FreeBSD 7.0 kernel configuration file.  I created it on my reference system, to be used on four production servers whose hardware configurations differ some.  For that reason there&#8217;re few options (indicated as &#8220;[OPTION]&#8220;) that are conditional for &#8230; <a href="http://my.galagzee.com/2008/06/28/freebsd-70-release-kernel-optimization/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Below is my FreeBSD 7.0 kernel configuration file.  I created it on my reference system, to be used on four production servers whose hardware configurations differ some.  For that reason there&#8217;re few options (indicated as &#8220;[OPTION]&#8220;) that are conditional for the configurations. I&#8217;ve also left in IPv6 options which are currently commented out, but that I may take into use later if/when IPv6 becomes more prevalent in the environment these servers operate.</p>
<pre class="brush: plain; title: ; notranslate">
#
# INERTIA -- Inertia kernel configuration file for FreeBSD/i386
#
# For more information on this file, please read the handbook section on
# Kernel Configuration Files:
#
#    http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
#
# The handbook is also available locally in /usr/share/doc/handbook
# if you've installed the doc distribution, otherwise always see the
# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
# latest information.
#
# An exhaustive list of options and more detailed explanations of the
# device lines is also present in the ../../conf/NOTES and NOTES files.
# If you are in doubt as to the purpose or necessity of a line, check first
# in NOTES.
#
# Based on
# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.474.2.2.2.1 2008/02/06 03:24:28 scottl Exp $

ident		INERTIA
machine		i386
cpu		I686_CPU

options		SMP 			# Symmetric MultiProcessor Kernel (`device apic' is also required for multiprocessor use)
options 	SCHED_4BSD		# 4BSD scheduler
options 	PREEMPTION		# Enable kernel thread preemption
options 	INET			# InterNETworking
#options 	INET6			# IPv6 communications protocols
options 	FFS			# Berkeley Fast Filesystem
options 	SOFTUPDATES		# Enable FFS soft updates support
options 	UFS_ACL			# Support for access control lists
options 	UFS_DIRHASH		# Improve performance on big dirs
options 	CD9660			# ISO 9660 Filesystem
options 	PROCFS			# Process filesystem (requires PSEUDOFS)
options 	PSEUDOFS		# Pseudo-filesystem framework
options		MSDOSFS			# MSDOS filesystem support (for floppies)
options 	COMPAT_43		# Compatible with BSD 4.3 (required)
options 	COMPAT_FREEBSD4		# Compatible with FreeBSD4
options 	COMPAT_FREEBSD5		# Compatible with FreeBSD5
options 	COMPAT_FREEBSD6		# Compatible with FreeBSD6
options 	SCSI_DELAY=15000	# Delay (in ms) before probing SCSI (TWA/TWE issue)
options 	KTRACE			# ktrace(1) support
options 	SYSVSHM			# SYSV-style shared memory
options 	SYSVMSG			# SYSV-style message queues
options 	SYSVSEM			# SYSV-style semaphores
options 	_KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev, may be needed to hot-plug USB keyboards
options 	AHC_REG_PRETTY_PRINT	# Print register bitfields in debug output
options 	AHD_REG_PRETTY_PRINT	# Print register bitfields in debug output
options 	ADAPTIVE_GIANT		# Giant mutex is adaptive
options		ACCEPT_FILTER_HTTP	# Must be here or AcceptFilter won't work w/Apache2
options		SC_DISABLE_REBOOT	# Disable Ctrl-Alt-Del reboot (this is a server)

device		apic			# I/O APIC (required)
device		npx   			# The Numeric Processing eXtension driver (required)

device		pci
device		isa			# Required by npx

device		fdc			# Floppy drives

device		ata			# ATA and ATAPI devices
device		atadisk			# ATA disk drives
device		ataraid			# ATA RAID drives [OPTION]
device		atapicd			# ATAPI CDROM drives
options 	ATA_STATIC_ID		# Static device numbering

device		scbus			# SCSI bus (required for SCSI, ALSO REQ'D FOR SATA-RAID, USB/umass)
device		da			# Direct Access (disks)
device		pass			# Passthrough device (direct SCSI access)

#device		twe			# 3ware ATA RAID [OPTION]
#device		twa			# 3ware 9000 series PATA/SATA RAID [OPTION]
#options	TWA_DEBUG		# 0-10; 10 prints the most messages; enable for twa debug only

device		atkbdc			# AT keyboard controller
device		atkbd			# AT keyboard
device		kbdmux			# keyboard multiplexer

device		vga			# VGA video card driver
device		sc			# syscons, the default console driver
device		sio			# 8250, 16[45]50 based serial ports

device		ppc			# Parallel port
device		ppbus			# Parallel port bus (required)
device		lpt			# Printer
device		ppi			# Parallel port interface device

#device		miibus			# MII bus support (required by some NICs) [OPTION]
#device		fxp			# Intel EtherExpress PRO/100B (82557, 82558); requires miibus [OPTION]
device		em			# Intel PRO/1000 adapter Gigabit Ethernet Card [OPTION]

options		DEVICE_POLLING		# Imporoves network driver performance

device		coretemp		# On-die temperature sensor on Intel Core and newer CPUs [OPTION]

device		loop			# Network loopback
device		random			# Entropy device
device		ether			# Ethernet support
device		pty			# Pseudo-ttys (telnet etc)
#device		gif			# IPv6 and IPv4 tunneling
#device		faith			# IPv6-to-IPv4 relaying (translation)
device		bpf			# Berkeley packet filter

# USB support [OPTION]
device		uhci			# USB support / UHCI PCI-&gt;USB interface
device		ohci			# USB support / OHCI PCI-&gt;USB interface
device		ehci			# USB support / EHCI PCI-&gt;USB interface (USB 2.0)
device		usb			# USB support / USB Bus (required)
device		ugen			# USB support / Generic
device		uhid			# USB support / &quot;Human Interface Devices&quot;
device		ukbd			# USB support / Keyboard
device		umass			# USB support / Disks/Mass storage - Requires scbus and da

options		COMPAT_LINUX		# Linux compat / Enable Linux ABI emulation
options		COMPAT_AOUT		# Linux compat / Enable i386 a.out binary support
options		LINPROCFS		# Linux compat / Enable procfs support (COMPAT_LINUX / PSEUDOFS)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2008/06/28/freebsd-70-release-kernel-optimization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

