📄 file_systems.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head> <title></title> <link rel="stylesheet" media="screen" type="text/css" href="./style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="./design.css" /> <link rel="stylesheet" media="print" type="text/css" href="./print.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="clear"><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#file_systems" class="toc">File Systems</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#looking_at_filesystems" class="toc">Looking at Filesystems</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#useful_filesystems" class="toc">Useful Filesystems</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#the_superblock" class="toc">The Superblock</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#creating_a_filesystem" class="toc">Creating a Filesystem</a></span></div></li></ul></li><li class="level2"><div class="li"><span class="li"><a href="#file_system_exampledebugfs" class="toc">File System Example: Debugfs</a></span></div></li></ul></li></ul></div></div><h2><a name="file_systems" id="file_systems">File Systems</a></h2><div class="level2"><p> A file system is a method to describe the data layout found on some physical media. There are also things called pseudo filesystems which use the features of the file system interface to access or manage some kernel functions.</p><p>Probably one of the most excellent features of Linux is its ability to dynamically add different filesystem types to the kernel.</p><p>This means that when you plug in your USB Drive the kernel detects the device and also tries to access this by adding the correct file systems to the kernel.</p></div><!-- SECTION [1-546] --><h3><a name="looking_at_filesystems" id="looking_at_filesystems">Looking at Filesystems</a></h3><div class="level3"><p> The command <strong>cat /proc/filesystems</strong> is a good way to see what the kernel understands. The size of this list is a good indication of how much filesystems are used.</p><pre class="code c"> Output of cat /proc/filesystems <span class="br0">(</span> from an X86 system <span class="br0">)</span> ext3nodev sysfsnodev rootfsnodev bdevnodev procnodev sockfsnodev futexfsnodev tmpfsnodev pipefsnodev eventpollfsnodev devpts ext2nodev ramfsnodev hugetlbfs minix iso9660nodev nfsnodev mqueuenodev rpc_pipefs reiserfsnodev usbfsnodev usbdevfsnodev subfsnodev nfsd vfat</pre><p>The <strong>nodev</strong> filesystems are pseudo filesystems that do not have direct access to some storage device.</p></div><!-- SECTION [547-1300] --><h3><a name="useful_filesystems" id="useful_filesystems">Useful Filesystems</a></h3><div class="level3"><p> This is a summary of the more useful filesystems directly used by the embedded developer. </p><table class="inline"> <tr> <td> Name </td><td> Description </td><td> Read Write </td><td>Use</td> </tr> <tr> <td>ext2</td><td> Basic Linux Filesystem</td><td>RW </td><td> Often used as a Root File System </td> </tr> <tr> <td>ext3</td><td> ext2 with journalling</td><td>RW</td><td> Used to provide a quick recovery after a shutdown </td> </tr> <tr> <td>romfs</td><td> rom based filesystem</td><td> Read only</td><td> often used for flash based systems </td> </tr> <tr> <td>cramfs</td><td> compresses rom based </td><td> Read Only</td><td> like romfs but file data is compressed</td> </tr> <tr> <td>tmpfs</td><td> ram based </td><td> RW </td><td> Fixed size volatile ram based file system</td> </tr> <tr> <td>ramfs</td><td> ram based </td><td> RW </td><td> Expanding , volatile ram based file system </td> </tr> <tr> <td>jffs2</td><td> flash based </td><td>RW </td><td> Flash Journalling File System </td> </tr></table><br /><p>This is a summary of filesystems often included in the kernel </p><table class="inline"> <tr> <td> Name </td><td> Description </td><td> Read Write </td><td>Use</td> </tr> <tr> <td>proc</td><td> Kernel Information System </td><td> RW </td><td> Used to access kernel data and structures </td> </tr> <tr> <td>sysfs</td><td> Kernel Object Information </td><td> RW </td><td> procfs replacement for 2.6 kernels </td> </tr></table><br /><p> Here are some more advanced file systems, some of these require patches in the kernel. Some of these are experimental and you may have to do a google search to find more information.</p><table class="inline"> <tr> <td> Name </td><td> Description </td><td> Read Write </td><td>Use</td> </tr> <tr> <td>overlayfs</td><td> Overlays a read only filesystem with non volatile storage </td><td> RW </td><td> live cds with persistent backing store </td> </tr> <tr> <td>debugfs</td><td> Exposes optional debug information</td><td>RW</td><td> Debugging Systems </td> </tr> <tr> <td>configfs</td><td>Exposes configuration information </td><td>RW</td><td> Configuring Systems </td> </tr> <tr> <td>squashfs</td><td>Cramfs alternative</td><td>Read Only</td><td> Embedded Systems </td> </tr> <tr> <td>yaffs</td><td>Jffs2 alternative </td><td> RW </td><td> Yet Another Flash File System </td> </tr> <tr> <td>cloopfs</td><td>compressed loop </td><td> Read Only</td><td> Knoppix style Live CD’s </td> </tr> <tr> <td>devfs</td><td> Device Driver Interface</td><td> RW </td><td> Exposes Device Drivers ( now deprecated ) </td> </tr></table><br /></div><!-- SECTION [1301-2997] --><h3><a name="the_superblock" id="the_superblock">The Superblock</a></h3><div class="level3"><p> This is not a football move but is the core of a file system.</p><p>The first 512 bytes of a device are normally used the determine the structure of the file system contained in that device. The kernel will read this initial data and try to determine the type of filesystem contained. If needed the kernel will try to load additional modules to allow it to understand and mount the file system.</p></div><!-- SECTION [2998-3416] --><h3><a name="creating_a_filesystem" id="creating_a_filesystem">Creating a Filesystem</a></h3><div class="level3"><p> Not a task for beginners but Linux has a fully working example file system in the kernel. If you look at the code for <strong>ramfs</strong> ( in <strong>linux/fs/ramfs/inode.c</strong> ) you will see an example File system generated by Linus.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -