Memory Hierarchy(from primary, faster to secondary and slower memory)
Flash memory will store data even it is powered off.
Cheaper for a given storage capacity. Used a lot in cameras, phones.
USB(Universal serial bus)
A lot of USB sticks use flash drive.
Solid state drives.
Optical storage(CD, DVD)
Use laser to read.
Can only be read sequentially.
Each magnetic disk will contain several platter. They are flat, circular. Their surfaces are covered with magnetic material. Plates are usually made of glass or metal.
units on disk
Each disk platter is divided into tracks, and then divided into sectors.
Usually a platter contains 50,000 – 100,000 tracks. Inner tracks usually have smaller length(smaller number of sector).
Sectors are usually 512 bytes. Each track usually have 500 to 1000 sectors in the inner track. sectors are the smallest “addressable” unit on the disk
The motor spins the disk at 60, 90, 120 rps(revolution per second).
How read-write head stores information through reversing the direction of the magnetic field.
The head floats above the disk
The head doesn’t touch the plate. The spinning creates breeze that lift the head.
Head crash would remove the storage medium. Further more, the removed medium will fly around, causing more crash.
Interface between the disk and the computer system. It is usually with in the disk drive. It accepts read-write command over a sector. controller also moves heads around.
Remapping of bad sectors.
If controller sees a sector become bad, an attempt to write to this sector will let controller logically map the sector to a different physical sector.
Interfaces to OS
ATA is a connection standard from 80’s
SAS（serial attached SCSI
SAN(Storage area network
Large numbers of disks are connected by a high speed network. The disks are usually organized using RAID (redundant arrays of independent disks). to give a logical view of a very large disk
NAS(network attached storage
It provides a file system interface using networked file system protocols such as NFS
Optimizing disk-block access
Requests for Disk I/O are from vm manager and file system
A block is a logical unit consisted of fixed number of contiguous sectors. Sometimes page is used to refer to blocks.
For successive block numbers. The disk will seek the first block. Then successive request will not require seek. It is a lot faster.
Just as the name imply
Blocks read are stored in an in-memory buffer for future requests.
When reading a block, read in consecutive blocks from the same track.(great for sequential)
When requesting different block, we might benefit from ordering the block requests.
We can organize blocks such that it corresponds closely to the way the data will be accessed. OS will often allocate multiple consecutive blocks at a time to a file to increase the chance of sequential write.
A file that have multiple small appends might become fragmented. The system can make a backup copy of the data and restore the entire disk. This restoration will write back the file sequentially to decrease the fragmentation.
Use a disk devoted to writing sequential log. Several consecutive blocks can be written at once. Since log disk can do writes later, the DB don’t have to wait for the write to complete.