File Systems2023Part2
File Systems2023Part2
• PART 1:
• Secondary storage devices
• Types of storage devices
• Disk structure
• Disk formatting
• Files
• File systems
• Definition of “file system”
• Address mapping
• Strategies for allocating disk space to files
• PART 2:
• Windows file systems
• FAT 12,16, 32
• NTFS
• Linux file systems
• Linux file structure on disk
• ext2
• Mounting a file system in Linux and Windows
• The boot sequence
• Directory structure
• Different Windows file systems
• FAT 12
• FAT 16, 32
• The NTFS file system
• The Master File Table (MFT)
• MTS entries
• Structure of MFT
• NTFS file storage allocation
Structure of directory entries for MS-DOS
• Directory entries are 32 bytes long
• A directory entry has the format below:
• Attributes: a collection of bit flags:
• read only,
• hidden,
• system file,
• root directory,
• sub-directory,
• file has been archived,
• last 2 unused
File Allocation Table (FAT)
• FAT is a linked list allocation of blocks to files using tables
• FAT, developed in 1977 for use on floppy disks, MS-DOS,
later adapted for use on hard drives and other devices, as
well as for the first Windows versions
• The increase in disk drives capacity required three major
variants: FAT12, FAT16, FAT32
• FAT was replaced with NTFS as the default file system on
Windows operating systems starting with Windows XP
(2001)
• Nevertheless, FAT continues to be used on flash
memory and other solid-state memory cards (including
USB drives), as well as digital cameras, etc.
File Allocation Table (FAT)
• The entries size is1024 bytes. The first 42 bytes store the header. The other 982 bytes do not have a
fixed structure, and are used to keep attributes.
• The other 982 bytes consist of a sequence of (attribute header, value) pairs.
• Each attribute begins with a header telling which attribute this is and
how long the value is.
• If the attribute value is short enough to fit in the MFT entry, it is placed
there.
• If it is too long, it is placed elsewhere on the disk and a pointer to it is
placed in the MFT entry
Structure of master file entries
• i-node:
• Each i-node is the internal
representation of a file, i.e. the mapping
of the file to disk blocks
• It also contains the attributes of the file:
owner, permissions, date of creation, etc
• The i-node list is a pre-determined
sequence of i-nodes available to a
“block group” in the file system
Boot Block Super Block i-node List Data Blocks
General view of Linux: Data blocks
• Boot Block
• Super Block
• Inode List
• Data Block
• Data Blocks:
• Storage available to a file system
• An allocated data block can belong to one
and only one file in the file system
Data blocks
100
Directory
Linux file systems ext3 and ext4
• In ext2 writes are delayed, and changes may not be committed to
disk for up to 30 sec, which is a very long time interval
• Like Windows NTFS, ext3 and ext4 are “journaling file systems”
• The basic idea behind a journaling file system is to maintain a
journal, which describes all file-system operations in sequential
order.
• By sequentially writing out changes to the file-system data, the
operations do not suffer from the overheads of disk-head movement
during random disk accesses.
• Eventually, the changes will be written out, committed, to the
appropriate disk location, and the corresponding journal entries can
be discarded.
Structure of Linux directory entries
• Each entry of a Linux directory consists of four fixed-length fields and
one variable-length field.
• The fixed files are:
• The first field is the i-node number.
• The next field tells how big the entry is (in bytes),
• Next is the type field: file, directory, and so on.
• The last fixed field is the length of the actual file name in bytes
• Finally, comes the file name itself, terminated by a 0 byte
Linux hierarchical file naming
• Linux hierarchical
naming:
• /users/faculty/rama/foo
• Each part of the file
name corresponds to
an i-node which form
part of a tree like
structure where all but
the leaf nodes are
directory files (which
are i-nodes)
• Each directory entry
contains a type which
indicates if it is a
directory or a data file
The big picture
• The first thing the MBR program does is locate the active
partition, read in its first block, which is called the boot block,
and execute it.
• The program in the boot block loads the operating system
contained in that partition
Why disk partitioning
• On DOS, Microsoft Windows, a common practice is to use one
primary partition for the active file system that will contain the
operating system, the page/swap file, all utilities, applications, and
user data.
• On most Windows computers, the drive letter C: is routinely
assigned to this primary partition.
• On Unix-like operating systems it is possible to use multiple
partitions on a disk device. Multiple partitions allow directories such
as /boot, /tmp, /usr, /var, or /home to be allocated their own
filesystems. Such a scheme has a number of advantages:
• If one file system gets corrupted, the data outside that filesystem/partition
may stay intact, minimizing data loss.
• Specific file systems can be mounted with different parameters, e.g.,
read-only, or with the execution of setuid files disabled.
• Keeping user data such as documents separate from system files allows the
system to be updated with lessened risk of disturbing the data.
• A common minimal configuration for Linux systems is to use three
partitions: one holding the system files mounted on "/" (the
root directory), one holding user configuration files and data mounted
on /home (home directory), and a swap partition.