Linux文件系统学习笔记 (2)
发表时间:2008-11-26 09:28:48明白了Linux内核的编译和部署过程之后,我们就可以进入文件系统的部分。在进入详细的技术层面之前,我们先简单地熟悉一下操作层面的一些技巧。
将下载到的samplefs.tar.gz解压缩到你的home目录:
cp samplefs.tar.gz ~
cd ~
gunzip samplefs.tar.gz
tar xvf samplefs.tar
编辑Linux内核源代码目录中的fs/Kconfig文件(sudo gedit fs/Kconfig),在if BLOCK语句后面加入下面这些内容:
config SAMPLEFS_FS
tristate "Sample filesystem (EXPERIMENTAL)"
help
Samplefs is a sample filesystem for learning how to build
a simple Linux filesystem
If unsure, say N.
config SAMPLEFS_DEBUG
bool "Additional debugging statements for samplefs"
depends on SAMPLEFS_FS
help
Enabling this option adds a few more debugging routines
to the samplefs code which slightly increases the size of
the samplefs module and can cause additional logging of debug
messages in some error paths, slowing performance. This
option can be turned off unless you are debugging
samplefs problems. If unsure, say N.
然后运行如下命令:
sudo make menuconfig
用箭头键在菜单中移动,选择File Systems,在Sample filesystem (EXPERIMENTAL)选项前面按M,表示我们要将我们自己的文件系统作为独立编译加载的内核模块,然后存盘退出。
按照Steve的教程编译第一个文件系统模块:
sudo make M=~/samplefs/day1
编译完成后在~/samplefs/day1目录下多了一些文件,其中samplefs.ko就是我们需要的模块文件。我们可以用insmod来加载这个新模块:
sudo insmod ~/samplefs/day1/samplefs.ko
用下面这个命令来看看samplefs模块是否已经被加载:
sudo lsmod | grep fs
用下面这个命令在卸载samplefs模块:
sudo rmmod samplefs
顺便说一下,如果你的Linux内核是使用MODVERSIONS=1参数编译的,那么你在编译samplefs模块的时候需要加上同样的参数,也就是:
sudo make MODVEFRSIONS=1 M=~/samplefs/day1
| 上一篇 | 下一篇 |
| 姓名: | |
| 评论: | |
|
请输入下面这首诗词的作者姓名。 白日依山尽,黄河入海流。 |
|
| 答案: | |
云与清风常拥有,
冰雪知音世难求。
击节纵歌相对笑,
案上诗书杯中酒。
2000.12.31 于 洛杉矶