210 likes | 303 Views
Operating System Concepts and Techniques Lecture 18. Information management-2* FFS, UFS2, NTFS M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011. To order: www.iUniverse.com , www.barnesandnoble.com, or www.amazon.com
E N D
Operating System Concepts and Techniques Lecture 18 Information management-2* FFS, UFS2, NTFS M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011. To order: www.iUniverse.com, www.barnesandnoble.com, or www.amazon.com * Information management is not usually covered in the first course of operating systems
Fast file system • Larger block size than UFS • To avoid excess internal fragmentation: • A data block is divided into a number of equal size fragments (often eight). These fragments can be independently assigned to files and directories • Since UNIX frequently has many small files and directories, most of the time these are placed in the fragments left over by larger directories and files • In the file’s or directory’s i-node eight bits are reserved to show which segments of the last data block is occupied by this file • A one means it is used and a zero means otherwise
Fast file system... • Based on UFS • Data blocks of a file or directory are stored in cylinders that are placed as close as possible to each other • A number of adjacent cylinders are called a cylinder group • The on-disk i-node of a file or directory is stored in the same cylinder group of the file or directory • Data blocks of directories are distributed across the whole disk’s data area so that a directory’s data blocks are close to its files data blocks • Furthermore, a file’s and directory’s on-disk i-node is stored as close as possible to the file’s or directory’s data blocks
Fast file system... • Other improvements: • The Berkeley FFS has two superblocks instead of one. If one of the superblocks becomes faulty the system immediately switches to the other and starts repairing • Another FFS enhancement is the increase in the file name’s length to 255 characters • Yet another improvement is its two different block sizes, for example, 4K and 8K • For small size files (or directories), the first block size is used and for large size files there is the second block size.
FFS adv/disadv • Advantages: • Accessing a directory’s or file’s data is faster because the number of seek times is usually less than that of the original UFS file system • Disk head movements are reduced thus raising overall performance • Superblock failure recovery is possible • Can be used with UFS and USF2 • Disadvantage: • Increases the complexity of the file system implementation
UNIX File System 2 • Based on UFS • Pointers to USF2 data blocks are eight bytes long, one tera byte file can be stored • the size of each i-node is 256 bytes • Usually few bunch of consecutive blocks are assigned, simultaneously • Number of pointes is reduced
NTFS file system • Objectives: • Supporting a wide range of systems; has many versions • Recoverability • File system recovery; use of transaction concept • Security and protection • File and directories are considered object, must have the right to access • Memories are cleared before allocation • Windows provides the capability to encrypt file information upon the user’s request • Very large files • A file can be as large as 264 bytes
Boot sector Master file table Recovery data Attributes and data blocks Volume • Volume is a collection of clusters for which a file system is used • Can be part of a disk, a disk, or a set of parts of many disks • The maximum size of a volume is 264 bytes • Four general sections are identified in a volume • Like UNIX, files and directories are treated the same • in NTFS, name, attributes, and data of files all called attributes
Boot sector • One OS per volume possible, one boot sector per OS • Boot sector (Master Boot Record (MBR) in 32-bit or GUID (Globally Unique Identifier) Partition Table (GPT) in 64-bit ) • 512 bytes • Very essential metadata of the volume such as, the number of bytes per sector, the number of sectors per cluster, disk type (floppy, hard), the number of sectors per record, the location of master file tables, disk identification, and whether the volume is bootable or not • A small machine language program
NTFS Boot Sector 0x00 3B Jump Instruction 0x03 8B OEM-ID (original equipment manufacturer-id) 0x0B 25B BPB (BIOS Parameter Block)* 0x24 48B Extended BPB* 0x54 426B Bootstrap Code. 0x1FE 2B End of Sector Marker * 0x0B, Bytes per sector. 0x0D Sectors per Cluster 0x15 Media descriptor. F8: HD; F0: HD Floppy 0x28 Total sectors. 0x30 Logical cluster number for the MFT 0x38 Logical cluster number copy of the MFT 0x40 Clusters per MFT Record. 0x48 Volume serial
NTFS Master File Table • Information on how to find files and directories attributes and data • A record based file; each record is 1K • There is at least one record for each file (or directory) called base record • A file’s entire metadata may not fit in one record; in such case, extended records are allocated • A file of variable size • Not all attribute names are applicable to all files • First 16 records are reserved for metadata files, their name begins with $ • First four entries are replicated for MFT repair
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 . . . $Mft Master file table $MftMirr Mirror copy of Mft $LogFile Log file for recovery $Volume Volume file $AttrDef Attribute definition $ Root directory $Bitmap Bitmap of clusters used $Boot Bootstrap loader $BadClus List of bad clusters $Secure Security descriptors of files $Upcase Case conversion table $Extend Extension: quotas, etc Reserved for future use Reserved for future use Reserved for future use Reserved for future use A User file A User file . . . System files User files and system and user files extensions 1K Master File Table
Some metadata Other MFT records for this file File data clusters Unused An MFT record • Different sections of a MFT record
Example • Example: Suppose a file’s data is stored in cluster numbers 501, 502, 503, 585, 586, 587, 588, 589, 621, 622, 623, 624, 625, 674, 675, 676, 677, 678, 690, and 691 • How this information is stored in the file’s base and extended MFT records? • If each set of adjacent clusters is called a bunch, then this file’s clusters will form five bunches: 501 to 503, 585 to 589, 621 to 625, 674 to 678, and 690 to 691 • Suppose also that two MFT records are needed to save the attributes of this file
Headers674 4 690 2 Free space Headers and file attributes Header 482 Header 501 3 583 5 621 5 Example… • The first record is the base record with record number sya 125 and the second one is an extended record with record number say 482 • Roughly speaking, the information shown in the figure above is stored in the base record of this file • The information in the figure below is stored in the extended record of this file • Headers are delimeters
Accessing a file and its data • Suppose the following figure is the structure of the files and directories of the specific volume in which file K’s data is to be located • The absolute path of the file is /C/R/KD D C B A P R X W S Directory File Q L K
Accessing a file and its data... • Root directory is stored in record number 5 of MFT • Suppose root’s data are stored in say cluster no. 950 • Cluster number 950 is accessed, the information is the names and base MFT records of the root directory’s files and directories • A sequential or B+ search locates C and its base MFT record is 125 • This record is accessed just as C was searched for with record 5 replaced by 125 and C replaced by R, suppose record 85 is the base MFT record for R • Now, K must be found; suppose this is done and the base MFT record 94 is extracted for file K • From this base record and its extensions, all metadata and data of file K can be located
NTFS Summary • Berkeley Fast File System was briefly discussed • UNIX File System 2 was also briefly introduced • The design details of New Technology File System was studied • Each file on an NTFS volume is represented by a record in a special file called the master file table (MFT) • The first 16 records of MFT are for special files • Each file and directory has a base MFT record and zero or more extended record to store its metadata • Directories are also viewed as files by NTFS • An example was presented to show how a file’s metadata and data are stored and how we can locate a file or directory
Find out • The advantages of UFS2 over USF • The detailed information stored in base MFT record • What is the purposes of record numbers 12, 13, 14, and 15 of the MFT file • The maximum size of a file whose metadata and data can completely fit in its base MFT record • The purposes of record number four of MFT file • How we can use two disks as one volume • Which records of the MFT file are duplicated • The purposes of duplicating some records of the MFT file