3. IDENTIFYING
FILE
SYSTEMS
AND DEVICES
Files on a
Linux
server
are
accessed
through
the file-
system
hierarchy
A single inverted
tree of directories.
Assembled from file
systems provided by
the storage devices
on your system.
Each file system is a
storage device that
has been formatted
to store files.
5. The hierarchy presents a collection of
file systems on separate storage
devices as if it were one set of files
on one giant storage device that you
can navigate.
Most of the time, you
don’t need to know
which storage device a
particular file is on,
you just need to know
the directory that file
is in.
You might need to
determine how full a
storage device is and
what directories in the
file-system hierarchy
are affected.
There might be errors
in the logs from a
storage device
Hard link between two
files.
HIERARCHY
6. FHS
The file system hierarchy assembles
all the file systems into one tree of
directories with a single root, the /
directory
8. FILE SYSTEMS AND
MOUNT POINTS
Makes the contents of a
file system available in
the file-system hierarchy
Must be mounted on an
empty directory (mount
point)
Once mounted, if you
use ls to list that
directory, you will see
the contents of the
mounted file system
Many file systems are
automatically mounted
as part of the boot
process.
Microsoft Windows
drive letters, are a
fundamentally different
concept.
It is somewhat similar to
the NTFS mounted
folders feature.
9. FILE SYSTEMS, STORAGE,
AND BLOCK DEVICES
Low-level access to storage devices in
Linux is provided by a special type of
file called a block device
Block devices must be formatted with
a file system before they can be
mounted.
Block device files are stored in the
/dev directory
Device files are created automatically
by the operating system.
In Red Hat Enterprise Linux, the first
SATA/PATA, SAS, SCSI, or USB hard
drive detected is called /dev/sda, the
second is /dev/sdb, and so on
•represent the entire hard drive
•other types of storage will have other forms
of naming
10. DISK PARTITIONS
Disk Partitions
Storage devices are divided up into
smaller chunks called partitions.
Partitions allow you to
compartmentalize a disk
Partitions can be formatted with
different file systems or used for
different purposes.
user home directories, system data,
logs. If a user fills up the home
Partitions are block devices in their
own right.
SATA-attached storage, the first
partition on the first disk is
/dev/sda1.
Paravirtualized storage devices
have a similar naming system.
An NVMe-attached SSD device is
/dev/nvme0p1.e1p3
A long listing of the /dev/sda1
device file on host reveals its special
file type as b, which stands for block
device:
11. STORAGE MANAGEMENT CONCEPTS
A file system is an organized
structure of data-holding files and
directories residing on a storage
device, such as a physical disk or
partition.
The advantage of FSH existing
hierarchy can be extended at any
time by adding a new disk or
partition containing a supported file
system to add disk space anywhere
in the file system tree. The process
of adding a new file system to the
existing directory tree is called
mounting.
The directory where the new file
system is mounted is referred to as a
mount point. This is a fundamentally
different concept than that used on
a Microsoft Windows system, where
a new file system is represented by a
separate drive letter.
Hard disks and storage devices are
normally divided up into smaller
chunks called partitions. A partition
is a way to compartmentalize a disk.
Storage devices are represented by a
special file type called block device.
The block device is stored in the
/dev directory. In Red Hat Enterprise
Linux, the first SCSI, PATA/SATA, or
USB hard drive detected is /dev/sda,
the second is /dev/sdb. This name
represents the whole drive. The first
primary partition on /dev/sda is
/dev/sda1, the second partition is
/dev/sda2.
A long listing of the /dev/vda device
file on serverX reveals its special file
type as b, which stands for block
device
12. LOGICAL VOLUMES
LVM relies on the Device Mapper (DM) kernel driver.
The symbolic link /dev/myvg/mylv points
to the /dev/dm-number block device
node.
The assignment of the number is
sequential beginning with zero (0).
There is a symbolic link for every logical
volume in the /dev/mapper directory
with the name /dev/mapper/myvg-mylv.
Access to the lv can use either of the
consistent and reliable symbolic link
names
/dev/dm-number name can vary with
each boot.
Volume group and the logical volume have names assigned upon creation.
volume group, a directory with the same name as the volume group exists in the /dev directory. below that directory, a symbolic link with the same name as the logical volume has been created.
Another way of organizing disks and partitions is with logical volume management (LVM).
one or more block devices can be aggregated into a storage pool called
a volume group.
Disk space is made available with one or more logical volumes.
A logical volume is the equivalent of a partition residing on a physical
disk.
13. EXAMINING FILE
SYSTEMS
• To get an overview about the file
system mount points and the
amount of free space available, run
the df command. (Recall you saw
this command in Chapter 3.)
• When the df command is run
without arguments, it will report
total, used and free disk space on
all mounted regular file systems. It
will report on both local and remote
systems and the % of total disk
space used.
• Use df -HT
14. MOUNTING FILE SYSTEMS
MANUALLY
A file system residing on a
SATA/PATA or SCSI device
needs to be mounted
manually to access it.
mount allows the root to manually mount a file system.
First argument of mount specifies the file system to mount.
Second argument specifies the target directory where the file system is
made available.
Target directory is referred to as a mount point.
mount expects the file
system argument in one of
two different ways:
The device file of the partition holding the file system, residing in /dev.
The UUID, a universal unique identifier of the file system.
15. IDENTIFYING THE
BLOCK DEVICE
A hot-pluggable storage device, whether a
hard disk drive (HDD) or solid-state device
(SSD) in a server caddy, or a USB storage
device, might be plugged into a different port
each time they are attached to a system.
lsblk lists the details of a specified block
device or all available devices.
If you want to see the just hard drives like
/dev/sda, etc you can pipe lsblk to grep and
just search for anything that starts with “sd”
In this shot, sdb is a 2nd hard drive that has
been installed but not partitioned, formatted
or mounted yet.
16. MOUNTING BY BLOCK DEVICE NAME
To mount a file system,
the destination
directory must already
exist. The /mnt
directory exists by
default and is intended
for use as a temporary
mount point.
You can use /mnt
directory, or better yet
create a subdirectory
of /mnt to use as a
temporary mount
point, unless you have
a good reason to
mount it in a specific
location in the file-
system hierarchy.
This approach works
fine in the short run.
the order in which
the operating
system detects disks
can change
this will change the
device name
associated with that
storage device.
A better approach
would be to mount by
some characteristic
built into the file
system.
17. MOUNTING BY FILE-SYSTEM UUID
One stable identifier that is
associated with a file system is
its UUID
A very long hexadecimal
number that acts as a
universally-unique identifier
UUID is part of the file system
and remains the same as long
as the file system is not
recreated.
lsblk -fp lists the full path of
the device, along with the
UUIDs and mount points, as
well as the type of file system
in the partition.
If the file system is not
mounted, the mount point will
be blank, see how /dev/sdb
has no mount point of / or
anything else yet.
18. AUTOMATIC
MOUNTING
OF
REMOVABLE
STORAGE
DEVICES
Before removing the device, you should unmount
it manually.
If you are logged in and using the graphical
desktop environment, it will automatically mount
any removable storage media when it is inserted.
removable storage device is mounted at
/run/media/USERNAME/LABEL where USERNAME is the name of
the user logged into the graphical environment and LABEL is an
identifier, often the name given to the file system when it was
created if one is available.
19. UNMOUNTING
FILE SYSTEMS
The shutdown and reboot
procedures unmount all file
systems automatically. Any file
system data cached in memory is
flushed to the device
umount unmounts the specified file
•Unmounting is not possible if the mount
point is accessed by a process.
lsof lists all open files and the
process accessing them in the
provided directory.
20. MOUNTING AND UNMOUNTING FILE SYSTEMS
This Photo by Unknown Author is licensed under CC BY-SA-NC
21. LOCATING FILES
ON THE SYSTEM
This Photo by Unknown Author is licensed under CC BY-SA-NC
22. find performs a real-
time search as the
current user in the local
file systems to find files
that match the criteria
of the command-line
arguments.
The first argument to the find command is the directory to search. If the
directory argument is omitted, find will start the search in the current directory
and look for matches in any of the subdirectories.
•find has a huge number of options that can be provided to describe exactly what kind of file should be
found. Searches can be based on file name, file size, last modified time stamp, and other file
characteristics in any combination.
locate returns search
results based on file
name or path from the
locate database. The
database stores file
name and path
information.
When searching entries as a regular user, results are returned only for where the
user invoking the locate search has read permissions on the directory tree that
contains the matching element.
The locate database is automatically updated every day. The root user can
perform an update of the database with the updatedb command.
23. LOCATING FILES ON THE FILE SYSTEM
This Photo by Unknown Author is licensed under CC BY-SA-NC
24. • Storage devices are represented by a
special file type called block device.
• df reports total disk space, used disk
space, and free disk space on all mounted
regular file systems.
• mount allows the root user to manually
mount a file system.
• All processes need to stop accessing the
mount point in order to unsuccessfully
unmount the device.
• Removable storage devices are mounted in
the /run/media directory when using the
graphical environment.
• The find command performs a real-time
search in the local file systems to find files
based on search criteria.
This Photo by Unknown Author is licensed under CC BY-SA