SlideShare a Scribd company logo
Linux For Embedded Systems
ForArabs
Ahmed ElArabawy
Course 102:
UnderstandingLinux
Lecture 27:
FileSystems in Linux (Part 2)
User Application
C Library
System Call API
VFSInodes
Dentry
Cache
ext2 JFFS2 FAT NTFS
Buffer Cache
Device Driver Device Driver
User
Kernel
HW
The Big Picture
• User applications access files using a standard API
• This does not change no matter what storage media, partition, or
used file system type
• The used API results in a system call towards the kernel (generated
by the C-Library)
• The system call is received by the VFS (Virtual File System)
subsystem of the Linux Kernel
• This subsystem provides a unified access to the file via the concepts
of nodes and dentries (A previous lecture covered VFS in details)
• VFS then communicate with the used FileSystem that contain this
file
• The filesystem in turn Communicate with the device driver for the
storage media using the block abstraction
• The device driver is responsible for interfacing with the storage
hardware device
Popular FileSystem Types
Linux Extended FileSystems
ext2
• The ext2 used to be the most popular filesystem for Linux
distributions running on a hard disk
• It uses block sizes of 1024, 2048, or 4096 Bytes
• Large values waste disk space if we have a lot of small files
• Small values increase overhead for metadata to point to the different
blocks in the case of large files
• A problem with the ext2 was the risk of filesystem corruption due to
unexpected reboots or power failures
• A planned reboot will unmount all filesystems before the system is
shutdown
• This guarantees that the shutdown does not happen in the middle of
a write operation
• However, in case of a sudden power failure or a system crash, the
filesystem will not be unmounted, and we may run into a corruption
of the data in the fileSystem (some of the data is written without
updating the filesystem metadata)
• The solution for this problem is “Journaling”
Journaling
• The filesystem that support journaling will have a special file
“The Journal File”
• Every time there is a modification to the filesystem (a write
operation), this change is tracked first in the journal file then
committed to the actual file in the filesystem
• This way, we will have a journaling points that we can revert to
in case of a corruption (mismatch between filesystem
contents and its meta-data)
• Upon a boot after a sudden shutdown/reboot, the journal file
is tracked, and compared to the contents of the filesystem
• Changes in the journal may be applied or removed to maintain
data consistency
• Most newer filesystems support Journaling to maintain the
filesystem contents data integrity
Linux Extended FileSystems
ext3
• The ext3 filesystem is an extension to the ext2 filesystem to
support Journalling
• It is both forward and backword compatible with ext2 (we can
convert ext2 filesystem to ext3 and vice versa)
• In ext2 when the system shuts down abruptly, the next boot
takes long time, because a consistency check is run on the
filesystem
• In ext3, no consistency check is needed, the journaling file is
checked to verify changes, which is a much faster process
Linux Extended FileSystems
ext4
• The ext4 filesystem is an extension to the ext3 filesystem
• Currently, it is the default filesystem for Linux
• It also supports journaling
• It removes some of the limitations of ext3,
• The ext4 filesystem can support filesystem size of more than the
16 terabyte which is the limit for ext3
• The ext4 filesystem can support file sizes of up to 1 Terabyte
SecondGenerationJournaling FileSystem
JFFS2 FileSystems
• The jffs2 filesystem is used with flash memory storage devices
• Use of flash memory storage is very common in embedded systems
• Flash memory has the following features:
• Multiple files per Block:
• The block size is large (tens to hundreds of kilobytes). A typical value is 128KB
• This means, we need to be able to store multiple files in the same block
• Accordingly, one block on the flash may contain several small files
• Slow wrtie operations
• Writing a value to an empty place in the flash is performed one byte (or word) at a time
(as normal devices)
• However, you can not erase (or modify) a single byte (word)
• Erasing requires the whole block to be erased
• This means, if we need to modify a small file, this will require the whole block to be
erased, then the block (or another empty one) will be re-written
• This makes write operations in the flash much slower than other devices
• This results in a higher chance of corruption due to power failures during a write
operation
• Flash Lifetime
• Another limitation, flash memory has limited lifetime (specified in number of write
operations)
• Flash memory life time is measured by the number of write operations
• We need to even out the write operations to avoid damaging parts of the flash too early
SecondGenerationJournaling FileSystem
JFFS2 FileSystems
• The jffs2 filesystem handles the flash as follows,
• Due to the slow write operation, journaling becomes very
essential, and hence journaling is supported in JFFS2
• It makes sure that blocks are used evenly to distribute the write
operations on the flash. This is called Wear Leveling
• Special care is needed with the use of tools that keep updating
files such as logging tools (ex. syslogd, and klogd)
• If we have other forms of storage, it would be better to direct the
output away from the flash memory
• Use of caching may be useful to reduce the number of
modifications
• This affects both system performance and flash life-time
Cram FileSystem
cramfs
• This filesystem objective is to compress a filesystem into a
small ROM
• It is a read-only filesystem
• It supports compression of the data in the filesystem
• Useful for small embedded systems to store read only data in
a small ROM or flash
• Ideal for boot ROMs
Memory Hosted FileSystems
ramfs
• A filesystem that lives in the system memory (RAM)
• This provides high access speed, but it is volatile (erased at
reboot time or at shutdown)
• It is different from RamDisks that it can grow and shrink based
on the need
Memory Hosted FileSystems
tmpfs
• Like ramfs, everything is stored in system volatile memory
(RAM)
• Accordingly, contents of this filesystem are lost on power
failure or reboot
• Different from the ramfs in that it can not grow dynamically
• It can also use the swap while the ramfs can not
• Normally mount to /tmp
Network File System
Network FileSystem
NFS
• This filesystem will exist on a remote machine and will be
accessed through the network
• Useful for sharing folders in the network
• A central NFS server will contain the filesystem data
• All machines that need to have access to the data will need to
contain a NFS Client
• Machines with NFS Clients will need to mount the NFS filesystem
(Map to the network drive)
NFS in Embedded Systems
• Another very useful application for NFS is development of Embedded
Systems
• Embedded target flash memory size may not be able to hold all the tools and
utilities used during development
• Hence, all the tools and utilities can be located on a remote machine (NFS
Server) and the target would mount an NFS filesystem to have access to it
• Also, during development, we don’t need to upload the image of the binary
everytime we make a new build, instead, we keep the binary on the
development host machine
• The target can even have its root file system mounted as NFS, so the target
will only carry the bootloader and kernel. All the rest will be on the remote
machine (development host)
Virtual FileSystems
procfs & sysfs
• Those filesystems are not stored in any storage device, but
they are managed by the kernel
• Reading from a file in this filesystem results in a query to the
kernel
• Writing to a file results in sending some info to the kernel
• Those filesystems will be studied in detail in separate lectures
LINUX COMMANDS
Show FileSystem Disk Space Usage
(df Comand)
$ df
Show FileSystem Disk Space Usage
(df Comand)
$ df -i (Show FileSystem inode Usage)
Show Process Disk Usage
(du Command)
$ du <device>
• This command shows the disk usage per process for the disk
specified by the device filename
$ du /dev/sda1
http://Linux4EmbeddedSystems.com

More Related Content

What's hot (20)

PDF
Course 102: Lecture 7: Simple Utilities
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 25: Devices and Device Drivers
Ahmed El-Arabawy
 
ODP
Linux commands
Balakumaran Arunachalam
 
PPTX
Know the UNIX Commands
Brahma Killampalli
 
PPT
Shell Scripting
Gaurav Shinde
 
PDF
Course 102: Lecture 4: Using Wild Cards
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 6: Seeking Help
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 8: Composite Commands
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 10: Learning About the Shell
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
PPTX
System call
DarakhshanNayyab
 
PDF
Course 102: Lecture 17: Process Monitoring
Ahmed El-Arabawy
 
PDF
An Introduction To Linux
Ishan A B Ambanwela
 
PPT
Linux basic commands
MohanKumar Palanichamy
 
PDF
Linux dma engine
pradeep_tewani
 
PPTX
Lec 01_Linux System Administration (1).pptx
ShabanaShafi3
 
PDF
Shell scripting
Manav Prasad
 
PDF
Course 102: Lecture 20: Networking In Linux (Basic Concepts)
Ahmed El-Arabawy
 
PPT
Part 1 - PROCESS CONCEPTS
priyasoundar
 
PPT
Processes Control Block (Operating System)
Imdad Ullah
 
Course 102: Lecture 7: Simple Utilities
Ahmed El-Arabawy
 
Course 102: Lecture 25: Devices and Device Drivers
Ahmed El-Arabawy
 
Linux commands
Balakumaran Arunachalam
 
Know the UNIX Commands
Brahma Killampalli
 
Shell Scripting
Gaurav Shinde
 
Course 102: Lecture 4: Using Wild Cards
Ahmed El-Arabawy
 
Course 102: Lecture 6: Seeking Help
Ahmed El-Arabawy
 
Course 102: Lecture 8: Composite Commands
Ahmed El-Arabawy
 
Course 102: Lecture 10: Learning About the Shell
Ahmed El-Arabawy
 
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
System call
DarakhshanNayyab
 
Course 102: Lecture 17: Process Monitoring
Ahmed El-Arabawy
 
An Introduction To Linux
Ishan A B Ambanwela
 
Linux basic commands
MohanKumar Palanichamy
 
Linux dma engine
pradeep_tewani
 
Lec 01_Linux System Administration (1).pptx
ShabanaShafi3
 
Shell scripting
Manav Prasad
 
Course 102: Lecture 20: Networking In Linux (Basic Concepts)
Ahmed El-Arabawy
 
Part 1 - PROCESS CONCEPTS
priyasoundar
 
Processes Control Block (Operating System)
Imdad Ullah
 

Viewers also liked (18)

PDF
Course 102: Lecture 14: Users and Permissions
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 1: Course Overview
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 2: Introduction to Embedded Systems
Ahmed El-Arabawy
 
PPTX
Files and directories in Linux 6
Meenakshi Paul
 
PDF
Course 102: Lecture 22: Package Management
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 8: Lab 1: Building a Raspberry Pi Based WiFi AP
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 4: Selecting the Proper RTOS
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry Pi
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 1: Course Overview
Ahmed El-Arabawy
 
PDF
Embedded Systems: Lecture 7: Unwrapping the Raspberry Pi
Ahmed El-Arabawy
 
PDF
C 102 lec_29_what_s_next
Ahmed El-Arabawy
 
PPTX
임베디드
래선 김
 
PDF
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 11: Environment Variables
Ahmed El-Arabawy
 
PDF
File systems for Embedded Linux
Emertxe Information Technologies Pvt Ltd
 
Course 102: Lecture 14: Users and Permissions
Ahmed El-Arabawy
 
Course 102: Lecture 1: Course Overview
Ahmed El-Arabawy
 
Embedded Systems: Lecture 2: Introduction to Embedded Systems
Ahmed El-Arabawy
 
Files and directories in Linux 6
Meenakshi Paul
 
Course 102: Lecture 22: Package Management
Ahmed El-Arabawy
 
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Ahmed El-Arabawy
 
Embedded Systems: Lecture 8: Lab 1: Building a Raspberry Pi Based WiFi AP
Ahmed El-Arabawy
 
Embedded Systems: Lecture 4: Selecting the Proper RTOS
Ahmed El-Arabawy
 
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Ahmed El-Arabawy
 
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry Pi
Ahmed El-Arabawy
 
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Ahmed El-Arabawy
 
Embedded Systems: Lecture 1: Course Overview
Ahmed El-Arabawy
 
Embedded Systems: Lecture 7: Unwrapping the Raspberry Pi
Ahmed El-Arabawy
 
C 102 lec_29_what_s_next
Ahmed El-Arabawy
 
임베디드
래선 김
 
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Ahmed El-Arabawy
 
Course 102: Lecture 11: Environment Variables
Ahmed El-Arabawy
 
File systems for Embedded Linux
Emertxe Information Technologies Pvt Ltd
 
Ad

Similar to Course 102: Lecture 27: FileSystems in Linux (Part 2) (20)

PPTX
UNIT 4-UNDERSTANDING VIRTUAL MEMORY.pptx
LeahRachael
 
PPTX
EMBEDDED KERNEL and its COMPONENTS.pptx
DrMLordwinVelTechChe
 
PPTX
11 linux filesystem copy
Shay Cohen
 
PPTX
File system and Deadlocks
Rohit Jain
 
PDF
Poking The Filesystem For Fun And Profit
ssusera432ea1
 
PPTX
Ext filesystem4
Neha Kulkarni
 
PPTX
Advanced Storage Area Network
Soumee Maschatak
 
PDF
Do journaling filesystems guarantee against corruption after a power failure (1)
Rudhramoorthi Andiappan
 
PPT
XFS.ppt
DmitryIg
 
PDF
12-introductiontolinuxos-190907073928
SahilNegi60
 
PPTX
12 introduction to Linux OS
Hameda Hurmat
 
PPTX
Operating system and installation
IshworKhatiwada
 
PPTX
UNIT III.pptx
YogapriyaJ1
 
PPTX
Disk and File System Management in Linux
Henry Osborne
 
PPTX
Hadoop Distributed File System
Milad Sobhkhiz
 
PPTX
Windows file system
sumitjain2013
 
PPTX
Operating system
Shivneep kaur
 
PPTX
Operating systems (For CBSE School Students)
Gaurav Aggarwal
 
UNIT 4-UNDERSTANDING VIRTUAL MEMORY.pptx
LeahRachael
 
EMBEDDED KERNEL and its COMPONENTS.pptx
DrMLordwinVelTechChe
 
11 linux filesystem copy
Shay Cohen
 
File system and Deadlocks
Rohit Jain
 
Poking The Filesystem For Fun And Profit
ssusera432ea1
 
Ext filesystem4
Neha Kulkarni
 
Advanced Storage Area Network
Soumee Maschatak
 
Do journaling filesystems guarantee against corruption after a power failure (1)
Rudhramoorthi Andiappan
 
XFS.ppt
DmitryIg
 
12-introductiontolinuxos-190907073928
SahilNegi60
 
12 introduction to Linux OS
Hameda Hurmat
 
Operating system and installation
IshworKhatiwada
 
UNIT III.pptx
YogapriyaJ1
 
Disk and File System Management in Linux
Henry Osborne
 
Hadoop Distributed File System
Milad Sobhkhiz
 
Windows file system
sumitjain2013
 
Operating system
Shivneep kaur
 
Operating systems (For CBSE School Students)
Gaurav Aggarwal
 
Ad

More from Ahmed El-Arabawy (8)

PDF
Course 102: Lecture 24: Archiving and Compression of Files
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 12: Basic Text Handling
Ahmed El-Arabawy
 
PDF
Course 102: Lecture 2: Unwrapping Linux
Ahmed El-Arabawy
 
PDF
Course 101: Lecture 6: Installing Ubuntu
Ahmed El-Arabawy
 
PDF
Course 101: Lecture 5: Linux & GNU
Ahmed El-Arabawy
 
PDF
Course 101: Lecture 4: A Tour in RTOS Land
Ahmed El-Arabawy
 
PDF
Course 101: Lecture 2: Introduction to Operating Systems
Ahmed El-Arabawy
 
PDF
Course 101: Lecture 1: Introduction to Embedded Systems
Ahmed El-Arabawy
 
Course 102: Lecture 24: Archiving and Compression of Files
Ahmed El-Arabawy
 
Course 102: Lecture 12: Basic Text Handling
Ahmed El-Arabawy
 
Course 102: Lecture 2: Unwrapping Linux
Ahmed El-Arabawy
 
Course 101: Lecture 6: Installing Ubuntu
Ahmed El-Arabawy
 
Course 101: Lecture 5: Linux & GNU
Ahmed El-Arabawy
 
Course 101: Lecture 4: A Tour in RTOS Land
Ahmed El-Arabawy
 
Course 101: Lecture 2: Introduction to Operating Systems
Ahmed El-Arabawy
 
Course 101: Lecture 1: Introduction to Embedded Systems
Ahmed El-Arabawy
 

Recently uploaded (20)

PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Complete Network Protection with Real-Time Security
L4RGINDIA
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Complete Network Protection with Real-Time Security
L4RGINDIA
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 

Course 102: Lecture 27: FileSystems in Linux (Part 2)

  • 1. Linux For Embedded Systems ForArabs Ahmed ElArabawy Course 102: UnderstandingLinux
  • 2. Lecture 27: FileSystems in Linux (Part 2)
  • 3. User Application C Library System Call API VFSInodes Dentry Cache ext2 JFFS2 FAT NTFS Buffer Cache Device Driver Device Driver User Kernel HW
  • 4. The Big Picture • User applications access files using a standard API • This does not change no matter what storage media, partition, or used file system type • The used API results in a system call towards the kernel (generated by the C-Library) • The system call is received by the VFS (Virtual File System) subsystem of the Linux Kernel • This subsystem provides a unified access to the file via the concepts of nodes and dentries (A previous lecture covered VFS in details) • VFS then communicate with the used FileSystem that contain this file • The filesystem in turn Communicate with the device driver for the storage media using the block abstraction • The device driver is responsible for interfacing with the storage hardware device
  • 6. Linux Extended FileSystems ext2 • The ext2 used to be the most popular filesystem for Linux distributions running on a hard disk • It uses block sizes of 1024, 2048, or 4096 Bytes • Large values waste disk space if we have a lot of small files • Small values increase overhead for metadata to point to the different blocks in the case of large files • A problem with the ext2 was the risk of filesystem corruption due to unexpected reboots or power failures • A planned reboot will unmount all filesystems before the system is shutdown • This guarantees that the shutdown does not happen in the middle of a write operation • However, in case of a sudden power failure or a system crash, the filesystem will not be unmounted, and we may run into a corruption of the data in the fileSystem (some of the data is written without updating the filesystem metadata) • The solution for this problem is “Journaling”
  • 7. Journaling • The filesystem that support journaling will have a special file “The Journal File” • Every time there is a modification to the filesystem (a write operation), this change is tracked first in the journal file then committed to the actual file in the filesystem • This way, we will have a journaling points that we can revert to in case of a corruption (mismatch between filesystem contents and its meta-data) • Upon a boot after a sudden shutdown/reboot, the journal file is tracked, and compared to the contents of the filesystem • Changes in the journal may be applied or removed to maintain data consistency • Most newer filesystems support Journaling to maintain the filesystem contents data integrity
  • 8. Linux Extended FileSystems ext3 • The ext3 filesystem is an extension to the ext2 filesystem to support Journalling • It is both forward and backword compatible with ext2 (we can convert ext2 filesystem to ext3 and vice versa) • In ext2 when the system shuts down abruptly, the next boot takes long time, because a consistency check is run on the filesystem • In ext3, no consistency check is needed, the journaling file is checked to verify changes, which is a much faster process
  • 9. Linux Extended FileSystems ext4 • The ext4 filesystem is an extension to the ext3 filesystem • Currently, it is the default filesystem for Linux • It also supports journaling • It removes some of the limitations of ext3, • The ext4 filesystem can support filesystem size of more than the 16 terabyte which is the limit for ext3 • The ext4 filesystem can support file sizes of up to 1 Terabyte
  • 10. SecondGenerationJournaling FileSystem JFFS2 FileSystems • The jffs2 filesystem is used with flash memory storage devices • Use of flash memory storage is very common in embedded systems • Flash memory has the following features: • Multiple files per Block: • The block size is large (tens to hundreds of kilobytes). A typical value is 128KB • This means, we need to be able to store multiple files in the same block • Accordingly, one block on the flash may contain several small files • Slow wrtie operations • Writing a value to an empty place in the flash is performed one byte (or word) at a time (as normal devices) • However, you can not erase (or modify) a single byte (word) • Erasing requires the whole block to be erased • This means, if we need to modify a small file, this will require the whole block to be erased, then the block (or another empty one) will be re-written • This makes write operations in the flash much slower than other devices • This results in a higher chance of corruption due to power failures during a write operation • Flash Lifetime • Another limitation, flash memory has limited lifetime (specified in number of write operations) • Flash memory life time is measured by the number of write operations • We need to even out the write operations to avoid damaging parts of the flash too early
  • 11. SecondGenerationJournaling FileSystem JFFS2 FileSystems • The jffs2 filesystem handles the flash as follows, • Due to the slow write operation, journaling becomes very essential, and hence journaling is supported in JFFS2 • It makes sure that blocks are used evenly to distribute the write operations on the flash. This is called Wear Leveling • Special care is needed with the use of tools that keep updating files such as logging tools (ex. syslogd, and klogd) • If we have other forms of storage, it would be better to direct the output away from the flash memory • Use of caching may be useful to reduce the number of modifications • This affects both system performance and flash life-time
  • 12. Cram FileSystem cramfs • This filesystem objective is to compress a filesystem into a small ROM • It is a read-only filesystem • It supports compression of the data in the filesystem • Useful for small embedded systems to store read only data in a small ROM or flash • Ideal for boot ROMs
  • 13. Memory Hosted FileSystems ramfs • A filesystem that lives in the system memory (RAM) • This provides high access speed, but it is volatile (erased at reboot time or at shutdown) • It is different from RamDisks that it can grow and shrink based on the need
  • 14. Memory Hosted FileSystems tmpfs • Like ramfs, everything is stored in system volatile memory (RAM) • Accordingly, contents of this filesystem are lost on power failure or reboot • Different from the ramfs in that it can not grow dynamically • It can also use the swap while the ramfs can not • Normally mount to /tmp
  • 16. Network FileSystem NFS • This filesystem will exist on a remote machine and will be accessed through the network • Useful for sharing folders in the network • A central NFS server will contain the filesystem data • All machines that need to have access to the data will need to contain a NFS Client • Machines with NFS Clients will need to mount the NFS filesystem (Map to the network drive)
  • 17. NFS in Embedded Systems • Another very useful application for NFS is development of Embedded Systems • Embedded target flash memory size may not be able to hold all the tools and utilities used during development • Hence, all the tools and utilities can be located on a remote machine (NFS Server) and the target would mount an NFS filesystem to have access to it • Also, during development, we don’t need to upload the image of the binary everytime we make a new build, instead, we keep the binary on the development host machine • The target can even have its root file system mounted as NFS, so the target will only carry the bootloader and kernel. All the rest will be on the remote machine (development host)
  • 18. Virtual FileSystems procfs & sysfs • Those filesystems are not stored in any storage device, but they are managed by the kernel • Reading from a file in this filesystem results in a query to the kernel • Writing to a file results in sending some info to the kernel • Those filesystems will be studied in detail in separate lectures
  • 20. Show FileSystem Disk Space Usage (df Comand) $ df
  • 21. Show FileSystem Disk Space Usage (df Comand) $ df -i (Show FileSystem inode Usage)
  • 22. Show Process Disk Usage (du Command) $ du <device> • This command shows the disk usage per process for the disk specified by the device filename $ du /dev/sda1