mke2fs to format a file rather than a hard drive partition (block device) for which it was intended. As such, mke2fs detected that fact and asked us to confirm the operation. After confirming, mke2fs proceeded to write an ext2 superblock and file system data structures into the file. We then can mount this file like any block device, using the Linux loopback device:
# mount -o loop ./my-new-fs-image /mnt/flash
This command mounts the file my-new-fs-image as a file system on the mount point named /mnt/flash. The mount point name is not important; you can mount it wherever you want, as long as the mount point exists. Use mkdir to create your mount point.
After the newly created image file is mounted as a file system, we are free to make changes to it. We can add and delete directories, make device nodes, and so on. We can use tar to copy files into or out of it. When the changes are complete, they are saved in the file, assuming that you didn't exceed the size of the device. Remember, using this method, the size is fixed at creation time and cannot be changed.
9.11. Chapter Summary
• Partitions are the logical division of a physical device. Numerous partition types are supported under Linux.
• A file system is mounted on a mount point in Linux. The root file system is mounted at the root of the file system hierarchy and referred to as / .
• The popular ext2 file system is mature and fast, and is often found on embedded and other Linux systems such as Red Hat and the Fedora Core series.
• The ext3 file system adds journaling on top of the ext2 file system, for better data integrity and system reliability.
• ReiserFS is another popular and high-performance journaling file system found on many embedded and other Linux systems.
• JFFS2 is a journaling file system optimized for use with Flash memory. It contains Flash-friendly features such as wear leveling for longer Flash memory lifetime.
• cramfs is a read-only file system perfect for small-system boot ROMs and other read-only programs and data.
• NFS is one of the most powerful development tools for the embedded developer. It can bring the power of a workstation to your target device. Learn how to use NFS as your embedded target's root file system. The convenience and time savings will be worth the effort.
• Many pseudo file systems are available on Linux. A few of the more important ones are presented here, including the proc file system and sysfs.
• The RAM-based tmpfs file system has many uses for embedded systems. Its most significant improvement over traditional ramdisks is the capability to resize itself dynamically to meet operational requirements.
9.11.1. Suggestions for Additional Reading
'Design and Implementation of the Second Extended Filesystem'
Remy Card, Theodore Ts'o, and Stephen Tweedie
First published in the
Available on http://e2fsprogs.sourceforge.net/ext2intro.html
'A Non-Technical Look Inside the EXT2 File System'
Randy Appleton
www.linuxgazette.com/issue21/ext2.html
Whitepaper:
Michael K. Johnson
www.redhat.com/support/wpapers/redhat/ext3/
ReiserFS Home Page
www.namesys.com/
'JFFS: The Journaling Flash File System'
David Woodhouse
http://sources.redhat.com/jffs2/jffs2.pdf
README file from cramfs project
Unsigned (assumed to be the project author)
http://sourceforge.net/projects/cramfs/
NFS home page
http://nfs.sourceforge.net
The /proc file system documentation
www.tldp.org/LDP/lkmpg/2.6/html/c712.htm
A technical whitepaper
Dominic Kay
www.sun.com/software/whitepapers/solaris10/fs_performance.pdf
Chapter 10. MTD Subsystem
The Memory Technology Devices (MTD) subsystem grew out of the need to support a wide variety of memory-like devices such as Flash memory chips. Many different types of Flash chips are available, along with numerous methods to program them, partly because of the many specialized and high-performance modes that are supported. The MTD layer architecture enables the separation of the low-level device complexities from the higher-layer data organization and storage formats that use memory devices.
In this chapter, we introduce the MTD subsystem and provide some simple examples of its use. First we look at what is required of the kernel to support MTD services. We introduce some simple operations on a development workstation with MTD enabled, as a means to understand the basics of this subsystem. In this