0% found this document useful (0 votes)
10 views

Linux File System

The document provides a comprehensive overview of the Linux file system, detailing its structure, hierarchy, and key components such as the boot block, super block, inode block, and data block. It also explains various directories in the Linux system, file types, and the process of mounting and unmounting devices. Additionally, it includes examples of commands used for managing devices and file systems in Linux.

Uploaded by

thirosul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Linux File System

The document provides a comprehensive overview of the Linux file system, detailing its structure, hierarchy, and key components such as the boot block, super block, inode block, and data block. It also explains various directories in the Linux system, file types, and the process of mounting and unmounting devices. Additionally, it includes examples of commands used for managing devices and file systems in Linux.

Uploaded by

thirosul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1

Linux File System


A Linux file system is a structured collection of files on a disk drive or a partition. A partition is a
segment of memory and contains some specific data. In our machine, there can be various partitions of the
memory. Generally, every partition contains a file system.
The general-purpose computer system needs to store data systematically so that we can easily access
the files in less time. It stores the data on hard disks (HDD) or some equivalent storage type.
You can create file an assign name using any letter, underscore & number. file name can be as long
as 255 characters", (ASCII standard 0 to 255). You can include extension as part of file name a dot
.(period)is used to isolate which the file name proper extension can be useful for category of your file.

Eg: add.c or add.doc

 Hierarchy of File system / File , Directory Structure:


In Linux file system & directory are grouped according there purpose. All directory of Linux system are
under root directory. The root directory is denoted as slash (/). The Linux directory structure is a standard
structure like tree or hierarchical type structure. The top of the tree i.e. highest level is the root directory. It
include everything i.e. hard disk partition, directory, USB drive etc. for below the root directory content
some important system directory which are common with Linux distribution.

Fig: Hierarchy of File system

1) /root (/):-
It is main directory & it is as home directory for root user.

2) /home :-
This is the directory in which every user on the system has or own personal folder for its own
personal file name. home directory provide service for other directories like FTP, HTTP etc.

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj


2
3) /bin :-
This directory is used to store the system executable files. Most user are able to access those
directory as it does not usually content system critical files.
4) /sbin:-
sbin directory role is that similar to bin directory. Different it’s only accessible by root user.

5) /boot :-
These directory contain files for booting of the OS i.e. boot strap loader etc.

6) /user:-
In this directory store user application and files. It contains all commands, libraries, games and static
files for normal operation.

User file contain below 4 files.

a) /lib:- It contain unchanging data file for program and sub program system.
b) /include:- It header file in the c programing language. It shoud be bellow /user/bin for consistency.
c) /bin:- This directory includes user executable files.
d) /sbin:- These are system binary files. They are executables utilized for system administration.

7) /dev:-
It includes the device file for all hardware devices connected to the system.

8) /etc:-
It includes the local system configuration files for the host system.

9) /mnt:-
It is a temporary mount point for basic file systems that can be used at the time when the
administrator is working or repairing a file system.

10) /media:-
A place for mounting external removable media devices like USB thumb drives that might be linked
to the host.

11) /opt:-
It contains optional files like vendor supplied application programs that must be placed here.

12) temp:-
It act as storage for temporary file program running after boot up and should use /var/temp file.

13) /var:-
Here, variable data files are saved. It can contain things such as MySQL, log files, other database
files, email inboxes, web server data files, and much more.

var file contain below 4 files.

a) /cache
b) /log
c) /spool
d) tem

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj


3
 File System parts:
Each physical drive can be divided into several partition and each partition can contain one file
system and each file system contain - Boot Block, Super Block, Inode Block, and Data Block.

1) Boot Block -
A boot block in Linux is a sector on a storage device that contains the code and data required to start the
system. It's the first program that runs when a computer is turned on.
A boot block may contain the boot track code i.e. read into the machine during the booting this
program is executed when we boot the host machine. Although only one boot block is needed to start up the
machine.

How it works:

 The boot block is usually the first sector on the storage device.
 The BIOS loads the boot block into memory when the computer starts.
 The boot block contains the bootstrap program, which initializes the system.
 The bootstrap program locates the operating system kernel on the disk and loads it into memory.
 The bootstrap program then starts the operating system.

2) Super Block -
Superblock in Linux is a data structure that stores information about a file system. It's located at the
beginning of the disk slice.
The super block is a blueprint that allows the operating system to access, navigate, and manage the
file system. It's similar to a master index in a library, providing immediate access to information about every
file and directory.

What does a superblock contain?

 File system size.


 File system state.
 Block counts.
 Inode table location.
 Disk block map.
 Maintenance information.
 Supported features.

3) Inode block-
The inode (index node) is a data structure that describes a file-system object such as a file or a
directory. An inode block in Linux is a block of data that stores the disk block locations and attributes of a
file or directory. An inode, or index node, is a data structure that stores metadata about files and directories
in a Linux system. Inodes are unique identifiers for each file or directory in a filesystem.

The inode block contains:

 Owner of the file.


 Group to which the owner belong.
 Type of file.

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj


4
 File access permission.
 Date & time of the last access.
 Number of link to the file.
 Size of file.

4) Data block -
A data block in Linux is a storage block that contains information stored in a file, directory, or
symbolic link. The size of data blocks is determined when a file system is created. a data block size is
allocated to store file or directory. If it’s free and available for the system to allocate whenever needed.

data blocks:

 Plain data blocks: Contain the data stored in a file


 Directory data blocks: Contain directory entries
 Symbolic-link data blocks: Contain the path name stored in a symbolic link

 File types:

1) Ordinary File (Regular File):


Ordinary File content user data & those data are used for further processing. All program you write
belong to this type. An ordinary file itself can be divided into two types:

A] Text file:-
A text file content only printable characters & you can view of contents and make senses out of
them. A text file content lines of character. Where every line is terminated with new line also known as line
feed.

B] Binary file:-
A binary file on the other hand content both printable and unprintable characters that cover the entire
ASCII range. Most UNIX command are binary file.

2) Device file:-
It represent physical device such as disk that read or write data block at a time.

3) Character device file:-


It represent physical device such as terminal that read or write one character at a time.

 Devices and Drives in Linux:


Drivers are used to help the hardware devices interact with the operating system. In windows, all
the devices and drivers are grouped together in a single console called device manager. In Linux, even the
hardware devices are treated like ordinary files, which makes it easier for the software to interact with the
device drivers. When a device is connected to the system, a device file is created in /dev directory.

Most Common types of devices in Linux:

1. Character devices – These devices transmit the data character by characters, like a mouse or a
keyboard.
2. Block devices – These devices transfer unit of data storage called a block, USB drives, hard drives,
and CD ROMs

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj


5
To list all the device files use the below command.
ls -l /dev

 Mounting and Umounting devices:


Mounting devices in Linux is the process of making files and folders from another location
accessible on your computer. You can mount devices like USB drives, hard drives, or network
shares. umount means to detach the device from the mount point

How to mount and umount a device in Linux:

1. Open the terminal


2. Use the lsblk or fdisk -l command to find the path to the drive
3. Create a new directory for the mount point
4. Use the mount command to attach the drive to the new directory
5. Use the umount command to detach the device from the mount point

There are two types:

mount command.
umount command.

1) mount command.

The mount command is used. mounting devices in Linux is the process of making files and folders from
another location accessible on your computer. You can mount devices like USB drives, hard drives, or
network. A device file are located in the /dev directory

Mount command take two arguments:

1) Storage device – Means which device to store access another location.


2) Mount point - Means where you want to store the file on storage device attached.

Syntax:

#mount [option] <device-location> <mount point>

Options Available in mount Command:

Options Description
l Lists all the file systems mounted yet.
h Displays options for command.
V Displays the version information.
a Mounts all devices described at /etc/fstab.
t Type of filesystem device uses.
T Describes an alternative fstab file.
r Read-only mode mounted.

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj


6
Example:

#mount /dev/sda1 /home/viraj/file

2) umount command.
To umount mounted file systems from their mount points, use the umount command. Before physically
removing a storage device or making configuration changes, it is essential to umount the file system. It is a vital
instrument for securely disconnecting network shares or USB drives, among other types of storage, from
the Linux file system.
For the purpose of preventing data loss or corruption, the command makes sure each of the current file
operations has concluded.

Syntax:

#umount [option] <mount point>

Commonly Used Options in the `umount` Command in Linux:

Options Description
-a Unmount all filesystems listed in /etc/fstab.
-c Report the number of mounts and unmounts since the last check.

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj


7
-f Force unmount, even if the device is busy.
-h Display help information.
-l Lazy unmount. Detach the filesystem now and clean up later.
-n Dry run. Show what would be done without actually unmounting.
-r Mount the filesystem read-only.
-t Specify the filesystem type to unmount.
-v Increase verbosity, showing more details during unmounting.

Example:

#umount /home/viraj/file

A] Mount and Umount USB device: (Universal Serial Bus)


User wants to access a USB (pendrive) device to your computer machine in another location. First
plug-in USB drive to your PC. After you plug in your USB device to your Linux system USB port, It will
add new block device into /dev directory. To verify it, use the lsblk or fdisk -l command. Then perform
mount and umount operation on USB device.

Example:

#mount /dev/sda1 /home/viraj/file

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj


8
Example:

#umount /home/viraj/file

B] Mount and Umount CD/DVD device: (Compact Disk / Digital Versatile Disk)
You need to use the mount command to mount a CD-ROM or DVD disk under a Linux operating
systems. First, you need to insert the CD or DVD in the server / laptop or desktop drive. It will add new
block device into /dev directory. To verify it, use the lsblk or fdisk -l command. Then perform mount and
umount operation on CD/DVD device.

Example:

#mount /dev/cddvd /home/viraj/file

Example:

#umount /home/viraj/file

C] Mount and Umount HDD partition: (Hard Disk Drive)


If you have a hard drive that contains important data or that you want to use for storage, you may
need to mount it on your Linux computer. Mounting a hard drive allows you to access its contents and use it
as if it were a part of your computer’s file system. To verify the current location of hard drive to use the
lsblk or fdisk -l command. You can see hard drive located in /dev drive i.e /dev/hda name. Then perform
mount and umount operation on HDD device.

Example:

#mount /dev/hda1 /home/viraj/file

Example:

#umount /home/viraj/file

D] Mount and Umount Floppy Disk:


User wants to access a floppy disk to your computer machine in another location. It was already
added floppy disk device into /dev/ directory i.e /dev/fd. To verify it, use the lsblk or fdisk -l command.
Then perform mount and umount operation on floppy disk device.

Example:

#mount /dev/fd0 /home/viraj/file

Example:

#umount /home/viraj/file

Mr. Yogesh D. Pakhare, M. Sc[CS] College - GFCCT, Akluj

You might also like