TH 09 ‐ Management of Boot Volume - gautam-amitesh/OCI GitHub Wiki
Boot Volume
A Boot Volume is a storage device that contains the operating system, or image, that's used to boot a compute instance. In Linux everything is a file, directory or device files and to boot a Linux OS, boot volume should follow the same notion. Filesystem Hierarchy Standard (FHS) defines the structure of these file, directory, and device files in UNIX-like operating system (eg. Linux OS).
File System Hierarchy
Linux File System
-
/: This is the root directory which is considered as the top-level directory in the hierarchy because this is the main-entry point to the volume. Only root user have privilege to modify the content of this directory. -
/root: This is the home directory for root user which is inaccessible to non-root users. -
/home: This directory is block volume which is reserved for all non-root users where for each user there is a subdirectory inside/homedirectory which is only accessible to the root user and the owner of that subdirectory. -
/bin(shortcut for/usr/bin): This stands for binaries and this directory contains executables (command binaries) that are needed to boot, repair, and recover the OS. So, it's accessible to all users. -
/sbin(shortcut for/usr/sbin): This stands for system binaries and this directory contains executables (command binaries) which can only be used by root users to configure, maintain, and troubleshoot the OS. -
/proc: This stands for process information and unlike other directories it's not a real directory istead it's a virtual file system created inside RAM due to which it is volatile. Process are denoted by process id and Hardware and Kernel Data are text files. -
/boot: This directory is responsible for booting an OS which means it contains Linux Kernel, Initial RAM Filesystem, bootloader configuration, etc.- Linux Kernel: manages hardware and system resources
- Initial RAM Filesystem: volatile compressed root filesystem that loads actual root filesystem and after mounting it vanishes from memory
- bootloader configuration: tells the bootloader where the kernel is and what options to pass, eg. GRUB & efi
-
/dev: This directory contain device files which act as an interface between software and hardware like hard disk, printer and audio devices. Data is transmitted into hardware in two ways blocks (hard drive) and characters (mic & speaker).- blocks represented by
b
- characters represented by
c
-
/mnt: This is mount directory where system administrator manually mount temporary filesystem like physical or virtual data storage device. -
/media: This is a directory where OS dynamically mount the removal data storage device temporarily and unmount when removed. -
/etc: This directory contains system-wide editable text configuration files responsible for managing the system.
/etc/passwd: It keeps essential information(users and their default shells) about all user accounts on the system./etc/fstab: The file system table is a configuration file that guides the system how to mount and integrate a physical or virtual storage device into actual FSH at boot time./etc/hosts: This configuration file is used to map IP Addresses to hostnames which acts as a local DNS resolver and hence it's mostly used in local development.
/srv: It stands for service and this directory store site-specific data that is served by the system in simple language this directory is responsible for storing the data and files that our system (server) is actively serving to others.
- Web Servers:
/srv/www(store HTML, CSS, and PHP files) - FTP Servers:
/srv/ftp(store files available for download via File Transfer Protocol) - Version Control:
/srv/git(to host git repository) - File Sharing:
/srv/sambaor/srv/nfs(local network file sharing)
-
/sys: It stands for system and this directory is a virtual filesystem that provides an interface (information about connected hardware devices, their drivers, and their hierarchical relationships) to the Linux kernel by generating files dynamically in RAM by the kernel on system boot. -
/lib: It stands for libraries and this directory stores shared library files that are required for binary files located in/bin&/sbinto work efficiently by avoiding duplication of code. The libraries are in.soextension which is short for Shared Object. -
/tmp: It stands for temporary and this directory temporarily store files which are created by OS and running applications. On modern Linux distributions this temporarily created data is wiped out when rebooted. Often/tmpis mounted as tmpfs (Temporary File System) which means it is stored in RAM. -
/usr: Historically it stands for User (user home directories were stored) but today it stands for Universal System Resources or Unix System Resources and its primary purpose is to store read-only, sharable data, programs, and libraries for normal users and system after booting.
/usr/bin: /bin point towards this actual directory/usr/sbin: /sbin point towards this actual directory/usr/lib: /lib point towards this actual directory/usr/local: A safe playground for administrators which is essential for installing software locally (self compilled software from source code) so that any official system update never modifies these locally installed applications. It creates a separate environment for locally installed applications by mirroring the structure of rest of the system (containing/usr/local/bin,/usr/local/sbin,/usr/local/lib, etc) so that when system is updated it shouldn't touch this/usr/localdirectory.
/var: It stands for variable and this directory stores variable data which is expected to constantly change as the system runs. Directories like/usrand/binare for static and read-only files (actual software programs),/varis where those programs write their ongoing, operational data.
/var/log: stores log file generated by OS, kernel, and various applications/var/spool: stands for Simultaneous Peripheral Operations On-line which stores data that is queued up and waiting to be processes by a specific program and once the data is processed it gets deleted./var/tmp: stores temporary files that take long time to generate on the disk unlike /tmp which stores it in RAM this way the data survive reboots.
-
/opt: stands for optional which stores third-party pre-compilled softwares that doesn't fit into Linux hierarchy. It is different from/usr/localbecause it is for softwares which is self-compiled and follows Linux hierarchy(/lib, /bin, etc) while/optis pre-compiled third-party which wants to keep its all files in single directory. -
/run: It stores runtime state data for running background application's and system services in RAM and mount it as tmpfs in this directory.
Maintenance of File System
From the above File System we can only do maintenance operations in below file systems:
-
/home -
/tmp -
/var: we only do maintenance oflog&tmpfile- last 10 lines of file
/var/log/secure - last 100 lines of file
/var/log/secure
(Note : In log file system we only do maintenance of old backup files in secure and messages under /var.)