Skip to content
CS-505 · Linux (LAB)/Quick Revision Short Notes

Linux (LAB) (CS-505) - Unit 3 Short Notes

How unit 3 is examined

This unit covers how Unix/Linux and Solaris organise disks into file systems: disk geometry, the controller, file system types, the UFS layout (boot block, super block, inode), tuning and repair. No topic was asked in recent papers, so each is a short definition plus key points.

Definition of File System

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>A file system is the method and data structure an operating system uses to name, store, organise and retrieve files on a storage device.</mark>

Key points.

  1. It divides a disk into fixed-size blocks and records which blocks belong to which file.
  2. It provides a directory hierarchy so files can be found by pathname, starting from the root /.
  3. It stores metadata such as owner, permissions, size and timestamps for every file.
  4. A file system must be created (formatted) and then mounted at a directory before use.

Defining Geometry

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>Disk geometry describes the physical layout of a disk as platters, heads, cylinders, tracks and sectors.</mark>

Key points.

  1. A track is one circular ring on a platter surface, a sector is the smallest addressable slice of a track (usually 512 bytes), and a cylinder is the set of tracks at the same head position on all surfaces.
  2. The disk is addressed by the triple cylinder, head, sector.
  3. Capacity is the product of the geometry values.
  4. Modern disks use logical block addressing, so the reported geometry is often virtual.

Formula. $\text{Capacity} = C \times H \times S \times 512$ bytes. For $C=1000, H=16, S=63$ this is about 516 MB.

Disk Controller

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>A disk controller is the hardware circuit that sits between the CPU or memory and the disk drive and controls reading and writing of data.</mark>

Key points.

  1. It receives commands from the device driver, moves the heads to the right cylinder and transfers the requested sectors.
  2. It usually uses DMA to copy data directly to memory without burdening the CPU.
  3. It has a buffer or cache that smooths the speed difference between disk and memory.
  4. Common interfaces are IDE, SATA, SCSI and SAS.

Solaris File System

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>Solaris is a Unix operating system from Sun whose default disk file system is UFS, and it also supports NFS, ZFS and pseudo file systems.</mark>

Key points.

  1. A Solaris disk is divided into slices (partitions) numbered 0 to 7, and each slice can hold one file system.
  2. Slice 2 by convention represents the whole disk, and slice 0 is normally root.
  3. Solaris file systems fall into three groups: disk-based, network-based and virtual (pseudo) file systems.
  4. Pseudo file systems such as /proc and /tmp (tmpfs) live in memory and hold no disk data.

Disk Based File Systems

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>A disk-based file system stores its files on a local physical device such as a hard disk, CD-ROM or floppy.</mark>

Key points.

  1. Examples are UFS on Solaris, ext2, ext3 and ext4 on Linux, and HSFS for CD-ROM.
  2. It is created on a slice or partition with newfs or mkfs and attached with mount.
  3. ext3 and ext4 add journaling, which logs changes first so recovery after a crash is fast.
  4. Its data survives reboots because it lives on stable storage.

Network-Based File Systems

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>A network-based file system lets a computer access files stored on a remote server as if they were on a local disk.</mark>

Key points.

  1. The main example is NFS (Network File System), which uses a client-server model over TCP/IP.
  2. The server shares a directory with share (Solaris) or exportfs (Linux), and the client attaches it with mount.
  3. Users see remote files in the normal directory tree, so no application change is needed.
  4. It centralises data, so many users share the same files and backups are easier.

Virtual File systems

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>The Virtual File System (VFS) is a kernel layer that gives applications one common interface to every file system type.</mark>

Key points.

  1. Programs call the same system calls, such as open, read and write, whether the file is on UFS, ext4 or NFS.
  2. VFS passes each call to the driver of the actual file system underneath.
  3. It makes adding a new file system type easy, since only that driver must be written.
  4. Solaris implements it with the vnode, an object that stands for an open file independent of its type.

UFS File System

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>UFS (Unix File System) is the standard disk-based file system of Solaris and BSD Unix, derived from the Berkeley Fast File System.</mark>

Key points.

  1. A UFS file system is divided into cylinder groups, and each group holds a backup super block, inodes and data blocks, which keeps a file's parts close together.
  2. The layout is boot block, super block, then cylinder groups.
  3. The default block size is 8 KB, and 1 KB fragments avoid wasting space on small files.
  4. Directories map file names to inode numbers.

The Boot Block

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>The boot block is the first area of a file system, holding the bootstrap program that loads the operating system.</mark>

Key points.

  1. In UFS it occupies the first 8 KB (sectors 0 to 15) of the slice.
  2. On a bootable slice it holds the small program that finds and loads the kernel.
  3. On a non-bootable slice the space is reserved but empty.
  4. On a PC the equivalent is the MBR in the first sector of the disk, which holds boot code and the partition table.

The Super Block

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>The super block stores the global information about a file system, such as its size, block size and the free block and inode counts.</mark>

Key points.

  1. In UFS it starts at sector 16, right after the boot block, and is 8 KB long.
  2. It records the number of cylinder groups, inodes per group, block size, fragment size and the mount state.
  3. Copies are kept in every cylinder group, so fsck can restore a damaged super block from a backup.
  4. If the super block is corrupted, the file system cannot be mounted.

The Inode

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>An inode (index node) is a fixed-size record that stores all the information about one file except its name and its data.</mark>

Key points.

  1. It holds file type, permissions, link count, owner and group IDs, size and the access, modification and change times.
  2. A UFS inode is 128 bytes and holds 12 direct block pointers plus one single, one double and one triple indirect pointer.
  3. The file name is stored in the directory entry, which links the name to the inode number.
  4. The number of inodes is fixed when the file system is created, so a disk can run out of inodes even with free space.

Formula. With 8 KB blocks and 4-byte pointers, one indirect block holds $8192/4 = 2048$ pointers, and the 12 direct pointers cover $12 \times 8 = 96$ KB.

Tuning File System

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>Tuning a file system means changing its parameters, after or during creation, to improve performance or use of disk space.</mark>

Key points.

  1. In Solaris the tunefs command changes parameters of an unmounted or read-only UFS, and on Linux tune2fs does the same for ext2, ext3 and ext4.
  2. The minimum free space (minfree) is reserved, by default about 10 percent in older UFS, so the system stays fast and root can still work when the disk is full.
  3. The optimisation setting chooses between time (faster allocation) and space (less fragmentation).
  4. Block size and inode density are fixed at creation by newfs and cannot be tuned later.

Repairing File System

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>Repairing a file system means checking it for inconsistencies with fsck and correcting them.</mark>

Key points.

  1. Inconsistencies arise when the system crashes or loses power before buffered changes are written to disk.
  2. fsck checks blocks and sizes, path names, connectivity, reference counts and cylinder group summaries, in that order.
  3. Files whose directory entry is lost are placed in the lost+found directory under their inode number.
  4. It must run on an unmounted file system, and it runs automatically at boot when the state flag is not clean.

Last-minute revision

  1. A file system names, stores and retrieves files on a device, and must be mounted to be used.
  2. Capacity equals cylinders times heads times sectors times 512 bytes.
  3. The disk controller talks to the driver, moves the heads and uses DMA.
  4. Solaris slices are numbered 0 to 7, and slice 2 is the whole disk.
  5. Disk-based examples are UFS and ext4, the network-based example is NFS, and virtual examples are /proc and tmpfs.
  6. VFS gives one system-call interface over all file system types, using vnodes in Solaris.
  7. UFS layout is boot block, super block, then cylinder groups with inodes and data.
  8. UFS block size is 8 KB with 1 KB fragments.
  9. The boot block is 8 KB and the super block starts at sector 16.
  10. A UFS inode is 128 bytes with 12 direct, and single, double and triple indirect pointers.
  11. tunefs and tune2fs tune, and fsck repairs with lost+found.

Memory hooks

  • Geometry is CHS: Cylinder, Head, Sector.
  • UFS order is B-S-C: Boot, Super, Cylinder groups.
  • Inode pointers are 12 direct then single, double, triple, growing like 1, 2, 3 levels.
  • fsck means "file system check", and orphaned files go to lost+found.

Coverage checklist

  • Definition of File System: definition and key points (no past questions).
  • Defining Geometry: CHS terms and capacity formula (no past questions).
  • Disk Controller: role, DMA and interfaces (no past questions).
  • Solaris File System: slices and file system groups (no past questions).
  • Disk Based File Systems: UFS, ext4, journaling (no past questions).
  • Network-Based File Systems: NFS share and mount (no past questions).
  • Virtual File systems: VFS and vnode (no past questions).
  • UFS File System: cylinder groups, block and fragment (no past questions).
  • The Boot Block: bootstrap area and MBR (no past questions).
  • The Super Block: global file system information (no past questions).
  • The Inode: contents and pointers (no past questions).
  • Tuning File System: tunefs and tune2fs (no past questions).
  • Repairing File System: fsck and lost+found (no past questions).
Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in