Lecture 13 - File Layout Flashcards
What is contiguous allocation?
Each file occupies a set of contiguous (consecutive) blocks on the disk
Directory entries point to a contiguous block
What are the pros and cons of contiguous allocation?
Pros: Easy indexing - start & length
Random access well supported
Cons:
Difficult to grow files, must preallocate needed space
Wasteful if not all space is used
What is linked allocation?
Each file is a linked list of disk blocks
Blocks may be scattered anywhere
What are the pros and cons of linked allocation?
Pros: Simple - need only starting address
can grow anywhere in the file - middle, ends
Good for sequential access
Cons: Bad for random access
Slow - need to read through sequentially to find the rquired part of a file
Can be unreliable - system crash can completely mess up a file that was busy being updated
What is indexed allocation?
Each file has an index block which points to all the blocks of the file
Directory entry points to this index block
What file layout does UNIX use?
Index nodes
How do unix index nodes work?
Disk has inode table that contains inodes of all files in the system
I node contains file attribute data (metadata) and can point to other inodes
Example: mode, owners, timestamps, size, count, block pointers, inode pointers
How can free space be managed by a bit vector?
Keep a bit vector with one entry per file block
If bit for a given block is 1, implies the block is free, else occupied
What are the pros and conds of bit vectors for managing free space?
Pros: Easy to find consecutive blocks and update entries
Conds: Must be stored on disk, and thus consumes space
How can free space be managed by a linked list?
Make all free blocks a linked list so each free block points to the next
What are the pros and cons of linked list free space management?
Pros: No wasted space
doesn’t matter that free space cant be randomly accessed usually
Cons: Difficult to know total number of free blocks unless its tracked elsewhere
Difficult to group nearby blocks together if they’re freed at different times
What is a directory?
A file mapping names to metadata/data
What are two directory implementations?
Linear list of file names with pointers to the data blocks - simple, but time consuming to execute (can be alleviated with sorted list)
Hash table - linear list with hash data structure - decreases search time but may have collisions
What is a volume?
An entity containing a filesystem
What is the difference between formatted and raw partitions?
Formatted contains a filesystem i.e. it is a volume
Raw is just a collection of bytes