<?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>16hot 的博客 &#187; freebsd</title>
	<atom:link href="http://www.16hot.com/tag/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.16hot.com</link>
	<description>技术、工作、生活，坚持一种信念，一切皆有可能……</description>
	<lastBuildDate>Sat, 07 Jan 2012 11:09:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>FreeBSD 9.0-STABLE + KMS补丁[分享]</title>
		<link>http://www.16hot.com/2011/12/1294/</link>
		<comments>http://www.16hot.com/2011/12/1294/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 12:31:25 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[KMS/GEM]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1294</guid>
		<description><![CDATA[由于kib提供的KMS补丁是基于HEAD版本的，有人提取了9.0-STABLE的版本补丁出来。 下面是原始下载地址： https://docs.google.com/open?id=0BxbPi2OX4_B-NDcwZGI1OTAtOTQxOC00YmMxLTg5ZjEtNmIxYTY0M2I0OWI5 访问不了docs.google.com 兄弟，可以从下面地址下载： http://www.16hot.com/tmp/drm-all.12.3-stable9.patch 打补丁： 代码: # cd /usr/src # patch -p3 < drm-all.12.3-stable9.patch 之后是编译和安装内核…… 注：我已经使用12.3版本一天左右时间，目前没有发现异常。之前是一直用10.3。]]></description>
			<content:encoded><![CDATA[<p>由于kib提供的KMS补丁是基于HEAD版本的，有人提取了9.0-STABLE的版本补丁出来。 </p>
<p>下面是原始下载地址： </p>
<p>https://docs.google.com/open?id=0BxbPi2OX4_B-NDcwZGI1OTAtOTQxOC00YmMxLTg5ZjEtNmIxYTY0M2I0OWI5</p>
<p>访问不了docs.google.com 兄弟，可以从下面地址下载： </p>
<p>http://www.16hot.com/tmp/drm-all.12.3-stable9.patch</p>
<p>打补丁：<br />
代码:</p>
<p># cd /usr/src<br />
# patch -p3 < drm-all.12.3-stable9.patch </p>
<p>之后是编译和安装内核…… </p>
<p>注：我已经使用12.3版本一天左右时间，目前没有发现异常。之前是一直用10.3。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/12/1294/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>解决FreeBSD下编译LuaJIT的问题</title>
		<link>http://www.16hot.com/2011/10/1287/</link>
		<comments>http://www.16hot.com/2011/10/1287/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 15:30:47 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[LUA]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[luajit]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1287</guid>
		<description><![CDATA[在FreeBSD下编译LuaJIT时，报如下错误： CC lj_err.o lj_err.c:189:20: error: unwind.h: No such file or directory lj_err.c:199: error: expected declaration specifiers or '...' before '_Unwind_Action' lj_err.c:200: error: expected declaration specifiers or '...' before '_Unwind_Exception_Class' lj_err.c:201: warning: 'struct _Unwind_Context' declared inside parameter list lj_err.c:201: warning: its scope is only this definition or declaration, which is probably not what you want lj_err.c:201: [...]]]></description>
			<content:encoded><![CDATA[<p>在FreeBSD下编译LuaJIT时，报如下错误：<br />
<code><br />
CC        lj_err.o<br />
lj_err.c:189:20: error: unwind.h: No such file or directory<br />
lj_err.c:199: error: expected declaration specifiers or '...' before '_Unwind_Action'<br />
lj_err.c:200: error: expected declaration specifiers or '...' before '_Unwind_Exception_Class'<br />
lj_err.c:201: warning: 'struct _Unwind_Context' declared inside parameter list<br />
lj_err.c:201: warning: its scope is only this definition or declaration, which is probably not what you want<br />
lj_err.c:201: warning: 'struct _Unwind_Exception' declared inside parameter list<br />
lj_err.c: In function 'lj_err_unwind_dwarf':<br />
lj_err.c:206: error: '_URC_FATAL_PHASE1_ERROR' undeclared (first use in this function)<br />
lj_err.c:206: error: (Each undeclared identifier is reported only once<br />
lj_err.c:206: error: for each function it appears in.)<br />
lj_err.c:207: error: 'uexclass' undeclared (first use in this function)<br />
lj_err.c:208: warning: implicit declaration of function '_Unwind_GetCFA'<br />
lj_err.c:208: warning: cast to pointer from integer of different size<br />
lj_err.c:210: error: 'actions' undeclared (first use in this function)<br />
lj_err.c:210: error: '_UA_SEARCH_PHASE' undeclared (first use in this function)<br />
lj_err.c:213: error: '_URC_CONTINUE_UNWIND' undeclared (first use in this function)<br />
lj_err.c:218: error: '_URC_HANDLER_FOUND' undeclared (first use in this function)<br />
lj_err.c:220: error: '_UA_CLEANUP_PHASE' undeclared (first use in this function)<br />
lj_err.c:225: error: '_UA_HANDLER_FRAME' undeclared (first use in this function)<br />
lj_err.c:226: warning: implicit declaration of function '_Unwind_DeleteException'<br />
lj_err.c:231: error: '_UA_FORCE_UNWIND' undeclared (first use in this function)<br />
lj_err.c:234: warning: implicit declaration of function '_Unwind_SetGR'<br />
lj_err.c:235: warning: implicit declaration of function '_Unwind_SetIP'<br />
lj_err.c:235: error: '_Unwind_Ptr' undeclared (first use in this function)<br />
lj_err.c:238: error: '_URC_INSTALL_CONTEXT' undeclared (first use in this function)<br />
lj_err.c:246: error: expected ')' before 'lj_vm_unwind_rethrow'<br />
lj_err.c: In function 'err_raise_ext':<br />
lj_err.c:271: error: invalid use of undefined type 'struct _Unwind_Exception'<br />
lj_err.c:271: error: '_Unwind_Exception_Class' undeclared (first use in this function)<br />
lj_err.c:272: error: invalid use of undefined type 'struct _Unwind_Exception'<br />
lj_err.c:273: warning: implicit declaration of function '_Unwind_RaiseException'<br />
gmake: *** [lj_err.o] 错误 1<br />
</code></p>
<p>只需要拷贝一个头文件，并且改名即可：</p>
<p>/usr/src/contrib/gcc/unwind-generic.h /usr/include/unwind.h</p>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/10/1287/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeBSD下根据进程名称获取PID</title>
		<link>http://www.16hot.com/2011/10/1272/</link>
		<comments>http://www.16hot.com/2011/10/1272/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 07:44:40 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[KVM]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1272</guid>
		<description><![CDATA[想通过进程名称来监控进程是否健在，在网上找了一个小例子，改成如下： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [...]]]></description>
			<content:encoded><![CDATA[<p>想通过进程名称来监控进程是否健在，在网上找了一个小例子，改成如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**
 * 
 * gcc getproc.c -I/usr/include -I/usr/local/include -L/usr/lib/ -L/usr/local/lib/ -lkvm -o getproc
 */</span>
&nbsp;
<span style="color: #339933;">#include &lt;stdio.h&gt;   </span>
<span style="color: #339933;">#include &lt;string.h&gt;   </span>
<span style="color: #339933;">#include &lt;err.h&gt;   </span>
<span style="color: #339933;">#include &lt;kvm.h&gt;   </span>
<span style="color: #339933;">#include &lt;sys/param.h&gt;   </span>
<span style="color: #339933;">#include &lt;sys/sysctl.h&gt;   </span>
<span style="color: #339933;">#include &lt;sys/user.h&gt;   </span>
<span style="color: #339933;">#include &lt;sys/param.h&gt;   </span>
<span style="color: #339933;">#include &lt;fcntl.h&gt;   </span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;   </span>
<span style="color: #339933;">#include &lt;sysexits.h&gt;    </span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span>  
get_pid_of_process<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>process_name<span style="color: #009900;">&#41;</span>   
<span style="color: #009900;">&#123;</span>   
 <span style="color: #993333;">static</span> kvm_t <span style="color: #339933;">*</span>kd <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>   
 <span style="color: #993333;">struct</span> kinfo_proc <span style="color: #339933;">*</span>p<span style="color: #339933;">;</span>   
 <span style="color: #993333;">int</span> i<span style="color: #339933;">,</span> n_processes<span style="color: #339933;">,</span> processes_found<span style="color: #339933;">;</span>   
 processes_found <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>   
&nbsp;
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>kd <span style="color: #339933;">=</span> kvm_open<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;/dev/null&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;/dev/null&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;/dev/null&quot;</span><span style="color: #339933;">,</span> O_RDONLY<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;kvm_open&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> NULL<span style="color: #009900;">&#41;</span>    
    <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>errx<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> kvm_geterr<span style="color: #009900;">&#40;</span>kd<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
 <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>   
  p <span style="color: #339933;">=</span> kvm_getprocs<span style="color: #009900;">&#40;</span>kd<span style="color: #339933;">,</span> KERN_PROC_PROC<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>n_processes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> n_processes<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>   
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>strncmp<span style="color: #009900;">&#40;</span>process_name<span style="color: #339933;">,</span> p<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">ki_comm</span><span style="color: #339933;">,</span> COMMLEN<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
    <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;progame: %s, pid: %d <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> process_name<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>p<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">ki_pid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
    processes_found<span style="color: #339933;">++;</span>   
   <span style="color: #009900;">&#125;</span>   
<span style="color: #666666; font-style: italic;">//~ if (p[i].ki_pid == pid){</span>
  <span style="color: #666666; font-style: italic;">//~ (void)printf(&quot;%s &quot;, p[i].ki_comm);</span>
  <span style="color: #666666; font-style: italic;">//~ processes_found++;</span>
 <span style="color: #666666; font-style: italic;">//~ }</span>
  kvm_close<span style="color: #009900;">&#40;</span>kd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">return</span> processes_found<span style="color: #339933;">;</span>   
<span style="color: #009900;">&#125;</span>   
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span> <span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span>argv <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> pf <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> argc <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">2</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;Please input a process name!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    pf <span style="color: #339933;">=</span> get_pid_of_process<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;have found %d proess<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> pf <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/10/1272/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>升级内存！！</title>
		<link>http://www.16hot.com/2011/08/1250/</link>
		<comments>http://www.16hot.com/2011/08/1250/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 10:25:20 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[16hot 杂记]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[ZFS]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1250</guid>
		<description><![CDATA[笔记本一直在用4G的内存，用FreeBSD 8的时候，没有用ZFS，4G内存就足够了。 自从换成FreeBSD9，用ZFS后，内存就很紧张。常常要用上交换分区，系统就变得特别慢。太痛苦了！！ 最近内存价格降得很厉害，犹豫再三后，决定再买条4G的内存换上去。想在是6G内存了。呵呵 观测看看，还会不会内存不够用，再不够，再换成8G内存。]]></description>
			<content:encoded><![CDATA[<p>笔记本一直在用4G的内存，用FreeBSD 8的时候，没有用ZFS，4G内存就足够了。</p>
<p>自从换成FreeBSD9，用ZFS后，内存就很紧张。常常要用上交换分区，系统就变得特别慢。太痛苦了！！</p>
<p>最近内存价格降得很厉害，犹豫再三后，决定再买条4G的内存换上去。想在是6G内存了。呵呵</p>
<p>观测看看，还会不会内存不够用，再不够，再换成8G内存。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/08/1250/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关注FreeBSD下的新版CARP</title>
		<link>http://www.16hot.com/2011/08/1241/</link>
		<comments>http://www.16hot.com/2011/08/1241/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 01:13:59 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[carp]]></category>
		<category><![CDATA[freebsd]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1241</guid>
		<description><![CDATA[http://lists.freebsd.org/pipermail/freebsd-net/2011-August/029539.html http://people.freebsd.org/~glebius/newcarp/README Hello networkers, I'd like to present for review and early testing (for brave ones) a new CARP implementation. The reason for this rewrite was that CARP protocol actually doesn't bring a new interface, but is a property of interface address. Rewriting it in this way helps to remove several hacks from incoming packet [...]]]></description>
			<content:encoded><![CDATA[<p>http://lists.freebsd.org/pipermail/freebsd-net/2011-August/029539.html</p>
<p>http://people.freebsd.org/~glebius/newcarp/README</p>
<blockquote>
<pre>  Hello networkers,

  I'd like to present for review and early testing (for brave ones)
a new CARP implementation. The reason for this rewrite was that CARP
protocol actually doesn't bring a new interface, but is a property of
interface address. Rewriting it in this way helps to remove several
hacks from incoming packet processing[1], simplifies some code, makes
CARP addresses more sane from viewpoint of routing daemons such as
quagga/zebra. It also brings support for a single redundant address
on the subnet, the thing that is called "carpdev feature" in OpenBSD,
long awaited in FreeBSD.

More info and the patch itself is available here:

<a href="http://people.freebsd.org/%7Eglebius/newcarp/README">http://people.freebsd.org/~glebius/newcarp/README</a>

I'm glad to here comments.</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/08/1241/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关注KMS/GEM进展</title>
		<link>http://www.16hot.com/2011/07/1230/</link>
		<comments>http://www.16hot.com/2011/07/1230/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 14:28:48 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[KMS/GEM]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1230</guid>
		<description><![CDATA[已经有人在做需要KMS支持的X相关的ports了。 http://trillian.chruetertee.ch/ports/browser/branches/xorg-dev https://trillian.chruetertee.ch/svn/ports/branches/xorg-dev/]]></description>
			<content:encoded><![CDATA[<p>已经有人在做需要KMS支持的X相关的ports了。</p>
<p>http://trillian.chruetertee.ch/ports/browser/branches/xorg-dev</p>
<p>https://trillian.chruetertee.ch/svn/ports/branches/xorg-dev/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/07/1230/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeBSD-9 Current ZFS安装</title>
		<link>http://www.16hot.com/2011/07/1304/</link>
		<comments>http://www.16hot.com/2011/07/1304/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 03:01:26 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[KMS/GEM]]></category>
		<category><![CDATA[ZFS]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1304</guid>
		<description><![CDATA[最近特别忙，先将安装部分帖上，迟些整理完KMS/GEM部分，再帖到WIKI上。 下载 从FreeBSD官方的目录没有找到AMD64版本的，从下面地址找： http://pub.allbsd.org/FreeBSD-snapshots/ http://pub.allbsd.org/FreeBSD-snapshots/amd64-amd64/9.0-HEAD-20110711-JPSNAP 安装 用光盘启动后，选择模式，提示login: 的时候，直接输入root回车就可以了。 创建分区 如果是旧硬盘，里面有数据，需要擦除的话，可以使用如下方法： 如果需要，此时用dd抹除硬盘内容， 例如 dd if=/dev/zero of=/dev/ada0 bs=1m count=1 代码: gpart create -s gpt ada0 （重复此步直到所有硬盘皆包含GPT分区表） gpart add -s 64K -t freebsd-boot ada0 （实际上只有启动盘需要，不过64K空间对现代硬盘来说基本上可以忽略不计） gpart add -s 4G -t freebsd-swap -l swap0 ada0 （根据需要酌情配置） gpart add -t freebsd-zfs -l zdisk ada0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot [...]]]></description>
			<content:encoded><![CDATA[<p>最近特别忙，先将安装部分帖上，迟些整理完KMS/GEM部分，再帖到WIKI上。 </p>
<p>下载<br />
从FreeBSD官方的目录没有找到AMD64版本的，从下面地址找： </p>
<p>http://pub.allbsd.org/FreeBSD-snapshots/</p>
<p>http://pub.allbsd.org/FreeBSD-snapshots/amd64-amd64/9.0-HEAD-20110711-JPSNAP</p>
<p>安装 </p>
<p>用光盘启动后，选择<Live>模式，提示login: 的时候，直接输入root回车就可以了。 </p>
<p>创建分区 </p>
<p>如果是旧硬盘，里面有数据，需要擦除的话，可以使用如下方法：<br />
如果需要，此时用dd抹除硬盘内容，<br />
例如 dd if=/dev/zero of=/dev/ada0 bs=1m count=1 </p>
<p>代码:<br />
gpart create -s gpt ada0 （重复此步直到所有硬盘皆包含GPT分区表）<br />
gpart add -s 64K -t freebsd-boot ada0 （实际上只有启动盘需要，不过64K空间对现代硬盘来说基本上可以忽略不计）<br />
gpart add -s 4G -t freebsd-swap -l swap0 ada0 （根据需要酌情配置）<br />
gpart add -t freebsd-zfs -l zdisk ada0<br />
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0</p>
<p>接下来是创建ZFS pool了。这时候有个关键点。如果硬盘支持4k扇区，那将zpool设置为4k扇区支持，磁盘性能将提升一倍。具体参考dj的文章：https://blog.delphij.net/2011/01/-neptune-zfs.html </p>
<p>代码:<br />
硬盘支持4k扇区时的：<br />
gnop create -S 4096 /dev/gpt/zdisk<br />
zpool create -f zdisk /dev/gpt/zdisk.nop </p>
<p>代码:<br />
如果硬盘不支持4K扇区，方法如下<br />
zpool create -f zdisk /dev/gpt/zdisk</p>
<p>注意：创建zpool时会提示“cannot mount &#8216;/zdisk&#8217;: failed to create mountpoint”，直接忽略它。 </p>
<p>代码:</p>
<p>zpool set bootfs=zdisk zdisk<br />
zfs set checksum=fletcher4 zdisk<br />
zfs set mountpoint=/mnt zdisk </p>
<p>zfs create zdisk/var<br />
zfs create zdisk/usr<br />
zfs create zdisk/home<br />
zfs create zdisk/tmp</p>
<p>注意：创建分区时提示“cannot mount &#8216;/mnt/usr&#8217;: failed to create mountpoint<br />
filesystem successfully create, but not mounted”<br />
这些信息直接忽略。 </p>
<p>更多的分区，可以根据自己的需要创建，设置可以使用ZFS的更多特性，如压缩等。 </p>
<p>接下来是导出和导入ZFS分区：<br />
代码:</p>
<p>zpool export zdisk<br />
zpool import -o cachefile=/tmp/zpool.cache zdisk</p>
<p>安装系统 </p>
<p>安装基本系统<br />
代码:<br />
sh<br />
cd /usr/freebsd-dist<br />
export DESTDIR=/mnt<br />
for file in base.txz lib32.txz kernel.txz doc.txz src.txz;<br />
do (cat $file | tar &#8211;unlink -xpJf &#8211; -C ${DESTDIR:-/}); done </p>
<p>拷贝zpool.cache文件<br />
cp /tmp/zpool.cache /mnt/boot/zfs/zpool.cache<br />
提示：这步一定要做，否则启动时找不到分区。 </p>
<p>配置ZFS相关设置<br />
代码:<br />
cat <<EOF> /mnt/etc/rc.conf<br />
zfs_enable=&#8221;YES&#8221;<br />
hostname=&#8221;gptzfsboot.16hot.com&#8221;<br />
defaultrouter=&#8221;192.168.56.1&#8243;<br />
ifconfig_em0=&#8221;inet 192.168.56.13 netmask 255.255.255.0&#8243;<br />
EOF</p>
<p>提示： zfs_enable=&#8221;YES&#8221;这行是必须的，下面的配置主机名、网络部分，可以启动后配置。 </p>
<p>代码:</p>
<p>cat <<EOF> /mnt/boot/loader.conf<br />
zfs_load=&#8221;YES&#8221;<br />
vfs.root.mountfrom=&#8221;zfs:zdisk<br />
vfs.root.mountfrom.options=&#8221;rw&#8221;<br />
vfs.zfs.prefetch_disable=0<br />
EOF </p>
<p>cat <<EOF> /mnt/etc/fstab<br />
# Device                       Mountpoint              FStype  Options         Dump    Pass#<br />
/dev/gpt/swap0                 none                    swap    sw              0       0<br />
EOF</p>
<p>代码:</p>
<p>zfs set readonly=on zdisk/var/empty<br />
zfs unmount -a </p>
<p>zfs set mountpoint=legacy zdisk<br />
zfs set mountpoint=/tmp zdisk/tmp<br />
zfs set mountpoint=/usr zdisk/usr<br />
zfs set mountpoint=/var zdisk/var</p>
<p>至此已经安装完基本系统了。直接reboot 重启就行。 </p>
<p>如果重启过程有异常，不能正常启动，那得从头检查看看是那个环节出错了。我也因为某个环节出错，反复尝试，折腾了一整个下午才搞定。 </p>
<p>应用KMS/GEM </p>
<p>重启后，为了使用KMS/GEM补丁，接下来就需要自己更新源码和重新编译系统和内核了。<br />
在开始这部分之前，最好仔细看看 http://wiki.freebsd.org/Intel_GPU 。目前这个补丁还是内部开发过程，还不是正式测试阶段，功能还不完善，而且难免还有很多未知BUG。<br />
代码:</p>
<p>cat <<EOF> /root/stable-supfile<br />
*default host=cvsup10.tw.freebsd.org<br />
*default base=/usr<br />
*default prefix=/usr<br />
*default release=cvs tag=.<br />
*default delete use-rel-suffix<br />
*default compress<br />
src-all<br />
EOF </p>
<p>csup /root/stable-supfile</p>
<p>下载KMS补丁<br />
到 http://people.freebsd.org/~kib/drm/ 找个最新的版本。<br />
我当时最新的是 all.5.6.patch ，因此我下载的是 all.5.6.patch 。 </p>
<p>代码:<br />
cd /usr/src<br />
mkdir drm<br />
cd drm<br />
fetch http://people.freebsd.org/~kib/drm/all.5.6.patch<br />
fetch http://people.freebsd.org/~kib/drm/libdrm.1.patch </p>
<p>打补丁<br />
cd /usr/src<br />
patch -p1 < ./drm/all.5.6.patch </p>
<p>代码:<br />
cat <<EOF> /usr/src/mk.sh<br />
#!/bin/sh<br />
cd /usr/src<br />
make -j2 buildworld &#038;&#038; make -j2 buildkernel &#038;&#038; make installworld &#038;&#038; make installkernel<br />
EOF </p>
<p>chmod +x /usr/src/mk.sh </p>
<p>time /usr/src/mk.sh </p>
<p>接下来就是等着编译完成，然后重启到新系统了。这里没有配置内核，因为使用KMS补丁不需要进行什么特定的内核配置。如果自己需要，可以根据自己的情况配置下。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/07/1304/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用上FreeBSD9-current + KMS/GEM 补丁了</title>
		<link>http://www.16hot.com/2011/07/1227/</link>
		<comments>http://www.16hot.com/2011/07/1227/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 12:42:56 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[KMS/GEM]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1227</guid>
		<description><![CDATA[由于FreeBSD8.x还没有支持KMS/GEM，而无法使用intel的最新显卡驱动程序，无法很好的驱动X201i的集成显卡。使用Vesa驱动虽然能使用Xorg ，但是性能很差，屏幕刷新稍微快些，就耗CPU 100％。而且另外还有个很严重的问题，就是不支持外接显示器，更别说用投影仪了。 后来在2月份，看到freebsd官方公告说支持KMS/GEM项目研发。而7月初，KMS/GEM的补丁出来了，虽然还不是正式的测试版本。 居于上面的两点，一个是性能，一个是不能用投影。特别是不能使用投影仪，对日常工作多少有些影响，带来不便，特别是要给客户做演示的时候，只能使用同事的电脑，极其不便。看到KMS/GEM补丁之后，就开始动心了。 可是KMS/GEM补丁只能在FreeBSD9上使用，而FreeBSD9又没有进入Beta版，还是处于开发阶段。对于其稳定性实在没有什么把握，于是买了块新的500G笔记本硬盘用于安装FreeBSD9。原来的硬盘安装的FreeBSD-8-stable保留起来，可以随时切换。 这次安装FreeBSD9，直接使用ZFS文件系统。回头再写个安装文档。 使用KMS/GEM补丁，参考FreeBSD的wiki上的文档 http://wiki.freebsd.org/Intel_GPU 。不过intel的显卡驱动，从git获取的源码编译不通过，单独下了个xf86-video-intel-2.15.0版本使用。 安装配置好后，按平时的使用检测了下。性能确实提升很大，开启gnome2，编译东西时不再卡。而且用Vbox下用PPS看高清电影，也不卡了。而且CPU使用率只在20－30％。以前得80％以上。 其次，可以使用外接显示器了。 不过目前的KMS/GEM补丁还没有进入正式测试阶段，还是属于内部研发阶段，BUG是避免不了的。目前我遇到的问题是，启动X后，切换不回去终端界面了，被模糊的图形覆盖了。 总体而言，FreeBSD9支持KMS/GEM后，在笔记本上使用，更爽了。期待早日发布稳定版本。]]></description>
			<content:encoded><![CDATA[<p>由于FreeBSD8.x还没有支持KMS/GEM，而无法使用intel的最新显卡驱动程序，无法很好的驱动X201i的集成显卡。使用Vesa驱动虽然能使用Xorg ，但是性能很差，屏幕刷新稍微快些，就耗CPU 100％。而且另外还有个很严重的问题，就是不支持外接显示器，更别说用投影仪了。</p>
<p>后来在2月份，看到freebsd官方公告说支持KMS/GEM项目研发。而7月初，KMS/GEM的补丁出来了，虽然还不是正式的测试版本。</p>
<p>居于上面的两点，一个是性能，一个是不能用投影。特别是不能使用投影仪，对日常工作多少有些影响，带来不便，特别是要给客户做演示的时候，只能使用同事的电脑，极其不便。看到KMS/GEM补丁之后，就开始动心了。</p>
<p>可是KMS/GEM补丁只能在FreeBSD9上使用，而FreeBSD9又没有进入Beta版，还是处于开发阶段。对于其稳定性实在没有什么把握，于是买了块新的500G笔记本硬盘用于安装FreeBSD9。原来的硬盘安装的FreeBSD-8-stable保留起来，可以随时切换。</p>
<p>这次安装FreeBSD9，直接使用ZFS文件系统。回头再写个安装文档。</p>
<p>使用KMS/GEM补丁，参考FreeBSD的wiki上的文档 http://wiki.freebsd.org/Intel_GPU 。不过intel的显卡驱动，从git获取的源码编译不通过，单独下了个xf86-video-intel-2.15.0版本使用。</p>
<p>安装配置好后，按平时的使用检测了下。性能确实提升很大，开启gnome2，编译东西时不再卡。而且用Vbox下用PPS看高清电影，也不卡了。而且CPU使用率只在20－30％。以前得80％以上。</p>
<p>其次，可以使用外接显示器了。</p>
<p>不过目前的KMS/GEM补丁还没有进入正式测试阶段，还是属于内部研发阶段，BUG是避免不了的。目前我遇到的问题是，启动X后，切换不回去终端界面了，被模糊的图形覆盖了。</p>
<p>总体而言，FreeBSD9支持KMS/GEM后，在笔记本上使用，更爽了。期待早日发布稳定版本。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/07/1227/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>磁盘分区挂载表</title>
		<link>http://www.16hot.com/2011/07/1221/</link>
		<comments>http://www.16hot.com/2011/07/1221/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 02:02:23 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ufs]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1221</guid>
		<description><![CDATA[FreeBSD系统下的分区挂载表。 % cat /etc/fstab # Device        Mountpoint    FStype    Options        Dump    Pass# /dev/ada0s1b        none        swap    sw        0    0 /dev/ada0s1a        /        ufs    rw        1    1 /dev/ada0s3e        /opt        ufs    rw        2    2 /dev/ada0s2e        /opt/data        ufs    rw        2    2 /dev/ada0s2d        /opt/vm1        ufs    rw   [...]]]></description>
			<content:encoded><![CDATA[<p>FreeBSD系统下的分区挂载表。</p>
<blockquote><p>% cat /etc/fstab<br />
# Device        Mountpoint    FStype    Options        Dump    Pass#<br />
/dev/ada0s1b        none        swap    sw        0    0<br />
/dev/ada0s1a        /        ufs    rw        1    1<br />
/dev/ada0s3e        /opt        ufs    rw        2    2<br />
/dev/ada0s2e        /opt/data        ufs    rw        2    2<br />
/dev/ada0s2d        /opt/vm1        ufs    rw        2    2<br />
/dev/ada0s3d        /opt/vm2        ufs    rw        2    2<br />
/dev/ada0s1d        /tmp        ufs    rw        2    2<br />
/dev/ada0s1f        /usr        ufs    rw        2    2<br />
/dev/ada0s1e        /var        ufs    rw        2    2<br />
/dev/cd0        /cdrom        cd9660    ro,noauto    0    0<br />
proc            /proc       procfs  rw 0 0<br />
linprocfs /compat/linux/proc linprocfs rw 0 0</p></blockquote>
<h1><a id="如何在linux中mount_ufs2文件系统" name="如何在linux中mount_ufs2文件系统">如何在linux中mount ufs2文件系统？</a></h1>
<div>
<p>FreeBSD的默认文件系统是ufs2。 可以用:</p>
<pre>mount -r -t ufs -o ufstype=ufs2 /dev/hda10 /mnt</pre>
<p>这样的命令来挂载。</p>
<p>前提：Linux内核中必须启用ufs和bsd disk label支持. 即</p>
<pre>CONFIG_BSD_DISKLABEL=y
CONFIG_UFS_FS=y
CONFIG_UFS_FS_WRITE=y</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/07/1221/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pf rtables and setfib in FreeBSD</title>
		<link>http://www.16hot.com/2011/07/1218/</link>
		<comments>http://www.16hot.com/2011/07/1218/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 14:20:08 +0000</pubDate>
		<dc:creator>16hot</dc:creator>
				<category><![CDATA[BSD/linux]]></category>
		<category><![CDATA[转载]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[pf]]></category>
		<category><![CDATA[setfib]]></category>

		<guid isPermaLink="false">http://www.16hot.com/?p=1218</guid>
		<description><![CDATA[If one has multiple outgoing links to which one would like to use different routing tables the FreeBSD provides possibility through the setfib command but in order to have multiple routing tables one has to first compile a custom kernel with option ROUTETABLES in example simple kernel config: include GENERIC options ROUTETABLES=4 After the kernel [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>If one has multiple outgoing links to which one would like to  use different routing tables the FreeBSD provides possibility through  the setfib command but in order to have multiple routing tables one has  to first compile a custom kernel with option ROUTETABLES in example  simple kernel config:</p>
<pre>include GENERIC
options         ROUTETABLES=4</pre>
<p>After the kernel has been built and rebooted the different routing  tables can be accessed as shown in the setfib(1) man page by issuing  command setfib 0 netstat -rn. 0 is the default routing table.</p>
<p>After this one has to create the second routing table by prepending every route add command with setfib 1 route add… e.g:</p>
<pre># setfib 1 route add -net default 10.0.0.1</pre>
<p>With packet filter one can control how the routing table is selected  by using rtable option but it should be noted that this selection can  only be done on the input of the packets as the routing decision is done  at the input not at the output. Here is an example of very simple  pf.conf that uses rtable rules and NATs everything to the external  interface address:</p>
<pre>#
# Macros
#
INT_IF = "em0"
EXT_IF = "bge0"
EXT_IF2 = "bge1"

table &lt;private_nets&gt; persist { 127/8, 172.16/12, 192.168/16, 169.254/16 }

#
# Options and default policy
#
set block-policy drop
set state-policy if-bound

#
# Packet normalization
#
scrub in                          all
scrub out on $EXT_IF all random-id
scrub        on $EXT_IF all reassemble tcp

#
# NAT/redirects
#

# NAT
nat on $EXT_IF from &lt;private_nets&gt; to any -&gt; ($EXT_IF)
nat on $EXT_IF2 from &lt;private_nets&gt; to any -&gt; ($EXT_IF2)

#
# Filter rules
#
pass all
pass in from 192.168.100.0/24 to any rtable 0
pass in from 192.168.150.0/24 to any rtable 1</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.16hot.com/2011/07/1218/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

