Hard Disk Partitions - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Hard Disk Partitions

Description:

block management directories. Hard Disk Partitions. Why have partition hard disks? ... blocks placed in the /lost found directory with inode number as the name ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 13
Provided by: quynh6
Category:

less

Transcript and Presenter's Notes

Title: Hard Disk Partitions


1
Hard Disk Partitions
  • Disk divided into partitions
  • Definition of partition group of adjacent
    cylinders
  • 1 file system may reside in a single partition
  • BIOS defines boot sector to be head 0, cylinder
    0, sector 1
  • Master Boot Record (MBR) used to boot computer
  • Partition table
  • Start and end addresses of each partition
  • One partition is marked as active
  • When computer boots up
  • BIOS executes MBR
  • MBR locates active partition and executes boot
    block

2
Hard Disk Partitions
  • Each partition
  • Starts with boot block even if it does not
    contain bootable OS
  • Superblock key parameters about file system in
    partition such as magic identifying file system
    type, number of blocks
  • Bitmap or linked-list of free blocks free space
    management
  • Inodes array of these (one per file)
  • Root directory of partition
  • Files and directories at the end

3
Hard Disk Partitions
  • Why have partition hard disks?
  • To subdivide disk into a number of intended uses
  • Exp. May have data partition separate from
    application program partition.
  • Which partition would need to be backed up often?
  • Want to have different OS or file systems using
    incompatible data structures
  • OS or file systems can be tuned separately
  • Safety from physical separation
  • Unmount file system when it is not needed
  • Backup some partitions more frequently
  • Use spare partitions for backup or for storing
    state when computer hibernates

4
Booting Up DOS
  • BIOS
  • Reads 446 byte program from partition sector into
    memory at 0x7C00
  • Checks indicator at 0xAA55
  • Executes program
  • Program actions
  • Recognize exactly 1 of 4 partition entries as
    active
  • Move itself from 0x7C00 to 0x0600 to make room
    for partition boot sector
  • Load active partitions boot sector into 0x7C00
    and jump to it

5
Unixs FSCK (File System Check)
  • Check for file system consistency after a crash
  • Causes of inconsistencies crash during
    multi-block transaction
  • Phases of FSCK
  • 1) Inode checks
  • Out-of-range block numbers
  • Blocks claimed by more than one file
  • 2) Size checks
  • Number of blocks claimed is inconsistent with
    size?
  • Directory size not a proper multiple
  • Directory checks
  • Missing . or ..
  • Entry points to out-of-range inode number
  • Entries do not fit correctly overlap or not all
    space is accounted for

6
Unixs FSCK (File System Check)
  • Phases of FSCK
  • 4) Pathname checks
  • File/directory not referenced by root-anchored
    pathname
  • 5) Link count checks
  • Inode link count does not equal sum of those in
    directory entries
  • 6) Free map checks
  • Blocks claimed by both free map and files
  • Unclaimed blocks not in free map
  • 7) Superblock checks
  • Total free block and/or inode count incorrect
  • More disk blocks allocated for inodes than max
    possible inodes

7
Unixs FSCK (File System Check)
  • Non-empty unreferenced blocks placed in the
    /lostfound directory with inode number as the
    name
  • If possible, implement by reading superblock and
    all cylinder group headers, directories, and
    inodes, into memory then apply tests
  • Above data structures are a small fraction of
    disk space (most of file system occupied by data
    blocks)

8
Unixs FSCK (File System Check)
  • Phase 5
  • 1 counter per file
  • Scan all directories increment count for inode
    when inode is seen in directory
  • Compare count vs. link field in inode
  • If (links ! count) and (count gt 0) set links
    count
  • If (links ! count) and (count 0) link inode
    into /lostfound directory with inode number as
    name

9
Unixs FSCK (File System Check)
  • Phase 1 6
  • 2 counters per block number of times in a file
    and number of times in free map
  • Check counter values as follows
  • in file in free map consistent?
  • 1 0 ok
  • 0 1 ok
  • 0 0 lost block, add to free map
  • gt1 1 rebuild free map, then check
  • if in-file gt 1
  • gt1 0 copy block redefine files

10
File System Performance Improvements
  • Caching
  • Similar to memory pages
  • If requested block is not in cache, load into
    cache first and then access
  • Use hash table for quick search hash on device
    and disk address
  • Block replacement algs. similar to memory page
    replacement algs. (FIFO, second chance, LRU)
  • Goals are slightly different
  • Blocks essential to consistency of file system
    should be written back to disk immediately
  • Blocks not needed again should be written back to
    disk and released

11
File System Performance Improvements
  • Caching continued
  • Unix
  • Sync command forces all modified blocks to be
    written to disk
  • update program runs in background after system
    starts and calls sync every few seconds
  • Windows
  • Uses write-through caching
  • Write every modified block to disk immediately
    most programs do internal buffering, so writes
    more than just one character at a time
  • Block read ahead
  • read more than requested block

12
File System Performance Improvements
  • Reduce disk arm motion
  • Block clustering attempt to place consecutive
    blocks in a file in the same cylinder
  • Place inodes in the middle of disk rather than at
    the start after inode access, arm moves at most
    half disk width to seek to file
  • Log-structured file system
  • Rarely used
  • Structure entire disk as a log
  • Pending writes are buffered in memory, collected
    into a single segment, and written to disk as
    single contiguous segment at end of log
  • Segment may contain inodes, directory blocks,
    data, etc.
  • Need inode map indexed by inode number to find
    inodes since they are not scattered throughout
    disk
  • Map is stored on disk and cached
Write a Comment
User Comments (0)
About PowerShow.com