\section{ext4 Features}
\begin{frame}
   {ext4 Filesystem Features}

   \begin{itemize}
      \item Backward compatible with \textbf{ext3} and
      \textbf{ext2} ancestors
      \item Uses \textbf{extents} instead of \textbf{block lists}
      \item Persistent pre-allocation
      \item Delayed allocation
      \item Increases the 32,000 subdirectory limit of earlier ancestors
      \item Journal checksum
      \item Fast filesystem checking
      \item Precise timestamps (nanoseconds)
   \end{itemize}

\end{frame}

\cprotect\note{

   \begin{info}[Extents]
      An extent is a group of contiguous blocks. The use of
      extents can improve large file performance and reduce
      fragmentation.
   \end{info}

   The \textbf{ext4} filesystem can support volumes up to
   1 EB and file sizes up to 16 TB.  \textbf{Extents}
   replace the older  block mapping mechanism.

   \textbf{ext4} is backwards compatible with \textbf{ext3} and
   \textbf{ext2}.  It can pre allocate disk space for a file.  The
   allocated space is usually guaranteed and contiguous.
   It also uses a performance technique called
   \textbf{allocate-on-flush} (delays block allocation until it
   writes data to disk).  \textbf{ext4} breaks the 32,000
   subdirectory limit of \textbf{ext3}.

   \textbf{ext4} uses checksums for the journal which
   improves reliability.  This can also safely avoid a
   disk I/O wait during journalling, which results in a
   slight performance boost.

   Another feature is the use of improved timestamps.
   \textbf{ext4} provides timestamps measured in
   nanoseconds.

}

\section{ext4 Layout and Superblock and Block Groups}
\begin{frame}
   {ext4  Superblock and Block Groups}

   \begin{itemize}
      \item
      \textbf{Superblock} at the beginning contains information
      about the entire filesystem
      \item It is followed by \textbf{Block Groups}
      composed of sets of contiguous blocks
      \begin{itemize}
         \item Include administrative information
         \item High redundancy of information
         in block groups
         \item Other blocks store file data
      \end{itemize}
      \item Block size is specified when filesystem is
      created
      \begin{itemize}
         \item May be 512, 1K, 2K, 4K, 8K etc. bytes, but
         not larger than a \textbf{page} of memory (4 KB
         on \textbf{x86}).
      \end{itemize}
   \end{itemize}

\end{frame}

\cprotect\note{

   An \textbf{ext4} filesystem is split into a set of
   block groups.  The block allocator tries to keep each
   file's blocks within the same block group to reduce
   seek times.  The default block size is 4 KB, which
   would create a block group of 128 MB.

   All fields in \textbf{ext4} are written to disk in
   \textbf{little-endian} order, except the journal.

   \begin{figure}[H]
      \includegraphics[scale=0.80]{IMAGES/ext2}
      \caption{ext[3,4] Filesystem Layout}
   \end{figure}

   The layout of a standard block group is simple.  For
   block group 0, the first 1024 bytes are unused (to
   allow for boot sectors, etc).  The superblock will
   start at the first block, except for block group 0.
   This is followed by the group descriptors and a number
   of \textbf{GDT} blocks.  These is followed by the data block
   bitmap, the inode bitmap, the inode table, and the
   data blocks.
}

\begin{frame}
   {Block Groups}

   \begin{itemize}
      \item
      Duplicate Superblocks and Group Descriptors help in
      filesystem recovery
   \end{itemize}

   \begin{figure}[H]
      \includegraphics[height=2.7in]{IMAGES/dumpe2fs}
      \caption{Block Groups}
   \end{figure}

\end{frame}

\cprotect\note{

   The first and second blocks are the same in every block
   group, and comprise the \textbf{Superblock} and the
   \textbf{Group Descriptors}.

   Under normal circumstances, only those in the first block
   group are used by the kernel; the duplicate copies are only
   referenced when the filesystem is being checked. If
   everything is OK, the kernel merely copies them over from
   the first block group.

   If there is a problem with the master copies, it goes to the
   next and so on until a healthy one is found and the
   filesystem structure is rebuilt. This redundancy makes it
   very difficult to thoroughly fry an ext2/3/4 filesystem, as
   long as the filesystem checks are run periodically.

   In the early incarnations of the ext filesystem family, each
   block group contained the group descriptors for every block
   group, as well as a copy of the superblock. As an
   optimization, however, today not all block groups have a
   copy of the superblock and group descriptors. To see what
   you have, you could examine it as in the accompanying
   screenshot, (putting in an appropriate device node) to see
   precise locations. This happens when the filesystem is
   created with the \verb?sparse_super? option, which is the
   default.


}

\begin{frame}
   {A Closer Look at the Superblock}

   \begin{itemize}
      \item The Superblock contains global information about
      the filesystem
      \begin{itemize}
         \item Mount count and maximum mount count
         \item Block size for this filesystem
         \item Blocks per group
         \item Free block count
         \item Free Inode count
         \item OS ID
      \end{itemize}
      \item The Superblock is redundantly stored in several
      block groups
   \end{itemize}

\end{frame}

\cprotect\note{

   Note that every time the disk is successfully mounted,
   mount count is incremented.  The filesystem is checked
   every maximum-mount-counts or every 180 days whichever
   comes first.

   Block size can be set through the \textbf{mkfs}
   command.

   The superblock for the filesystem is stored in block 0
   of the disk.  This superblock contains information
   about the filesystem itself.  }

\section{dumpe2fs}
\begin{frame}
   {Block and Inode Information for ext4: dumpe2fs}

   \begin{itemize}
      \item Block size used to set maximum number of:
      \begin{itemize}
         \item Blocks
         \item Inodes
         \item Superblocks
      \end{itemize}
      \item See \textbf{dumpe2fs} for filesystem info:
      \begin{itemize}
         \item Limits
         \item Capabilities and flags
         \item Other attributes
      \end{itemize}
   \end{itemize}

\end{frame}

\cprotect\note{

   You can use the \textbf{dumpe2fs} program to get
   information about a particular partition.
   \respfilevar{dumpe2fs.inc}{\tiny}
}

\section{tune2fs}
\begin{frame}
   {tune2fs: Change Filesystem Parameters}

   \textbf{tune2fs} can be used to change filesystem parameters.
   \begin{itemize}
      \item
      To change the maximum number of mounts between
      filesystem checks (\verb?max-mount-count?):
      \begin{cmd}
$ sudo tune2fs -c 25 /dev/sda1
      \end{cmd}
      \item
      To change the time interval between checks
      (\verb?interval-between-checks?):
      \begin{cmd}
$ sudo tune2fs -i 10 /dev/sda1
      \end{cmd}
      \item
      To list the contents of the superblock including the
      current values of parameters which can be changed:
      \begin{cmd}
$ sudo tune2fs -l /dev/sda1
      \end{cmd}
      basically shows the global information from \textbf{dumpe2fs}
   \end{itemize}

\end{frame}

\cprotect\note{

   \respfilevar{tune2fs.inc}{\tiny}
}


