- Storage
- Traditional storage device is a
mechanical disk drive.
- Data is recorded by magnetizing (or not)
spots on the platter surface.
- The platter spins constantly.
- The head moves on the arm as needed to access specific data.
- Data are recorded in circles called tracks.
- Tracks are divided into sectors.
- A sector is the minimum amount of data which can be transferred,
traditionally 512 bytes.
- To read or write, the head must move to the track, wait for
the sector, then perform the transfer while the sector passes
underneath.
- Head motion is the slowest.
- Larger (or more often just older) drives use a stack of platters.
- There are heads for each platter, but they move together, so they
are always positioned at a group of tracks which are aligned.
- Such a stack of tracks is called a cylinder. Sectors in the
same cylinder may be read without moving the head.
- All common file systems have been designed to make efficient use
of such a device, especially to minimize head motion.
- Many devices today, especially mobile ones, use flash storage.
- Flash drives are electronic, and generally faster.
- Behavior and optimization of flash is totally different.
- Current practice is to treat flash drives like hard drives anyway,
using existing techniques.
- We have a section on flash later.
- Disk layout
- The OS treats a disk as a series of sectors.
- Physical disks are usually divided into partitions.
- The partition table at the front of the disk defines partitions
as ranges of sectors of the physical disk.
- Each partition contains a separate file system, often of different
file types.
- When the OS starts using a disk, it looks for a partition table.
- If none, it's just a single disk.
- If present, each partition is treated as a separate disk.
- Traditional PC format is
Master Boot Record (MBR) layout. (AKA DOS layout.)
- MBR is sector zero.
- Partition table is part of the MBR, and is of fixed size four.
- The format also allows for “extended partitions” so a disk
may have more.
- A partition may be marked extended in the MBR.
- Such a partition contains another partition table which
subdivides it.
- These subdivisions are treated as partitions of the disk,
rather than the extended partition.
- Partitions have one-byte type codes which are not managed.
Codes are used inconsistently by different software.
- Disk offsets are 32-bits. Denoting a 512-byte sector, this
limits disks to 2 TB.
- Newer: GUID Partition Table (GPT) layout.
- Variable-sized table, so many partitions are possible.
- Partition types given by GUIDs, which are large
identifiers.
- Supports much larger offset numbers.
- Text figure illustrates layout of a Unix fs, but layout in a partition
will depend on OS.
- There are many different file system designs.
- Usually associated with a particular O/S.
- Or with media type.
- Most OSes must support more than one type of FS.
- File systems are generally part of the OS, but some may be
supported in user space.
- File layout.
- Efficiency of operations:
- Sequential reading.
- Random-access reading.
- File growth.
- Basic approaches.
- Contiguous.
- Linked.
- Simple linked files.
- FAT.
- Indexed (i-nodes).
- Basic indexes.
- Index with blocks.
- Real systems make variations and combinations of these.
- Directory layout.
- A directory is just a list of files, given by location on disk.
- File name may be recorded in the directory entry, or the file.
Other meta-data likewise.
- Directory may be a list of fixed-size entries.
- Easy to maintain.
- Tends to create a short limit on file names.
- Directory may be a list variable-size entries.
- Same sort of problems as variable partitions.
- More flexible
- May combine fixed records with a head area for file names.
- In practice, don't seem to use fancy search-able structures.
- Multiple directory entries
- Hard linking.
- Some FSs allow a file to have multiple directory entries (Unix).
- Some do not (Windows).
- Allows a file to have multiple names. (At least different full
path names.)
- Soft linking.
- Some systems allow a special file which name another.
- Allows a file to have multiple names with only one directory entry.
- Text mentions log-structured file systems.
- Text mentions virtual file systems.