Guide to Operating Systems, 4th ed. Chapter 4: File Systems
List the basic functions common to all file systems Explain the file systems used by Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, and Windows 7 (FAT16, FAT32, FAT64, and NTFS) Discuss the file systems used by UNIX and Linux systems, including ufs and ext Explain the Mac OS X Extended (HFS+) file system including new features added in Mac OS X version 10.6 Leopard Objectives Guide to Operating Systems, 4th ed. 2
Understanding the File System Functions All information stored on a computer’s hard disk is managed, stored, and retrieved through a file system The file system allocates locations on a disk for storage and it keeps a record of where specific information is kept Some file systems also implement recovery procedures when a disk area is damaged or when the OS goes down Guide to Operating Systems, 4th ed.
Understanding File System Functions File systems used by operating systems perform the following general tasks: Partition and format disks to store and retrieve information Enable files to be organized through directories and folders Establish file-naming conventions Provide utilities to maintain and manage the file system and storage media Provide for file and data integrity Enable error recovery or prevention Secure the information in files Guide to Operating Systems, 4th ed.
Understanding the File System Functions The overall purpose of a file system is to create a structure for filing data The file cabinet = the computer The drawers = disk drives Within each drawer (disk) - Information is organized into: Hanging folders (directories) Manila Folders (subdirectories) Individual documents (files) Guide to Operating Systems, 4th ed.
Understanding File System Functions A file is a set of data that is grouped in some logical manner, assigned a name, and stored on the disk The file system records where the file is located on the disk The data contained in files can be text, images, music and sounds, video, Web pages. All data must be converted into digital (binary) format – a series of 1s and 0s There must be a way to write digital information onto disk, track it, update it, and retrieve it when the user or a program wants it. Guide to Operating Systems, 4th ed.
Understanding File System Functions To achieve this the OS: Groups disk sectors in some logical way; Creates a record of this structure; Builds a directory or folder to track the type of data stored in each file. Directory or folder – an organizational structure that contains files and may additionally contain subdirectories (subfolders) under it. The directory connects names to the files that are stored on the disk. Guide to Operating Systems, 4th ed.
Understanding File System Functions Directories also stores the following information: Date and time the directory or file was created Date and time the directory or file was last modified Date and time when the directory or file was last accessed Directory or file size Directory or file attributes, such as security information, or if the directory or file was backed up If the information in a directory or file is compressed or encrypted Guide to Operating Systems, 4th ed.
Designing a Directory Structure Directories and folders can be organized in a hierarchy that is similar to a tree structure. Building a hierarchy of folders and subfolders enables you to fine-tune the organization of files and folders in a methodical way so that information is easy to find and use. Without a well-designed directory or folder structure, it is common for a hard disk to become cluttered and disorganized with different versions of files and application software. Some users keep most of their files in the computer’s primary level or root directory (root folder) or they load all application software into a single directory. Guide to Operating Systems, 4th ed.
Designing a Directory Structure Some programs use an automated setup that suggests folders for new programs Example – creating new subfolders under the Program Files folder A chaotic file structure makes it difficult to: Run or remove programs; Determine the most current versions; Makes users spend unproductive time looking for specific files. To avoid chaos, design the file and folder structure from the start (especially on servers). Plan to design a directory structure that complements the one already set up by the OS. Guide to Operating Systems, 4th ed.
Designing a Directory Structure The default OS, along with the structure that you add might consist of the following: OS files (set up by the OS; Software Applications (often set up by both the OS, the software applications that you install, and decisions you make about how to install those applications; Work files such as word-processing, graphics, spreadsheet, and database files (set up by the user any by applications); Public files that you share over the network (set up by the user); Utilities files (set up by the OS, the Utilities applications, and decisions about how to install specific utilities); Temporary files (set up by the OS, applications that use temporary files, and decisions about where to store temporary files). Guide to Operating Systems, 4th ed.
Designing a Directory Structure In deciding how to allocate folders for specific types of files, consider following some general practices: Root folder should not be cluttered with files or too many directories/folders Each software application should have its own folder/subfolder so updates and software removal are easy to administer Similar information should be grouped (example: accounting systems or office productivity software) Operating system files should be kept separate and protected Directories and folders should have names that clearly reflect their purposes (a folder named “Shared” would contain documents that can be shared by many users) Guide to Operating Systems, 4th ed.
Designing a Directory Structure The folder structure from the root might be: Windows – for the system files Program Files – for general software and utilities Documents and settings – for work files and spreadsheets Shared – for spreadsheets that are shared over the network Forms – for specific types of forms used by the legal forms software Inetpub – for Web pages Guide to Operating Systems, 4th ed.
Designing a Directory Structure Sample folder structure for a Windows-based system Guide to Operating Systems, 4th ed.
Designing a Directory Structure For Linux systems, a typical directory structure that is already provided by the OS is: bin – for user programs and utilities (binary files) sbin – for system administration utilities (system binary files) lib – for runtime library files needed by programs stored in the /bin and /sbin directories usr – for user files and programs var – for files in which content often varies or that are used only temporarily tmp – for files used only temporarily dev – for devices mnt – for floppy drives, DVD/CD-ROM drives, flash drives, and other removable media Guide to Operating Systems, 4th ed.
Designing a Directory Structure For Linux systems, a typical directory structure that is already provided by the OS is: etc – for system and configuration files root – for files used by the root account home – for users’ home directory (or folder) and typically stored in subfolders named for each user proc – for system resource tracking Guide to Operating Systems, 4th ed.
Designing a Directory Structure In MAC OS X, the default folder structure created by the OS from the root level includes: Applications – for MAC OS X software applications Applications - (MAC OS 9) for applications used with the earlier MAC OS 9 System Folder – for MAC OS 9 system files System – for MAC OS X system files Library – for library files (such as fonts) Users – for user accounts, with subfolders for each user account to store files Documents – for documents Guide to Operating Systems, 4th ed.
Disk Storage Basics Hard disks arrive from manufacturer with low-level formatting A low-level format is a software process that marks the location of disk tracks and sectors Tracks are like several circles around a disk and each track is divided into sections of equal size called sectors Guide to Operating Systems, 4th ed.
Disk Storage Basics Disk tracks and sectors on a platter Guide to Operating Systems, 4th ed.
Block Allocation Block allocation – divides the disk into logical blocks (clusters), which correlate to sectors, heads, and tracks on the disk Keeps track of where specific files are stored on the disk Hard drives are made up of multiple disks (platters) Each hard disk platter has two sides, with a read/write head on each side. Cylinders - tracks that line up on each platter from top to bottom and are all read at the same time Guide to Operating Systems, 4th ed.
Block Allocation When the OS needs to allocate disk space, it does so based on a block address which is a way to address the hard disks by a single sector number. The reference to a file in the directory and in the file allocation data is based on block numbers. Data regarding block allocation is stored using one of two techniques: File allocation table (FAT) – uses a fixed portion of the disk to store this data. Initially implemented in MS-DOS and supported by all versions of Windows. Guide to Operating Systems, 4th ed.
Block Allocation Data regarding block allocation is stored using one of two techniques (contid) New Technology File System (NTFS) and Unix/Linux file systems – uses various locations on the disk to store a special type of file that is used for directory and file allocation information (metadata) Guide to Operating Systems, 4th ed.
Partitions Before a file system can be placed on a hard disk, the disk must be partitioned and formatted. Partitioning – the process of blocking a group of tracks and sectors to be used by a particular file system, such as FAT or NTFS After partitioning, the disk must be high-level formatted in order for the OS to store files It might be necessary for a disk to have more than one file system to allow multiple OSs Will require a partition for each file system Example: To allow the installation of Red Hat Enterprise Linux and Windows 7 on the same computer Guide to Operating Systems, 4th ed.
Partitions You can partition a disk so that different file systems can be installed on different disk partitions. Logical drives – creating multiple logical volumes on a single disk and assigning drive letters to each volume. When a partition is created, information about that partition is stored in a special area of the disk known as the partition table (in MS-DOS, Mac OS, and Windows) and disk label (in UNIX/Linux) Another piece of disk that is reserved is known as the boot block in UNIX/Linux and Mac OS X, or the Master Boot Record (MBR) in MS-DOS and Windows. Guide to Operating Systems, 4th ed.
Partitions • In Windows, the MBR consists of four elements: • The boot program – examines the partition table to determine which partition (the active partition) to boot from • Enables them program code in the active partition’s start area to execute and then point to the code that starts the OS. • The disk signature – stores information about the disk and is used by management software such as the Windows registry • The partition table for the active partition • The end-of-MBR marker – where the MBR ends • Not all operating systems support partitions in the same way • Each operating system uses specific utilities to create partitions Guide to Operating Systems, 4th ed.
Formatting After the disk is partitioned, the file system is placed on the partition. Necessary in order to install an operating system After the OS is installed, a disk management tool can be used to partition and format additional free space Another option for formatting is to use the format command from the Command Prompt window Writes all of the file system structure to the disk. Creates the boot block / Master boot record and adds information about the disk Number of tracks Number of sectors per track Guide to Operating Systems, 4th ed.
Formatting When a file is stored to disk: The data is written to clusters on the disk Filename is stored in the folder, along with the number of the first cluster the data is stored in When the OS fills the first cluster, data is written to the next free cluster and the FAT entry corresponding with the first cluster points to the number of the second cluster used When the second cluster is full, the OS continues with the next free cluster and the FAT entry for the second cluster points to the number of the third cluster used, and so on… When a file is completely written to the disk, the FAT entry for the final cluster is filled with all 1s (means end of file) This process is commonly referred to as the linked-list method Guide to Operating Systems, 4th ed.
Formatting Clusters are a fixed length When a files does not use all of the space in a cluster, the rest of the cluster is unusable Unusable spots are marked in the FAT as bad clusters (never used for file storage) Each partition stores and extra copy of the FAT table in case the first copy gets damaged There is only one copy of the root directory on each partition (see figure on the following slide) The FAT tables and root directory are at the beginning of each partition and always at the same location Guide to Operating Systems, 4th ed.
Formatting Typical FAT directory structure Guide to Operating Systems, 4th ed.
Formatting • Each FAT directory entry contains filename, file change date and time, file size, and file attributes • The filename consists of the name and the extension. • Extensions can have a special meaning • .sys – device drivers • .com / .exe – program files the OS can execute • .bat – batch files of commands that can be executed Guide to Operating Systems, 4th ed.
Formatting • The File Attributes identify the type of filename contained in each entry: • Volume • Indicates a file system volume label or nickname for the file system • Set with the /v option of the format command • Directory • Signifies that a file contains folder data and should be treated as a folder by the file system • Folders may contain subfolders, as long as the names of all subfolders in a path do not exceed 80 characters Guide to Operating Systems, 4th ed.
Formatting • The four remaining File Attributes indicate additional information about a file: • System (S flag) • Files that are part of the OS and should not be touched by programs or users • Hidden (H flag) • Files that should not be visible to the user • Read-only (R flag) • Files that should not be written to • Archive (A flag) – Files that should be backed up the next time a backup is made Guide to Operating Systems, 4th ed.
Formatting • The attrib command: • Typing attrib followed by a folder name shows all the attribute settings for all the files in the folder • Typing attrib followed by a filename shows the attributes for that file • The attrib command can also be used to set file attributes. • The attrib command is followed by the attribute letter, the + sign to set, or the – sign to unset an attribute, and the filename Guide to Operating Systems, 4th ed.
Windows File Systems Windows XP, Vista 7, Server 2003, and Server 2008 support three files systems: Extended FAT16 FAT32 NTFS These OSs also support file systems for DVD/CD-ROM drives and USB devices (flash drives) Guide to Operating Systems, 4th ed.
FAT16 and Extended FAT16 • Extended FAT16 evolved from FAT16 used in earlier versions of MS-DOS and Windows (3.x/95/98/Me) • FAT16 • FAT uses a file allocation table to store directory information • The “16” in FAT16 means that this file system uses 16-bit entries in the file allocation table and uses 216 clusters Guide to Operating Systems, 4th ed.
FAT16 and Extended FAT16 • In extended FAT16: • Maximum size of a volume is 4GB • Maximum size of a file is 2GB • Has been around for awhile and can be read by non-Windows operating systems like UNIX/Linux • Considered a stable file system • Long filenames (LFNs) can be used • Can contain up to 255 characters • Not case sensitive • Cannot include “ / \ [ ] : ; = special characters Guide to Operating Systems, 4th ed.
FAT32 Support for FAT32 started with Windows 95 Release 2 FAT 32: Designed to accommodate larger capacity disks Avoids the problem of cluster size limitations The FAT entry is 32 bits in length and supports 228 clusters The Root folder does not have to be at the beginning of a volume. It can be located anywhere. Can use disk space more efficiently than FAT16 (because it uses smaller cluster sizes) Largest volume that can be formatted is 32 GB Maximum file size is 4 GB Offers fast response on small 1 or 2 GB partitions Guide to Operating Systems, 4th ed.
FAT64 FAT64 (exFAT) is a proprietary file system introduced by Microsoft for mobile personal storage needs to handle large files. The size limit for FAT16 is 2 GB minus one byte. The size limit for FAT32 is 4 GB minus one byte. FAT64 with a limit of 16 EB is a good choice for USB flash devices that may store large files (such as pictures, videos, etc…). FAT64 is available in Service Pack 1 for Windows Vista, Windows 7, and Windows Server 2008, Mac OS X Snow Leopard Support is available for Linux from a third party Guide to Operating Systems, 4th ed.
NTFS NTFS – the dominant Windows file system for all Windows operating systems starting with Windows 2000. Designed for the needs of a networked environment. Uses a Master File Table (MFT) instead of FAT tables. Located at the beginning of the partition. The boot sector is located ahead of the MFT. Following the MFT, there are several system files that the file system uses to make all the features of NTFS work. Guide to Operating Systems, 4th ed.
NTFS The MFT is nothing more than a file on the file system. The second file on the disk is a copy of the first three records of the MFT. This ensures that if the MFT is damaged, it can be recreated. File number five ($) contains the entries in the root directory. File number six ($Bitmap) contains data about what clusters on the disk are in use. Normally, the MFT and related files take up about 1 MB of disk space When a file is created in NTFS, a record for that file is added to the MFT. Guide to Operating Systems, 4th ed.
NTFS This record contains all standard information (filename, size, dates, and times). It also contains additional attributes such as security settings, ownership, and permissions. The attributes can generally be repeated. It is possible to have a whole series of different security attributes for different users. It is also possible to have multiple filenames that refer to the same file (hard linking). Also available in UNIX/Linux file systems, sometimes used to make the same file appear in multiple directories without having to allocate disk space for the file more than once. Guide to Operating Systems, 4th ed.
NTFS Windows Vista, Server 2008, and 7 use NTFS version 6 Windows XP and Server 2003 use NTFS version 5 Windows NT 4.0 used NTFS 4 Guide to Operating Systems, 4th ed.
NTFS Basic features of NTFS: Long filenames Built-in security features Better file compression than FAT Ability to use larger disks and files than FAT File activity tracking for better recovery and stability than FAT Portable Operating System Interface for Unix (POSIX) support Volume striping and volume extensions Less disk fragmentation than FAT Guide to Operating Systems, 4th ed.
NTFS NTFS is equipped with security features that meet the US government’s C2 security specifications Refers to high-level, “top-secret” standards for data protection, system auditing, and system access Examples: System files can be protected so only the server administrator has access A folder of databases can be protected with read access, but no access to change data Public folder can give users in a designated group access to read and update files, but not to delete files Guide to Operating Systems, 4th ed.
NTFS File compression is a process that significantly reduces the size of a file by removing unused space within a file or using compression algorithms. Some files can be compressed by more than 50%, saving disk storage for other storage needs. This is particularly useful for files that are accessed infrequently. Guide to Operating Systems, 4th ed.
NTFS NTFS has the ability to keep a log or journal of file system activity (journaling) Makes it possible for files to be restored in the event of a power failure NTFS supports POSIX standards to enable portability of applications from one computer to another. NTFS supports volume striping Process that equally divides the contents of each file across two or more volumes to extend disk life, enable fault tolerance, and balance disk load for better performance NTFS has hot fix capabilities If a bad disk area is detected, automatically copies the information to another disk area that is not damaged Guide to Operating Systems, 4th ed.
NTFS In addition to NTFS 4 features, NTFS 5 adds several new features: Ability to encrypt files No system reboot required after creating an extended volume Ability to reduce drive designations Indexing for fast access Ability to retain shortcuts and other file information when files and folders are placed on other volumes Ability to establish disk quotas (to control how much disk space users can occupy) Guide to Operating Systems, 4th ed.
NTFS With NTFS 5: Files can be encrypted so that their contents are available only to those granted access. Volume extensions can be set up without the need to reboot the system. Volume mount points can be created as a way to reduce the number of drive designations for multiple volumes, instead of designating a new drive for each new volume. Fast indexing is incorporated in conjunction with Active Directory to make file searching and retrieval faster. Distributed Link Tracking is available so that shortcuts you have created are not lost when you move files to another volume. Enables you to set up disk quotas to control how much space users can occupy. Guide to Operating Systems, 4th ed.
NTFS • NTFS 6 (latest version) adds several new features: • Transactional NTFS – used to perform operations in transactions (all at once or not at all). • You can package registry and file system operations in a transacyion so that all of the operations take place or none of them succeed. • Used heavily in Windows Server 2008. • Partition resizing – allows administrator to expand or shrink partitions. • The capability is still very limited. • There are third-party products that are more capable and robust. • Self-healing – the chkdsk utility runs in the background to correct hard disk problems (instead of having to take the volume down to run it) Guide to Operating Systems, 4th ed.
NTFS • The chkdsk utility can detect and fix an extensive set of file system problems in FAT and NTFS system • This utility is available in all versions of Windows starting with Windows 2000 • The most common problems found are files with 0 sizes, caused when a file is not properly closed or chains of clusters that have no directory entries • Windows 2000 and later versions have a built-in disk defragmenting tool • Rearranges data on the disk in a continuous fashion, ridding the disk of scattered open clusters Guide to Operating Systems, 4th ed.