ECM 1413 File Management Flashcards
Definition of a file
a named collection of related information that is recorded on secondary storage (non-volatile memory).
How do we determine the type of a file
File extensions help the operating system determine how to interpret the file (.txt, .exe, .docx)
Magic numbers (a sequence of bytes at the beginning of a file) also determine file type
Metadata (file attributes) include:
the name of the file
the identifier of the file
The type of file
the location of the file on a storage device
the size of the file (size on disk: sometimes the file will take more space than required)
the protection mode of the file, giving permissions
the times that the file was created/accessed/modified
2 distinctive features of the Linux file system:
1 an everything is a file approach
2 files represented by a tree-like inode (index node) pointer structure
metadata on Linux is stored on inode files
Six types of files in Linux
Regular files
Directories
Special files (Character [transfers data character by character or byte by byte] or Block [transfers data k-bytes by k-bytes])
Pipes (Chains commands, an output becomes an input for another operation)
Links (hard)
Symbolic links (soft)
Hard Links
point to an file via its inode directly
If the file is moved/deleted, the link will still work
A hard link is another name for an existing file
Soft links
pointer to a filename
If the file is moved/deleted, the link will not work
In Linux, file allocation on disk is done in fixed-sized blocks, with each block typically being 4096 bytes (4KB)
How can we keep track of where blocks for a file are located?
A file is broken down into chunks that fit into blocks
- Smaller than the block -> internal fragmentation
○ Internal fragmentation: Space in a block that is empty and unused
- Larger files span multiple blocks
The inode pointer structure
The inode keeps track of where different blocks are stored using pointers
Direct - directly refers to data on the disk
Single - Refers to another pointer that refers to blocks; used to store larger files
Double - Larger than single
Triple - Larger than double.
How we implement these abstract file management systems:
1 Magnetic disks
2 Solid state disks
How do magnetic (/hard) disks operate
A magnetic disk has a number of spinning circular platters, over which hover some heads attached to a movable arm. The magnetic disk is read/written by having the head sense/change the magnetism of a sector.
At a bit level
magnetism in one direction represent a one
magnetism in the other direction represents a zero
Each platter is divided into circular tracks
Each track is divided into sectors
The set of tracks across different platters at a given arm position make up a cylinder
Each sector has a fixed amount of data (traditionally 512 bytes, became 4KB); This is the smallest unit that you can transfer to or from a disk
A magnetic disk is read/written by moving the arms in/out to the required cylinder
All heads/arms move together
The platters rotate; the rotation speed is related to the data transfer rate
Solid state disk contents and operations
A solid-state disk has no moving parts and instead stores data using flash memory.
A solid-state disk has
a controller (an embedded processor)
buffer memory (volatile memory)
flash memory
- Is divided into pages that are grouped into blocks
A typical solid-state disk might have 4 kB pages and a 512 kB block size.
In this case, each block consists of 128 pages.
The act of erasing flash memory requires a high amount of voltage, and can therefore only be done on block level.
Overwriting requires an erase operation, and is therefore slower than reading or writing to an empty drive.
How is SSD read
1 copying a flash memory page into the buffer
2 reading data from the page in the buffer
How is SSD overwritten
1 copying a memory block into the buffer
2 erasing the block in the flash memory
3 modifying the block in the buffer
4 writing the block from the buffer to the flash memory
Pros and cons of SSD
+Solid-state disks are faster than magnetic disks
+Solid-state disks are more reliable than magnetic disks
+Solid-state disks are more power-efficient than magnetic disks
-Solid-state disks deteriorate with every write process
-Solid-state disks are more expensive than magnetic disks