% on the following slides, include icon in the left sidebar
\def\lximg{/usr/share/lx/icons/fueller.png}

\input{configpres}

\title{Filesystems}
\maketitle

% stop displaying 'fueller.png' on the following slides
\def\lximg{none}

\subsection{Filesystems}
\subsubsection{Types}
\begin{frame}
\frametitle{Filesystem types}
\begin{itemize}
\item Filesystems for block devices
\item Filesystems for flash devices
\item Network filesystems (e.g. NFS)
\end{itemize}
\end{frame}

\subsubsection{For block devices}
\begin{frame}
\frametitle{Filesystems for block devices}
\begin{itemize}
\item EXT2
\item EXT3, EXT4
\item ReiserFS
\item XFS
\end{itemize}
Filesystem for ''flash based'' block devices:
\begin{itemize}
\item F2FS
\end{itemize}
\end{frame}

\subsubsection{For flash}
\begin{frame}
\frametitle{Flash filesystems}
\begin{itemize}
\item JFFS2
\item YAFFS2
\item LogFS
\item UbiFS
\end{itemize}
\end{frame}

\subsubsection{Journaling}
\begin{frame}
\frametitle{Journalling Filesystems}
\begin{alertblock}{What is a journalling filesystem?}
A ''Journalling Filesystem'' keeps track of all changes in a special memory area
(the journal). Based on the informations in the journal, files can be
reconstructed if a write access gets interrupted (for example by a system
crash or a power failure).
\end{alertblock}
\end{frame}

\subsubsection{Technical terms}
\begin{frame}
\frametitle{Technical terms}
\begin{itemize}
\item Block: Filesystems are usually organised in blocks. Small blocks won't
waste that much memory for small files; large blocks will increase the maximum
size of a filesystem
\item Inode: Stores information about regular files, directories, ...
\item Superblock: The superblock stores all information about the filesystem
\end{itemize}
\end{frame}

\subsubsection{EXT filesystems}
\begin{frame}
\frametitle{EXT2}
\begin{itemize}
\item \textbf{N}o journalling filesystem
\item A good choice for ''flash-based block devices'', like SD cards or USB
sticks (ext2 minimizes the number of writes), if you have heavy write access. F2FS
might be an alternative for flash devices
\item Supported block sizes: 1kb, 2kb, 4kb, 8kb
\item Max. filesystem size: 32TB (for 8kb blocks)
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{EXT3}
\begin{itemize}
\item \textbf{Journalling} filesystem
\item Three levels of journalling available: journal, ordered, writeback
\item Backward compatible with EXT2
\item Limited to 32.000 sub-directories
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{EXT4}
\begin{itemize}
\item \textbf{Journalling} filesystem
\item Backward compatible with EXT2 and EXT3
\item Faster filesystem checking
\item Filesystem size up 1 exabyte
\item Journal checksumming
\item \textbf{No longer} limited to 32.000 sub-directories
\end{itemize}
\end{frame}

\subsubsection{XFS}
\begin{frame}
\frametitle{XFS}
\begin{itemize}
\item \textbf{Journalling} filesystem
\item max. FILESIZE: 8 Exabyte !
\item Online defragmentation (using xfs\_fsr)
\item Online resizing (using xfs\_growfs)
\item Good choice for servers (e.g. file servers)
\end{itemize}
\end{frame}

\subsubsection{Flash filesystems}
\begin{frame}
\frametitle{F2FS}
\begin{itemize}
\item F lash F riendly F ilesystem
\item Available since Linux Kernel 3.8 (backports available back to 3.0)
\item Not a ''real'' flashfilesystem
\item For ''NAND flash based'' block devices, like SD, MMC, eMMC, ...
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{JFFS2}
\begin{itemize}
\item Flash filesystem
\item Used on top of MTD devices
\item All nodes must be scanned at mount time
\item Mount time and memory consumption linearly depend on the filesystem size
\item \textbf{No} powerfail safety
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{UbiFS}
\begin{itemize}
\item Flash filesystem
\item Used on top of UBI volumes
\item Fast mount time
\item Supports LZO and ZLIB compression
\item Powerfail safety !!!
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Recommendations}
\begin{itemize}
\item ''Flash-based block devices'': EXT2
\item Block devices: EXT3, EXT4
\item Block devices which are used in server machines (on which huge amounts
of data are stored): XFS
\item Flash devices: UbiFS
\end{itemize}
\end{frame}

\subsubsection{Creating and testing filesystems}

\begin{frame}[fragile]
\frametitle{Creating filesystems}
\begin{lstlisting}[keywordstyle=\ttfamily\footnotesize]
# EXT2 filesystem on a disk partition
mkfs.ext2 -b 2048 /dev/sdb2
# Checking an EXT2 filesystem
fsck.ext2 /dev/sdb2
# Mounting an EXT2 partition
mount -t ext2 /dev/sdb2 /mountpoint
# or just
mount /dev/sdb2 /mountpoint
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Creating filesystems}
\begin{lstlisting}[keywordstyle=\ttfamily\footnotesize]
# EXT2 filesystem in a file
$ dd if=/dev/zero of=ext2.img \
     bs=2048 count=1024
$ /sbin/mkfs.ext2 -b 2048 ext2.img 
myext2.img is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
256 inodes, 1024 blocks
51 blocks (4.98%) reserved for the super user
First data block=0
1 block group
16384 blocks per group, 16384 fragments per group
256 inodes per group
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Testing filesystems for block devices}
\begin{lstlisting}[keywordstyle=\ttfamily\footnotesize]
# 1) Mounting a filesystem which is located in a file
mount -o loop ext2.img /mountpoint
# 2) Mounting a specific partition of a complete disk image
$ fdisk -lu bla.img 
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
[...]
  Device Boot      Start         End      Blocks   Id  System
bla.img1              63       64259       32098+  83  Linux
# Now multiply the start offset (63) with
# the sector size (512) = 32256
$ mount -o offset=32256 /mountpoint
\end{lstlisting}
\end{frame}

\begin{frame}
\frametitle{Testing flash filesystems}
\begin{itemize}
\item You can emulate flash devices on your host system, if you want to test
your flash filesystem
\item \textbf{mtdram} can emulate NOR devices
\item \textbf{nandsim} can emulate NAND devices
\item This will be covered in a different chapter
\end{itemize}
\end{frame}

\subsubsection{sources}
\begin{frame}
\begin{thebibliography}{1}
\bibitem{ext2} http://en.wikipedia.org/wiki/Ext2
\bibitem{ext3} http://en.wikipedia.org/wiki/Ext3
\bibitem{ext4} http://en.wikipedia.org/wiki/Ext4
\bibitem{xfs} http://en.wikipedia.org/wiki/XFS
\bibitem{UBIFS} http://en.wikipedia.org/wiki/UBIFS
\end{thebibliography} 
\end{frame}

\input{tailpres}
