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

03 The File System

The document discusses various aspects of the Linux file system, including: 1) The six main file types: normal files, directories, device files, links, sockets, and FIFOs. 2) File naming conventions, which allow up to 255 characters including letters, numbers, and some special characters. 3) The hierarchical structure as defined by the Filesystem Hierarchy Standard (FHS), with top-level directories like /, /bin, /usr, and others below the root directory.

Uploaded by

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

03 The File System

The document discusses various aspects of the Linux file system, including: 1) The six main file types: normal files, directories, device files, links, sockets, and FIFOs. 2) File naming conventions, which allow up to 255 characters including letters, numbers, and some special characters. 3) The hierarchical structure as defined by the Filesystem Hierarchy Standard (FHS), with top-level directories like /, /bin, /usr, and others below the root directory.

Uploaded by

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

Revision no.

: PPT/2K403/02

The File System


Revision no.: PPT/2K403/02

The File System


2

• Files Types.

• File Names.

• The Hierarchical Structure of the File system.

• File system Formats.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

Files Types
3

– The file types in Linux referred to as normal files or directories


which are also known to other operating systems,Generally there
are 6 file types :
• Normal files
– It refers to files as they are also known to other operating system: a set of
contiguous data addressed with one name.
– This includes all the files normally expected under this term(ASCII
texts,executable programs, graphics files, etc).

• Directories
– Are special files containing information about other files, like a catalog.
– In particular,they contain two entries with which the structure of the
hierarchical file system is implemented.
– One of these entries(‘.’) points to the directory itself.
– The other entry (‘..’)points to the entry one level higher in the hierarchy.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File Types (contd.)


4

• Device Files
– Each piece of Hardware in a linux system is represented by device file.
– They represent links between the hardware components or the device
drivers in the kernel and the applications.
• Links
– Links are references to files located at other points in the file system.
– Changes only need to be made to the original file
• Sockets
– Sockets refer to special files with which data exchange between two locally
running processes can be implemented via the file system.
• FIFOs
– FIFO(first in first out) or named pipe is a term used for files to exchange
data between processes.
– However, they can only exchange data in one direction.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File Names
5

– A maximum of 255 characters may be used for a name.


– The name may consist of all letters of the alphabet as well as the
digits 0 to 9.
– Distinction is made between uppercase and lowercase.
– Whole series f special characters may be used.
– File names beginning with a dot (‘.’) are hidden files.
– Only “/” (the directory separator) and “\0” (null byte) may not be
used.
– Generally not use localized letters, such as umlauts,or space,
because they may sometimes be difficult to enter on the
keyboard.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system


6

• FHS – Filesystem Hierarchy Standard


– The structure of the file system is described in the Filesystem
Hierarchy Standard (FHS).
– It specfies which directories must be located on first level after
the root directory and what they contain.

– The FHS defines a two-layered hierarchy :


• The directories in the top layer(under root directory “/”).
• As a second hierarchy, the directories under /usr/.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


7

var usr tmp srv sbin root proc opt media lib home etc dev boot bin

share local lib bin x11R6 kde3 floppy cdrom tux geeko sda hda

man doc lib bin share man bin lib bin mail

packages howto

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


8

• Root Directory /
– The root directory refers to the highest layer of the file system
tree.
– When the system is booted, the partition on which this directory is
located is first one mounted.
– Following directories always have to be on the same partition as
the root directory: /bin ,/dev, /etc, /lib ,&/sbin.

• Binary Directory /bin


– Important executable programs necessary for the system start
when no other filesystem are mounted.
– Includes the various shells,important commands for working with
files, and commands for system analysis and configuration.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


9

• System Administration /sbin/


– Important programs for system administration are found in this
directory.
– Programs in the directory /sbin/ may also be run by normal users.
But only to display the configured values.

• Libraries /lib/
– In this directory /lib , the libraries are located that are used by
programs in the directories /bin and /sbin .
– In addition, the kernel modules are located in the directory
/lib/modules.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


10

• Configuration Files /etc /


– In this directory and the subdirectories, system configuration
files are stored which can be read by normal users, but cannot
edit any of them.
– In the subdirectories ,there are many shell scripts.

• Device File /dev/


– Each hardware component existing in the system (hardware
partitions,CD drives,printer, mouse, etc) is represented as a file in
the directory /dev/.
– There are two kinds of device files:
• character-oriented device files(for devices working sequentially such
as printer,mouse,or tapeDrive)
• block-oriented device files (for floppy disks, hard drives etc).

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)

11

• Service programs /usr/


– The directory /usr/, represents a second hierarchical layer.
– This directory consist of all application programs, files for the
graphical interface, additional libraries, locally installed programs,
and commonly shared directories containing documentation.

• Directory of Applications /opt/


– In the directory /opt/,additional installed applications may store
their static files.
– A directory with the name of the application is generated in which
the files are then located.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


12

• Temporary Area /tmp/


– Various programs create temporary files that are stored in /tmp
until they are deleted.

• Variable Files /var/


– In this directory and subdirectories, files are located that may be
modified while the system is running.
– It consists Log files for most services.(/var/log)
– Variable libraries( e.g Database for commands locate and rpm)

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


13

• User Directories /home/


– Every user on Linux system has own area in which to create files
and remove them, called the home directory.

– Whenever user login, they login in their corresponding home


directory.All configuration files of respective user can be found
here.

– These configuration files are hidden files.All these files have


names that begin with dot.(e.g /.profile, /.bashrc)

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


14

• Directory of the Administrator /root/


– The home directory of system administrator (root) is not located
beneath /home, it lies on the same partition as the root directory /.

• Server Directories /srv/


– The directory /srv/ contains files with data of various services in
separate subdirectories.

– Apache web server are located in the directory /srv/www and the
files of FTP server are located in the directory /srv/ftp.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


15

• Boot Directory /boot/


– The Directory /boot contains static files of the boot loader (grub or
lilo) all files require for boot process.
– The backed up information for Master boot Record and system
map files are found here.
– This directory contains information about where kernel is
located o the partition and this directory also contains the kernel.

• Process Files /proc/


– This Directory contains no real files and is located only in the
main memory.
– Each process has its own directory in which files are found with
various information.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


16

• Directories for mounting other File Systems


– Different File system may be mounted to the file system at any
point ,such as other hard drive partitions, directories from other
computer via network, or removable media.

– To mount a file system, a directory must exist where you want to


mount the file system.

– This directory is referred as mount point.

– Mounting a file system is done with the command mount.

– A file system can be removed with command umount.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

The Hierarchical Structure of the File system (contd.)


17

• The standard directory /mnt/


– The standard directory for integrating files systems is /mnt.
– With the command mount, the hard drive partition /dev/hda7 is
mounted at the position /mnt.
• # mount /dev/hda7 /mnt
– To remove this partition command umount is used
• # umount /mnt

• The Directory /media


– The directory /media was created for mounting CD-Roms and
Floppy disks.
– Its configuration in the file /etc/fstab also allows normal users to
mount and umount CD-Roms and Floppy disks.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats


18

• Linux-Specific File system formats


– The Linux file system that been standard file system for long time
is version 2 of Extended file system (ext2fs or ext2).
– The latest version is ext3fs, its further developed to provide
journaling functionality.
– During installation of Suse linux Enterprise Server,YaST provides
choice of various file systems (ext2fs ,ext3fs , ReiserFs,JFS,XFS).
– Reiser file system is very different from that in ext2 and ext3 file
system.
– XFS and JFS are available, but compared to ReiserFs they are still
at stage of development.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


19

• File System Formats of other Operating Systems


– Linux supports the file system of other operating system,
including FAT and VFAT(read and write).
– NTFS can be read, but should not try to write because it may be
possible that it may be no longer accessible from windows.
– The HPFS file system format of OS/2 can be read and
written.Linux can also handle various cdrom formats (ISO 9660).

• Network File System Formats


– Linux also understands various network file system formats.
– The most important is Network File System (NFS) , using
additional services included on SUSE Linux Enterprise Server it
can also work with network file system of other O S.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


20

– These includes Server Message Block (SMB) format from


windows and Netware Core protocol (NCP) from Novell.

• Virtual Filesystem Switch (VFS)


– This is an abstract level in the kernel providing defined interfaces
on the part of the of the other processes.
– User or program does not have to take care about how file access
is implemented technically.
– The VFS forwards these requests to the corresponding driver for
file system format.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


21

Process 1 Process 2 Process 3 VFS (Virtual


Filesystem Switch)
VFS

ext2 reiser FAT JFS VFAT

• Internal Structure of Linux File System


– Each file in Linux is described by an inode(index node or
information node).
– Each of this inode has size of 128 bytes and contains all the
information about file apart from the file name.
– This includes details of owner, access permissions, the size, time
details, links to data blocks of the file, etc .
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


22

• The ext2fs File System Format

– When a file system is created it specified how many files may be


created on this file system.
– An inode must exist for each file on the partition- the number of
inodes also determines the maximum possible number of files.
– Inode is generated for 4096 bytes of capacity. Therefore each files
should be 4 Kb in size.
– If there are many files smaller than 4 Kb , more inodes are used
compare to capacity.
– Although there is still space on the partition, all the inodes are
used, so no more files can be created.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


23

– The space on a partition is divided in to blocks.


– The block size is specified when the file system is created and
cannot be changed later.
– In the ext2 file system formats, Data is stored in linear chain of
blocks of equal size.
– A specific number of blocks is grouped together in a block group
consist of 8192 blocks.
– The boot sector is located to the beginning of this chain and
contains static information about file system, including
information about where the kernel to load.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


24

– Each block group contains following components :


• Superblock
– The superblock contains following information.
» The number of free and occupied blocks and inodes.
» The number of blocks and inodes for each block.
» Information about using the time of last mount, last write access and last file
system check.
» A valid bit, which is set to 0 when the file system is mounted and set to 1 when
the file system is umount.

• Group description
– Information is stored here about where exactly other areas are
located(block bitmap , inode bitmap).

• Block bitmap
– Block bitmap stores information which blocks in this group are free or
occupied

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


25

• Inode bitmap
– It stores the information about how many inodes are free or occupied.

• Inode table
– Information about files are stored.This includes owners, access
permissions, time stamps, and links to data blocks in which data is located.

• Data blocks
– This is where actual data is stored.

– The ext2 file system format can process file names with a length of up to
255 characters.
– The maximum file size can be 2 Tb (with block size of 1024 bytes ) or 16 Tb
(with a block size of 4096 bytes ).

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

File System Formats (contd.)


26

• The ReiserFs File System Format

– This file system as only one fixed block size of 4096 bytes

– Small files or the ends of the files are stored together in the same

block.

– The inodes required are not generated when the file system is

created, but only when they are actually needed.

– Advantage of the the ReiserFs is that, access to files is quicker.

© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02

27

Design & Published by:


CMS Institute, Design & Development Centre, CMS House, Plot No. 91, Street No.7,
MIDC, Marol, Andheri (E), Mumbai –400093, Tel: 91-22-28216511, 28329198
Email: [email protected]
www.cmsinstitute.co.in
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute

You might also like