<?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>可可熊的窝 &#187; filesystem</title>
	<atom:link href="http://cocobear.info/blog/tag/filesystem/feed/" rel="self" type="application/rss+xml" />
	<link>http://cocobear.info/blog</link>
	<description>K.I.S.S</description>
	<lastBuildDate>Sun, 31 Jan 2010 14:47:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux下以模块方式安装卸载文件系统</title>
		<link>http://cocobear.info/blog/2008/04/25/linux-install-or-uninstall-filesystem/</link>
		<comments>http://cocobear.info/blog/2008/04/25/linux-install-or-uninstall-filesystem/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 13:48:53 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[filesystem]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/?p=265</guid>
		<description><![CDATA[以Fedora8下面安装minix文件系统为例：
为了保证与系统内核相匹配，首先得获得相应版本的minix源代码，首先通过uname -r查询本机的内核版本：
[cocobear@cocobear ~]$ uname -r
2.6.24.4-64.fc8
在Kernel.org主页上可以获得2.6.24.4-64内核的源代码，其实我们只需要其中linux-2.6.24.4/fs/minix/目录中的代码。因为我们不需要对整个内核进行重新编译，因此我们只需要在linux-2.6.24.4/fs/minix/目录下写一个Makefile，生成相应的minix.ko就可以了。
在开始写Makefile之前要确认系统已经安装了以下的包：
[cocobear@cocobear ~]$ rpm -qa &#124; grep kernel
kernel-devel-2.6.24.4-64.fc8
kernel-headers-2.6.24.4-64.fc8
kernel-2.6.24.4-64.fc8
在模块编译的过程中需要用到。
在源代码中已经有一个Makefile：
#
# Makefile for the Linux minix filesystem routines.
#
obj-$(CONFIG_MINIX_FS) += minix.o
minix-objs := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o
修改该文件为：
#
# Makefile for the Linux minix filesystem routines.
# make minix fs as kernel module
obj-m += minix.o
minix-objs := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o
KERNELDIR:=/lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd)
default:
  [...]]]></description>
			<content:encoded><![CDATA[<p>以Fedora8下面安装minix文件系统为例：</p>
<p>为了保证与系统内核相匹配，首先得获得相应版本的minix源代码，首先通过uname -r查询本机的内核版本：</p>
<p>[cocobear@cocobear ~]$ uname -r<br />
2.6.24.4-64.fc8</p>
<p>在Kernel.org主页上可以获得2.6.24.4-64内核的源代码，其实我们只需要其中<a href="http://cocobear.info/blog/tag/linux/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Linux">linux</a>-2.6.24.4/fs/minix/目录中的代码。因为我们不需要对整个内核进行重新编译，因此我们只需要在<a href="http://cocobear.info/blog/tag/linux/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Linux">linux</a>-2.6.24.4/fs/minix/目录下写一个Makefile，生成相应的minix.ko就可以了。</p>
<p>在开始写Makefile之前要确认系统已经安装了以下的包：<br />
[cocobear@cocobear ~]$ rpm -qa | grep kernel<br />
kernel-devel-2.6.24.4-64.fc8<br />
kernel-headers-2.6.24.4-64.fc8<br />
kernel-2.6.24.4-64.fc8</p>
<p>在模块编译的过程中需要用到。<br />
在源代码中已经有一个Makefile：<br />
#<br />
# Makefile for the <a href="http://cocobear.info/blog/tag/linux/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Linux">Linux</a> minix <a href="http://cocobear.info/blog/tag/filesystem/" class="st_tag internal_tag" rel="tag" title="Posts tagged with filesystem">filesystem</a> routines.<br />
#</p>
<p>obj-$(CONFIG_MINIX_FS) += minix.o</p>
<p>minix-objs := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o</p>
<p>修改该文件为：</p>
<p>#<br />
# Makefile for the <a href="http://cocobear.info/blog/tag/linux/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Linux">Linux</a> minix <a href="http://cocobear.info/blog/tag/filesystem/" class="st_tag internal_tag" rel="tag" title="Posts tagged with filesystem">filesystem</a> routines.<br />
# make minix fs as kernel module</p>
<p>obj-m += minix.o</p>
<p>minix-objs := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o</p>
<p>KERNELDIR:=/lib/modules/$(shell uname -r)/build<br />
PWD:=$(shell pwd)</p>
<p>default:</p>
<p>        make -C $(KERNELDIR)  M=$(PWD) modules</p>
<p>clean:<br />
        rm -rf *.o *.mod.c *.ko *.symvers</p>
<p>这里简单的解释一下，obj-m表示该文件将以模块的方式编译；因为本模块由多个文件组成，采用模块名加 –objs（minix-objs）后缀的形式来定义模块的组成文件。KERNELDIR定义了代码树的位置，PWD定义了当前文件夹位置；而make命令中-C选项指定了代码树的位置（由KERNELDIR给出），M=$(PWD)指定了在当前目前进行构建工作。</p>
<p>最后一行清理编译过程产生的文件。</p>
<p>完成了Makefile后我们就可以开始编译这个文件系统模块了，直接输入make就开始编译了：<br />
[cocobear@cocobear minix]$ make<br />
make -C /lib/modules/2.6.24.4-64.fc8/build  M=/home/cocobear/minix modules<br />
make[1]: Entering directory `/usr/src/kernels/2.6.24.4-64.fc8-i686&#8242;<br />
  CC [M]  /home/cocobear/minix/bitmap.o<br />
  CC [M]  /home/cocobear/minix/itree_v1.o<br />
  CC [M]  /home/cocobear/minix/itree_v2.o<br />
  CC [M]  /home/cocobear/minix/namei.o<br />
  CC [M]  /home/cocobear/minix/inode.o<br />
  CC [M]  /home/cocobear/minix/file.o<br />
  CC [M]  /home/cocobear/minix/dir.o<br />
  LD [M]  /home/cocobear/minix/minix.o<br />
  Building modules, stage 2.<br />
  MODPOST 1 modules<br />
  CC      /home/cocobear/minix/minix.mod.o<br />
  LD [M]  /home/cocobear/minix/minix.ko<br />
make[1]: Leaving directory `/usr/src/kernels/2.6.24.4-64.fc8-i686&#8242;</p>
<p>编译结束后会面当前目前下生成minix.ko文件，这就是我们需要的东西，使用insmod命令就可以安装这个minix文件系统模块了。当然这里需要有root权限。我们来演示一下minix模块的加载：</p>
<p>[cocobear@cocobear minix]$ cat /proc/modules | grep minix<br />
[cocobear@cocobear minix]$ </p>
<p>这里可以看到minix并没有被加载，我们使用insmod minix.ko命令：<br />
[cocobear@cocobear minix]$ sudo insmod minix.ko<br />
[cocobear@cocobear minix]$ cat /proc/modules | grep minix<br />
minix 28676 0 &#8211; Live 0xd0e7d000</p>
<p>insmod后我们从上面的信息可以看到minix模块已经被加载，如果不需要使用这个模块我们同样可以很方便的把它卸载：</p>
<p>[cocobear@cocobear minix]$ sudo rmmod minix.ko<br />
[cocobear@cocobear minix]$ cat /proc/modules | grep minix<br />
[cocobear@cocobear minix]$ </p>
<p>到此我们顺利的完成了文件系统的编译、安装以及卸载。</p>
<p>BTW：中间遇到了点问题写了Makefile后输入make提示：”make: Nothing to be done for `default&#8217;.“，在网上找到了原因，在make命令前要使用tab，而不是空格，而我的刚好的空格，郁闷，以前就似乎遇到过的。</p>
]]></content:encoded>
			<wfw:commentRss>http://cocobear.info/blog/2008/04/25/linux-install-or-uninstall-filesystem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
