Tux
Communication
Mailing lists
Documentation
User Manual
Target board info.
Target chip info.
Support
Linux support
Bugzilla
Downloads
STLinux
Updates
Search
Google


The web
stlinux.com
How To Guide
How to boot from ROM
File system background
ST Logo
Previous   Contents   Next


File system background

There are two principal components to a Linux file system.

  • The device driver for the physical hardware on which the file system resides. Devices which support file systems are a special type known as block devices, because they only need to support the reading and writing of data in blocks. Typically a block corresponds to one or more sectors of a magnetic disk.

  • The file system itself, which resides on the block device. This is responsible for presenting data to applications as logical files, mapping these files to the location of the data on the device, maintaining a directory of file names, keeping track of file permissions and modification times, and other maintenance functions.

Most file systems can be supported on any block device. Organizing the system in this way provides maximum flexibility to the system designer.

A number of steps must be taken to set up a device for the first time.

  • Some devices have to be formatted before they can be used. Sometimes this is described as a low level format, because it lays down the fundamental block structure on what was hitherto a blank medium. There is usually a device specific command to do this. For example, floppy disks are formatted in Linux using the command fdformat.

  • Some devices can be partitioned. This divides a large physical device into several smaller logical devices. This may be useful if a single device is to be used for several purposes. For example, different partitions can hold different file systems, possibly with different characteristics (such as read-only and read/write) or for different operating systems. The Linux command for partitioning a disk is fdisk.

  • The file system must be created. Normally this is done with the mkfs command, providing the appropriate arguments; for example mkfs -t ext2.

Once a file system has been created, it has to be mounted. This tells Linux which device the file system resides on, and where in the file hierarchy the new file system should appear. For example:

target# mount -t minix /dev/hda1 /home

This command tells the kernel that the disk /dev/hda1 holds a minix format file system, and the files are to appear in the /home directory.

There are exceptions to the rule that the file system and block device driver are separate. The file systems procfs and devfs present data to the user in the form of files (in /proc and /dev), however there is no data storage involved. The data returned to the user when listing a directory or reading a file is generated on the fly as required. Therefore when the mount command is issued for these file systems, the device field is ignored and can be any string. It is often worthwhile to pick a name which will be meaningful when the mount list command (mount with no arguments) is issued, for example:

mount -t procfs proc /proc

Another exception is JFFS2, which uses additional interfaces only provided by Flash device drivers in order to manage better file systems mounted on Flash devices.

Previous   Contents   Next
Valid HTML 4.01! Last updated: 2005/09/29 14:43:17
© Copyright STMicroelectronics Limited, 2005
Printer