The document discusses Linux file systems and input/output. It describes the basic structure of Linux file systems, including the root directory and common file system types like Ext4, XFS, and Btrfs. It also summarizes the different classes of devices in Linux - block devices, character devices, and network devices. Block devices provide access to storage and allow random access to fixed sized blocks. Character devices process data sequentially and include keyboards and printers. Network devices operate indirectly through sockets, protocols, and network drivers.
2. FILE SYSTEM
INTRODUCTION
Linux file system is generally a built-in layer of a Linux operating system used to
handle the data management of the storage. Ithelps to arrangethe file on the disk
storage. It manages the file name, file size, creation date, and much more
information about a file.
The Linux file systemcontains the following sections:
1. The root directory (/)
2. A specific data storageformat(EXT3, EXT4, BTRFS, XFS and so on)
3. A partition or logical volume having a particular file system.
LINUXFILESYSTEMFEATURES
Specifying paths: Linux does not use the backslash () to separate the
components; it uses forward slash (/) as an alternative. For example, as in
Windows, the data may be stored in C: My DocumentsWork, whereas, in Linux,
it would be stored in /home/ My Document/ Work.
Partition, Directories, and Drives: Linux does not usedrive letters to organize
the drive as Windows does. In Linux, we cannot tell whether we are addressing a
partition, a network device, or an "ordinary" directory and a Drive.
Case Sensitivity: Linux file system is case sensitive. It distinguishes between
lowercaseand uppercasefile names. Such as,there is a differencebetween test.txt
and Test.txt in Linux. This rule is also applied for directories and Linux commands.
3. File Extensions: In Linux, a file may have the extension '.txt,' but it is not
necessary that a file should have a file extension. While working with Shell, it
creates some problems for the beginners to differentiate between files and
directories. If weuse the graphical file manager, it symbolizes thefiles and folders.
Hidden files: Linux distinguishes between standard files and hidden files, mostly
the configuration files are hidden in Linux OS. Usually, we don't need to access or
read the hidden files. The hidden files in Linux are represented by a dot (.) before
the file name (e.g., .ignore). To access the files, we need to change the view in the
file manager or need to usea specific command in the shell.
ROOT(/) DIRECTORY
4. The / in the instruction aboverefers to the rootdirectory. The rootdirectory is the
one fromwhich all other directories branch off from. When you run tree and tell it
to start with /, you will see the whole directory tree, all directories and all the
subdirectories in the whole system.
stay in your terminal window and run tree like this
tree -L 1 /
5. TYPESOFFILESYSTEM
Ext, Ext2, Ext3 and Ext4 file system
The file systemExt stands for Extended File System. Itwas primarily developed for
MINIXOS.TheExt file systemis an older version,and is no longer used dueto some
limitations.
Ext: an old one and no longer used due to limitations.
Ext2: the firstLinux file systemthat allows managing two terabytes of data.
Ext3: developed through Ext2; it is an upgraded version of Ext2 and contains
backward compatibility. The major drawback of Ext3 is that it does not support
servers becausethis file systemdoes not supportfile recovery and disk snapshot.
6. Ext4: file systemis the faster file systemamong all the Ext file systems. Itis a very
compatible option for the SSD (solid-state drive) disks, and it is the default file
systemin Linux distribution.
JFS File System
JFS stands for Journaled File System, and it is developed by IBM for AIX Unix. It is
an alternative to the Ext file system. It can also be used in place of Ext4, where
stability is needed with few resources. Itis a handy file systemwhen CPU power is
limited.
ReiserFS File System
ReiserFS is an alternative to the Ext3 file system. Ithas improved performanceand
advanced features. In the earlier time, the ReiserFS was used as the default file
system in SUSE Linux, but later it has changed some policies, so SUSE returned to
Ext3. This file system dynamically supports the file extension, but it has some
drawbacks in performance.
XFS File System
XFS file system was considered as high-speed JFS, which is developed for parallel
I/O processing. NASA still using this file system with its high storage server (300+
Terabyte server).
Btrfs File System
Btrfs stands for the B tree file system. Itis used for fault tolerance, repair system,
fun administration, extensive storageconfiguration, and more. Itis not a good suit
for the production system.
7. Swap File System
The swap file system is used for memory paging in Linux operating systemduring
the systemhibernation. A systemthat never goes in hibernate state is required to
have swap spaceequal to its RAM size.
8. INPUT AND OUTPUT
INTRODUCTION
To the user, the I/O systemin Linux looks much like that in any UNIX system. That
is, to the extent possible, all device drivers appear as normal files. A user can open
an access channelto a device in the sameway sheopens any other file-devices can
appear as objects within the file system.
The system administrator can create special files within a file systemthat contain
references to a specific device driver, and a user opening such a file will be able to
read from and write to the device referenced. By using the normal file-protection
system, which determines who can access which file, the administrator can set
access permissions for each device.
STRUCTURE
Linux splits all devices into three classes: block devices, character devices, and
network devices.
Fig 1. Device-Driver Block Structure
9. BLOCK DEVICE
Block devices provide the main interface to all disk devices in a system
or bloc devices allow random access, read only blocks of data and fixed
sized blocks of data.
Examples: Hard Disk, Floppy Disk, C D ROM and Flash Memory.
The work of request manager in block devices and separate list of
requests kept for each block device. The request is maintaining in sorted
order of increasing starting sector number when a request is accept for
processing by a block device driver, it’s not removed from the list. It is
removed after only the input output is complete.
In the block device there are two problems that may occurs
1. STARVATION:
- may be caused by error in a scheduling of work.
2. DEADLINES:
- for read request is 0.5 sec and for writing request is 5 sec.
Block device also maintains three queues
a) Sorted queue
b) Read queue
c) Write queue
10. CHARACTER DEVICES
All character devices deal with data one character at a time and process
them sequentially or serially only.
Examples: The Keyboard, Mouse or Touchpad and Printers, Etc.,
Any character- device drivers registered to the Linux kernel must also
register a set of functional that implement the file I/O operations that
the driver can handle.
The kernel performs almost no pre-processing of a file read or write
request to the device in question and lets the device deal with request.
(printers are character devices and after the kernel sends data to the
printer, the responsibility for that data passes to the printer the kernel
cannot backup and re-examine the data).
The exception to this rule is the special subset of character device drivers
that implement terminal devices.
The kernel maintains a standard interface to these drivers by means of a
set of tty_struct structures.
Each of these structures provide buffering and flow control on the data
stream from the terminal device and feeds those data to a line discipline.
A line discipline is an interpreter for the information from the terminal
device. the most common line discipline is the tty discipline.
11. tty discipline decides which process’s data should be attached or
detached from the terminal device.
NETWORKSTRUCTUREDEVICES
These are deal differently from block and character devices
Users cannot directly transfer data to network devices; instead, they
must communicate indirectly by opening a connection to the kernel’s
networking sub-system.
Networking in Linux kernel is implemented by three layers of drivers
1. The socket interfaces
2. Protocol drivers
3. Network device drivers
The Socket Interfaces
User applications perform all networking requests through the socket
interface. It looks like BSD socket layer, so that the program designed for
BSD socket can easily run-on Linux without any source code changes. BSD
socket is sufficient to represent network addresses for networking
protocols.
Protocol Devices
12. It is the second layer of software. When data arrives to this layer, it is
expected to have been tagged with an identifier specifying which
network protocol they contain.
Functions of protocol layer
a) Rewrite packets
b) Create new packets
c) Split or reassembling packets into fragments
d) Discard data
Network-device drivers
Communication between the layers of networking stack is performed by
passing single skbuff structures.
An skbuff is a set of pointers into a single continuous area of memory,
representing a buffer inside which network packets can be constructed.
The networking code either add or trim data from the end of packet.