ROOT FILE SYSTEM
Presented by
Bindu U
The root file system is the file system that is contained
on the same partition on which the root directory is
located, and it is the file system on which all the other
file systems are mounted as the system is booted up.
The root file system should generally be small,
because it contains critical files and infrequently
modified file system.
The exact contents of the root file system will vary
according to the computer.
Introduction
 It contains the files and directories critical for system
operation, including the device directory and
programs for booting the system.
The root file system also contains mount points
where file systems can be mounted to connect to the
root file system hierarchy.
Single user mode.
 Contents
/bin -> This directory contains binary executable files available
to all users.
Ex:-bash, busybox, cat, chmod, mount, cp, mv…
/sbin -> This directory contains tools needed for an
administrator, that an ordinary user can not use it. It will be in
root’s default path.
Ex:-ifconfig, route, rmmod, ip, mkfs, mke2fs…
/lib -> Contains architecture-independent libraries.
/boot -> This directory contains BOOT_LOADER and its
configuration file, directory GRUB or LILO.
/dev -> Contains device nodes for special files for local devices.
/etc -> This directory contains directories and files that are used
for system configuration.
/mnt -> It contains mount point for temporary mounts by the
system administrator.
/proc -> It presents information about processes and other
system information in a hierarchical file-like structure.
/home -> Serves as a mount point for a file system containing
user home directories.
/usr -> Contains files that do not change and can be shared by
machines such as executables and ASCII documentation.
/var -> This directory has a multiple purpose of which is the most
basic: -
 Storage of undelivered data from uncompleted process (printer ...)
[/var/spool/.....].
 Storage of unread or undelivered mail [/var/mail/.....].
 Web Contents of site [/var/www/.....].
 Records on the use of system resources (memory, disk drives, processor ...)
[/var/lock/.....].
 Temporary files that must be preserved during reboot [/var/tmp/.....].
FAT is a table that an operating system maintains on a hard disk
that provides a map of the clusters that a file has been stored
in.
The purpose of this table is to keep track of which areas of the
disk are available and which areas are in use.
There are three types of FAT
 FAT 12
 FAT 16
 FAT 32
FAT(FILE ALLOCATION TABLE)
The Boot Sector
The information about the file system, including cluster size,
sector size, etc. is located in the boot sector.
File Allocate Table
The FAT is a simple array of 12-bit, 16-bit or 32-bit data
elements(addressing the cluster).
Directories
 It contains the short name, file size, starting cluster, and
temporal information (time/date stamps).
Each directory entry points to a starting cluster and to a place
in the FAT where the cluster chain for the rest of the file is
located.
Clusters
The data area is divided into sector groups called clusters. All
the clusters in a single FAT volume have the same size.
Slack space
It refers to any unused space at the end of a cluster and cannot
be used by any other file or directory.
mkfs.vfat [ -a ] [ -A ] [ -b] [ -c ] [ -l ] [ -C ] [ -f ] [ -F ] [ -h ]
[ -i ] [ -I ] [ -m ] [ -n ] [ -r ] [ -R ] [ -s ] [ -S ] [ -v ]
Description:-
Options:-
 -a -> will align all the data structures to cluster size.
 -A -> turns off Atari format.
 -b -> Selects the location of the backup boot sector for FAT32.
 -c -> Check the device for bad blocks before creating the file
system.
Creating a FAT File System.
 -C -> used to create the new file system in a file instead of on a real
device.
 -f -> Specify the number of file allocation tables in the file system.
 -F -> Specifies the type of file allocation tables used (12, 16 or 32
bit).
 -h -> Select the number of hidden sectors in the volume.
 -i -> Sets the volume ID of the newly created file system.
 -I -> Specifies partition for fixed disk devices.
 -l -> Read the bad blocks list from filename.
 -m -> Sets the message the user receives on attempts to boot this
file system without having properly installed an operating system.
 -n -> Sets the volume name (label) of the file system.
 -r -> Select the number of entries available in the root directory.
 -R -> Select the number of reserved sectors.
 -s -> Specify the number of disk sectors per cluster.
 -S -> Specify the number of bytes per logical sector. Must be a
power of 2 and greater than or equal to 512.
 -v -> Verbose execution.
Example:-
1. sudo dd if=/dev/zero of=./mydisk bs=64M count=1
2. sudo mkfs.vfat -F 32 ./mydisk
3. sudo mkfs.vfat -F 32 -f 2 -S 512 -s 1 -R 32 ./mydisk
 It is the original file system introduced with the Linux operating
system.
 It uses virtual directories to handle physical devices, and storing data
in fixed-length blocks on the physical devices.
 The ext file-system uses a system called inodes to track information
about the files stored in the virtual directory.
 The extended part of the name comes from the additional data that it
tracks on each file, which consists of:
• The file name
• The file size
• The owner of the file
• The group the file belongs to
• Access permissions for the file
• Pointers to each disk block that contains data from the file
EXTENDED FILE SYSTEM 2/3/4
 Ext2
 Ext2 stands for second extended file system.
 This was developed to overcome the limitation of the original ext
file system.
 Ext2 does not have journaling feature.
 On flash drives, usb drives, ext2 is recommended, as it doesn’t
need to do the over head of journaling.
 Maximum individual file size can be from 16 GB to 2 TB
 Overall ext2 file system size can be from 2 TB to 32 TB
Ext3
 Ext3 stands for third extended file system.
 The main benefit of ext3 is that it allows journaling.
 Maximum individual file size can be from 16 GB to 2 TB
 Overall ext3 file system size can be from 2 TB to 32 TB
 There are three types of journaling available in ext3 file system.
 Journal / Data – Metadata and content are saved in the journal.
 Ordered – Only metadata is saved in the journal. Metadata
are journaled only after writing the content to disk. This is the default.
 Write back – Only metadata is saved in the journal. Metadata might
be journaled either before or after the content is written to the disk.
Ext4
 Ext4 stands for fourth extended file system.
 Maximum individual file size can be from 16 GB to 16 TB
 Overall maximum ext4 file system size is 1 EB (exabyte).
 Ext4 file system have option to Turn Off journaling feature.
 Other features like Sub Directory Scalability, Multiblock
Allocation, Delayed Allocation, etc.
 Creating Ext2 File System
# mke2fs /dev/device_name
 Creating Ext3 File System
# mke2fs –j /dev/device_name
OR
# mkfs.ext3 /dev/device_name
 Creating Ext4 File System
# mke2fs -t ext4 /dev/device_name
OR
# mkfs.ext4 /dev/device_name
Creating an Ext2, Ext3 and Ext4 File Systems
UBI stands for Unsorted Block Images.
A volume management system for raw flash devices
 Manage multiple logical volumes
 Spread the I/O load across whole flash chip
Vs. the Logical Volume Manager (LVM).
 LVM maps logical sectors to physical sectors,
 UBI maps logical erase blocks to physical erase blocks.
An UBI volume is a set of consecutive logical erase blocks (LEBs).
UBI FILE SYSTEM
UBI is aware of bad erase blocks and frees the upper layers
from any bad block handling.
20
PEB
LEB Volume A
UBI layer
1. Write data & failed
2. Recover the data to a good PEB
x 3. Retry write data
4. Remap LEB to new PEB
5. Mark this PEB bad
UBI/UBIFS stack
21
Six areas in UBIFS
 SB
 Super Block (SB) : static information
 MST
 Master Node (MST) : dynamic information
 LOG
 A part of UBIFS journal that the buds are.
 LPT (LEB properties tree)
 A wandering tree used to store LEB properties.
 ORPHAN
 Store the orphan inodes, which should be deleted at next reboot.
 MAIN
 the nodes that make up the file system data and the index.
UBIFS partition layout
SB MST LOG LPT ORPHAN MAIN
The purpose of the UBIFS journal
 To reduce the frequency of updates to the on-flash index
Journal
 All FS changes go to the journal
 Journal greatly increases FS write performance
 When mounting, journal is scanned and replayed
 Journal size is configurable and is stored in superblock
UBIFS’s Journal
A wandering tree used to store LEB properties.
LEB properties tree values
 Free space
 Dirty space
 Whether Erase block is an index erase block or not.
The LEB properties are essential
 To find space to add to the journal or the index.
 To find the dirtiest erase blocks to garbage collect.
LPT (LEB Properties Tree)
 Garbage Collector(GC) is responsible to turn dirty space to free
space
 One empty LEB is always reserved for GC
 GC procedure
1. Pick a victim LEB which has some dirty space.
2. Moves valid nodes from the victim LEB to the LEB reserved for GC.
3. If the victim LEB is erasable, erase the victim LEB.
4. pick new victim LEB, and moves the data to the reserved LEB
5. When the reserved LEB is full, pick another empty LEB, and continues
moving nodes from the victim LEB to the new reserved LEB
6. The process continues until a full empty LEB is produced.
Garbage collection
It is a single executable implementation of many standard
Linux® utilities.
It contains simple utilities such as cat and echo, as well as
larger more complex tools such as grep, find, mount etc.,
It has been written with size-optimization and limited
resources.
It is also extremely modular so we can easily include or
exclude commands (or features) at compile time.
Busy Box is a multi-call binary.
Busy Box
Invoking the Busy Box.
1. Invoke Busy Box by issuing a command as an argument
on the command line.
Ex:- /bin/busybox ls
will cause Busy Box to behave as 'ls'.
2. Invoke Busy Box using links to the Busy Box binary.
Ex:- ln -s /bin/busybox ls
./ls
will cause BusyBox to behave as 'ls‘.
Root file system

Root file system

  • 1.
  • 2.
    The root filesystem is the file system that is contained on the same partition on which the root directory is located, and it is the file system on which all the other file systems are mounted as the system is booted up. The root file system should generally be small, because it contains critical files and infrequently modified file system. The exact contents of the root file system will vary according to the computer. Introduction
  • 3.
     It containsthe files and directories critical for system operation, including the device directory and programs for booting the system. The root file system also contains mount points where file systems can be mounted to connect to the root file system hierarchy. Single user mode.  Contents
  • 5.
    /bin -> Thisdirectory contains binary executable files available to all users. Ex:-bash, busybox, cat, chmod, mount, cp, mv… /sbin -> This directory contains tools needed for an administrator, that an ordinary user can not use it. It will be in root’s default path. Ex:-ifconfig, route, rmmod, ip, mkfs, mke2fs… /lib -> Contains architecture-independent libraries. /boot -> This directory contains BOOT_LOADER and its configuration file, directory GRUB or LILO. /dev -> Contains device nodes for special files for local devices. /etc -> This directory contains directories and files that are used for system configuration. /mnt -> It contains mount point for temporary mounts by the system administrator.
  • 6.
    /proc -> Itpresents information about processes and other system information in a hierarchical file-like structure. /home -> Serves as a mount point for a file system containing user home directories. /usr -> Contains files that do not change and can be shared by machines such as executables and ASCII documentation. /var -> This directory has a multiple purpose of which is the most basic: -  Storage of undelivered data from uncompleted process (printer ...) [/var/spool/.....].  Storage of unread or undelivered mail [/var/mail/.....].  Web Contents of site [/var/www/.....].  Records on the use of system resources (memory, disk drives, processor ...) [/var/lock/.....].  Temporary files that must be preserved during reboot [/var/tmp/.....].
  • 7.
    FAT is atable that an operating system maintains on a hard disk that provides a map of the clusters that a file has been stored in. The purpose of this table is to keep track of which areas of the disk are available and which areas are in use. There are three types of FAT  FAT 12  FAT 16  FAT 32 FAT(FILE ALLOCATION TABLE)
  • 8.
    The Boot Sector Theinformation about the file system, including cluster size, sector size, etc. is located in the boot sector. File Allocate Table The FAT is a simple array of 12-bit, 16-bit or 32-bit data elements(addressing the cluster).
  • 9.
    Directories  It containsthe short name, file size, starting cluster, and temporal information (time/date stamps). Each directory entry points to a starting cluster and to a place in the FAT where the cluster chain for the rest of the file is located. Clusters The data area is divided into sector groups called clusters. All the clusters in a single FAT volume have the same size. Slack space It refers to any unused space at the end of a cluster and cannot be used by any other file or directory.
  • 10.
    mkfs.vfat [ -a] [ -A ] [ -b] [ -c ] [ -l ] [ -C ] [ -f ] [ -F ] [ -h ] [ -i ] [ -I ] [ -m ] [ -n ] [ -r ] [ -R ] [ -s ] [ -S ] [ -v ] Description:- Options:-  -a -> will align all the data structures to cluster size.  -A -> turns off Atari format.  -b -> Selects the location of the backup boot sector for FAT32.  -c -> Check the device for bad blocks before creating the file system. Creating a FAT File System.
  • 11.
     -C ->used to create the new file system in a file instead of on a real device.  -f -> Specify the number of file allocation tables in the file system.  -F -> Specifies the type of file allocation tables used (12, 16 or 32 bit).  -h -> Select the number of hidden sectors in the volume.  -i -> Sets the volume ID of the newly created file system.  -I -> Specifies partition for fixed disk devices.  -l -> Read the bad blocks list from filename.
  • 12.
     -m ->Sets the message the user receives on attempts to boot this file system without having properly installed an operating system.  -n -> Sets the volume name (label) of the file system.  -r -> Select the number of entries available in the root directory.  -R -> Select the number of reserved sectors.  -s -> Specify the number of disk sectors per cluster.  -S -> Specify the number of bytes per logical sector. Must be a power of 2 and greater than or equal to 512.  -v -> Verbose execution.
  • 13.
    Example:- 1. sudo ddif=/dev/zero of=./mydisk bs=64M count=1 2. sudo mkfs.vfat -F 32 ./mydisk 3. sudo mkfs.vfat -F 32 -f 2 -S 512 -s 1 -R 32 ./mydisk
  • 14.
     It isthe original file system introduced with the Linux operating system.  It uses virtual directories to handle physical devices, and storing data in fixed-length blocks on the physical devices.  The ext file-system uses a system called inodes to track information about the files stored in the virtual directory.  The extended part of the name comes from the additional data that it tracks on each file, which consists of: • The file name • The file size • The owner of the file • The group the file belongs to • Access permissions for the file • Pointers to each disk block that contains data from the file EXTENDED FILE SYSTEM 2/3/4
  • 15.
     Ext2  Ext2stands for second extended file system.  This was developed to overcome the limitation of the original ext file system.  Ext2 does not have journaling feature.  On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling.  Maximum individual file size can be from 16 GB to 2 TB  Overall ext2 file system size can be from 2 TB to 32 TB
  • 16.
    Ext3  Ext3 standsfor third extended file system.  The main benefit of ext3 is that it allows journaling.  Maximum individual file size can be from 16 GB to 2 TB  Overall ext3 file system size can be from 2 TB to 32 TB  There are three types of journaling available in ext3 file system.  Journal / Data – Metadata and content are saved in the journal.  Ordered – Only metadata is saved in the journal. Metadata are journaled only after writing the content to disk. This is the default.  Write back – Only metadata is saved in the journal. Metadata might be journaled either before or after the content is written to the disk.
  • 17.
    Ext4  Ext4 standsfor fourth extended file system.  Maximum individual file size can be from 16 GB to 16 TB  Overall maximum ext4 file system size is 1 EB (exabyte).  Ext4 file system have option to Turn Off journaling feature.  Other features like Sub Directory Scalability, Multiblock Allocation, Delayed Allocation, etc.
  • 18.
     Creating Ext2File System # mke2fs /dev/device_name  Creating Ext3 File System # mke2fs –j /dev/device_name OR # mkfs.ext3 /dev/device_name  Creating Ext4 File System # mke2fs -t ext4 /dev/device_name OR # mkfs.ext4 /dev/device_name Creating an Ext2, Ext3 and Ext4 File Systems
  • 19.
    UBI stands forUnsorted Block Images. A volume management system for raw flash devices  Manage multiple logical volumes  Spread the I/O load across whole flash chip Vs. the Logical Volume Manager (LVM).  LVM maps logical sectors to physical sectors,  UBI maps logical erase blocks to physical erase blocks. An UBI volume is a set of consecutive logical erase blocks (LEBs). UBI FILE SYSTEM
  • 20.
    UBI is awareof bad erase blocks and frees the upper layers from any bad block handling. 20 PEB LEB Volume A UBI layer 1. Write data & failed 2. Recover the data to a good PEB x 3. Retry write data 4. Remap LEB to new PEB 5. Mark this PEB bad
  • 21.
  • 22.
    Six areas inUBIFS  SB  Super Block (SB) : static information  MST  Master Node (MST) : dynamic information  LOG  A part of UBIFS journal that the buds are.  LPT (LEB properties tree)  A wandering tree used to store LEB properties.  ORPHAN  Store the orphan inodes, which should be deleted at next reboot.  MAIN  the nodes that make up the file system data and the index. UBIFS partition layout SB MST LOG LPT ORPHAN MAIN
  • 23.
    The purpose ofthe UBIFS journal  To reduce the frequency of updates to the on-flash index Journal  All FS changes go to the journal  Journal greatly increases FS write performance  When mounting, journal is scanned and replayed  Journal size is configurable and is stored in superblock UBIFS’s Journal
  • 24.
    A wandering treeused to store LEB properties. LEB properties tree values  Free space  Dirty space  Whether Erase block is an index erase block or not. The LEB properties are essential  To find space to add to the journal or the index.  To find the dirtiest erase blocks to garbage collect. LPT (LEB Properties Tree)
  • 25.
     Garbage Collector(GC)is responsible to turn dirty space to free space  One empty LEB is always reserved for GC  GC procedure 1. Pick a victim LEB which has some dirty space. 2. Moves valid nodes from the victim LEB to the LEB reserved for GC. 3. If the victim LEB is erasable, erase the victim LEB. 4. pick new victim LEB, and moves the data to the reserved LEB 5. When the reserved LEB is full, pick another empty LEB, and continues moving nodes from the victim LEB to the new reserved LEB 6. The process continues until a full empty LEB is produced. Garbage collection
  • 26.
    It is asingle executable implementation of many standard Linux® utilities. It contains simple utilities such as cat and echo, as well as larger more complex tools such as grep, find, mount etc., It has been written with size-optimization and limited resources. It is also extremely modular so we can easily include or exclude commands (or features) at compile time. Busy Box is a multi-call binary. Busy Box
  • 27.
    Invoking the BusyBox. 1. Invoke Busy Box by issuing a command as an argument on the command line. Ex:- /bin/busybox ls will cause Busy Box to behave as 'ls'. 2. Invoke Busy Box using links to the Busy Box binary. Ex:- ln -s /bin/busybox ls ./ls will cause BusyBox to behave as 'ls‘.

Editor's Notes

  • #7 /usr -> Standalone machines mount the root of a separate local file system over the /usr directory. Diskless machines and machines with limited disk resources mount a directory from a remote server over the /usr file system.