Abstract
| Goal | To access and inspect existing file systems on a Red Hat Enterprise Linux system. |
| Objectives |
|
| Sections |
|
| Lab |
|
Storage devices are represented by different device files.
After completing this section, students should be able to identify a directory in the file system hierarchy and what storage device it is stored on.
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 file system hierarchy discussed earlier assembles all the file systems into one tree of directories with a single root, the / directory. The advantage here is that the 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. Different parts of it can be formatted with different file systems or used for different purposes. For example, one partition could contain user home directories while another could contain system data and logs. If a user fills up the home directory partition with data, the system partition may still have space available. Placing data in two separate file systems on two separate partitions helps in planning data storage.
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, and so on. This name
represents the whole drive. The first primary partition on /dev/sda
is /dev/sda1, the second partition is /dev/sda2,
and so on.
A long listing of the /dev/vda device file on serverX reveals its special file type as b, which stands for block device:
[student@serverX ~]$ls -l /dev/vdabrw-rw----. 1 root disk 253, 0 Mar 13 08:00 /dev/vda
Exceptions are hard drives in virtual machines, which
typically show up as /dev/vd or <letter>/dev/xvd.
<letter>
Another way of organizing disks and partitions is with
logical volume management (LVM). With 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. Both the
volume group and the logical volume have names assigned upon creation.
For the 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.
For example, the device file representing the mylv logical
volume in the myvg volume group is
/dev/myvg/mylv.
It should be noted that LVM relies on the
Device Mapper (DM) kernel driver. The above
symbolic link /dev/myvg/mylv points to the
/dev/dm- block
device node. The assignment of the numbernumber
is sequential beginning with zero (0). There is a another symbolic link
for every logical volume in the /dev/mapper
directory with the name /dev/mapper/myvg-mylv.
Access to the logical volume can generally use either of the
consistent and reliable symbolic link names, since the
/dev/dm- name can
vary with each boot.
number
To get an overview about the file system mount points and the amount of free space available, run the df command. When the df command is run without arguments, it will report total disk space, used disk space, and free disk space on all mounted regular file systems. It will report on both local and remote systems and the percentage of the total disk space that is being used.
Display the file systems and mount points on the serverX machine.
[student@serverX ~]$dfFilesystem 1K-blocks Used Available Use% Mounted on /dev/vda1 6240256 4003760 2236496 65% / devtmpfs 950536 0 950536 0% /dev tmpfs 959268 80 959188 1% /dev/shm tmpfs 959268 2156 957112 1% /run tmpfs 959268 0 959268 0% /sys/fs/cgroup
The partitioning on the serverX machine shows one real file system, which is mounted on /. This is common for virtual machines. The tmpfs and devtmpfs devices are file systems in system memory. All files written into tmpfs or devtmpfs disappear after system reboot.
To improve readability of the output sizes, there are two different
human-readable options: -h or
-H. The difference between these two options is that
-h will report in KiB (210),
MiB (220), or GiB
(230), while the -H
option will report in SI units: KB (103), MB
(106), GB (109),
etc. Hard drive manufacturers usually use SI units when advertising
their products.
Show a report on the file systems on the serverX machine with all units converted to human-readable format:
[student@serverX ~]$df -hFilesystem Size Used Avail Use% Mounted on /dev/vda1 6.0G 3.9G 2.2G 65% / devtmpfs 929M 0 929M 0% /dev tmpfs 937M 80K 937M 1% /dev/shm tmpfs 937M 2.2M 935M 1% /run tmpfs 937M 0 937M 0% /sys/fs/cgroup
For more detailed information about the space used by a certain directory tree, there is the du command. The du command has -h and -H options to convert the output to human-readable format. The du command shows the size of all files in the current directory tree recursively.
Show a disk usage report for the /root directory on serverX:
[root@serverX ~]#du /root4 /root/.ssh 4 /root/.cache/dconf 4 /root/.cache 4 /root/.dbus/session-bus 4 /root/.dbus 0 /root/.config/ibus/bus 0 /root/.config/ibus 0 /root/.config 14024 /root
Show a disk usage report in human-readable format for the /var/log directory on serverX:
[root@serverX ~]#du -h /var/log... 4.9M /var/log/sa 68K /var/log/prelink 0 /var/log/qemu-ga 14M /var/log
df(1) and du(1) man pages