C330 Lesson 5 Slides
C330 Lesson 5 Slides
C330 Lesson 5 Slides
File Description
/dev/hda The master device on the primary IDE channel.
• Information about hard disk and • It can be used as a storage volume on all
partition table is stored in MBR, which x64-based platforms
is the first sector of the hard disk.
• It uses Unified Extensible Firmware
• Typically, the /boot partition which Interface (UEFI) and GPT is the standard
contains the Linux Kernel is in a for laying out partition tables on physical
primary partition. disks
• Uses 32-bits for storing logical block • Uses 64-bits for storing logical block
addresses addresses
https://en.wikipedia.org/wiki/Master_boot_record https://en.wikipedia.org/wiki/GUID_Partition_Table
Official (Closed) \ Sensitive Normal
• Limitations of MBR
• the maximum number of
partitions is four
• Disk partitions are
limited to 2TB
Extended Partitions
⚫ An extended partition is a partition that can be divided into logical drives
⚫ Partitions created within extended partitions are called logical partitions
⚫ Extended partitions are not formatted with file systems, but logical
partitions are formatted with file systems
Official (Closed) \ Sensitive Normal
OS File Systems
Extents File System (XFS) Default file system for RHEL, highly scalable, high performance
and 64-bit journaling file system that supports very large file and
file system on a single host
Extended File System (ext4) For managing local file files. Improved read/write performance
compared to ext2 and ext3.
Extensible File Allocation Table Supported for removable media
(exFAT) (from RHEL 9 only)
Global File System 2 (GFS 2) Used in enterprise server cluster, shared disks to manage
concurrent multi-node access
SWAP Swap partitions are used to support virtual memory. In other
words, data is written to a swap partition when there is not
enough RAM to store the data your system is processing.
Official (Closed) \ Sensitive Normal
⚫ lsblk – lists information about all available or the specified block devices.
• The command df (Disk Free) is used get an overview of local and remote file system devices and
the amount of free space available
• df command file system disk space usage only on mounted file systems and file systems in RAM
• -h option to display the output in human readable format
• -H option to display size in system units to Files
Mount Points
• Mount points are used to access the file systems on a storage device.
• Each mount point will correspond to a partition and is mounted as a
directory on the file system.
• We need to assign mount points to each of the partitions to make up the
file system.
• The mount command allows the root user to manually mount a file
system
• Mount points are listed in /etc/fstab, which is a plain text
configuration file that contains information about the major file systems on
a computer
Lecturer Demonstration
Official (Closed) \ Sensitive Normal
fstab Entries
#device mount_point filesystem mount_options dump fsck
Example:
/dev/sr0 /media/cdrom iso9660 rw,noauto,user 0 0
1st column: corresponds to the physical device or partition. It can be referred either by physical device or by
UUID e.g. /dev/sda1 or UUID= 13152fae-d25a-4d78-b318-74397eb08184
2nd column: shows the mount point on which the physical device or partition is mounted
3rd column: shows the filesystem type with which each device or partition is formatted. E.g. ext2, etx3, ext4,
swap, ntfs, auto, ISO 9660, smbfs, hfs, etc.,
4th column: shows the mount options associated with the file system.
5th column: used to determine whether the dump command will back up the filesystem. It has two options:0 (do
not dump- used for most partitions) and 1(dump – used for root partitions)
6th column: It is used by fsck program to determine the order in which the computer checks the filesystem
when it boots. It has three options: 0 (do not check), 1(check first, only root partition should have this setting)
and 2 (check after root partition has been checked)
https://www.howtogeek.com/howto/38125/htg-explains-what-is-the-linux-fstab-and-how-does-it-work/
Official (Closed) \ Sensitive Normal
• There are two common ways to specify the file system on a disk
partition to the mount command:
• With the name of the device file in /dev containing the file system.
mount /dev/vdb1 /mnt/data
• With the UUID written to the file system, a universally-unique identifier.
mount UUID=“f46ccd6d-4319-42e0-8d89-9eb041bc2da0” /misc
• To get the UUID, use the below command.
[root@c330-test-03 ~]# lsblk -fp /dev/sdb
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
/dev/sdb
└─/dev/sdb1 ext4 1.0 misc f46ccd6d-4319-42e0-8d89-9eb041bc2da0
Lecturer Demonstration
Locate Files on the System
• A system administrator needs tools to search for mounted files that match
specific criteria on the file system.
• The two commands to search for files in the file-system hierarchy are locate
and find
• The locate command searches a pre-generated index for file names or file
paths and returns the results instantly. Before using locate command, it is
important to use updatedb command to force an immediate update
[root@C330-RH9-01 ~]# updatedb
[root@C330-RH9-01 ~]# locate -n 5 passwd
/etc/passwd
/etc/passwd-
/etc/pam.d/passwd
/etc/security/opasswd
/usr/bin/gpasswd
• The find command searches for files in real time by parsing the file-system
hierarchy.
[root@C330-RH9-01 ~]# find /etc/ -name pas*
/etc/pam.d/passwd
/etc/pam.d/password-auth
/etc/passwd-
/etc/passwd
/etc/authselect/password-auth
Official (Closed) \ Sensitive Normal
• What should be used to write a GPT disk label? Do not demonstrate GPT
(OR)
[root@c330-test-01 ~]# parted /dev/sdb mkpart primary ext4 2048s 128MB
Official (Closed) \ Sensitive Normal
Getting help
Official (Closed) \ Sensitive Normal
8 0 31457280 sda
8 1 614400 sda1
8 2 1048576 sda2
8 3 29792256 sda3
8 16 2097152 sdb
8 17 123904 sdb1
11 0 8378368 sr0
253 0 27668480 dm-0
253 1 2121728 dm-1
Official (Closed) \ Sensitive Normal
Lecturer Demonstration
Lecturer Demonstration
Unmounting partitions
• To unmount file systems, the umount command expects the mount point
as argument.
• Unmounting is not possible if the file system is in use
• The lsof command lists all open files and process accessing the
mounted directory
If the partition is not deleted, reboot the system and delete the partition.
Official (Closed) \ Sensitive Normal
Activity
LPP Academic Week 5 Worksheet Q7
a) Create a new ext4 partition of 256MB and mount on /mnt/<yourname>
b) Test whether you can access the mount point by creating a new file
c330_<yourname>.txt
c) Create another ext4 partitions of 512MB and mount on
/mnt/<student_id>
d) Access your mount point by copying the files /etc/passwd and
/etc/group to mount point. Verify whether the files are copied.
e) Show the output to your lecturer before unmounting and deleting
partitions.
f) Unmount the partitions.
g) Delete the partitions created.
Persistent Mounting
2
5
Official (Closed) \ Sensitive Normal
Lecturer Demonstration
7
8
6
9 10
• We need to protect the fstab (chattr +a sets append only for the file. It
turns immutable bit on so even though root is not able to delete /overwrite the file)
# chattr +a /etc/fstab
• mtab contains currently mounted media, we’ll just copy what’s needed and append it
into fstab
Activity
LPP Academic Week 5 Worksheet Q8
a) Attach a new hard disk of size 3GB
b) Create a new ext4 partition of 1GB and manually mount on /mnt/<student_name>
c) Test whether you can access the mount point by creating a new file soi_c330.txt
d) Copy all files greater than 10 MB from / to soi_c330.txt which is created in
/mnt/<student_name> (Hint: use find command). Verify whether the files are
copied to soi_c330.txt
e) Create another ext4 partition of 512MB and mount persistently on
/mnt/<student_ID> (Hint: edit or append /etc/fstab)
f) Before you proceed to next step, verify the entry created in /etc/fstab file using
UUID.
g) Access your mount point by copying the files /var/log/messages to mount point
/mnt/<student_ID>
h) Verify whether the files are copied to /mnt/<student_ID>
Replace <yourname> and <student_id> with your name and student id.
Official (Closed) \ Sensitive Normal
Mode of Quiz Impact of LOA on the date Week 6 RH124:Section 5.7:Lab: Create, View and Edit Text Files (E-Learn)
of Quiz RH124: Section 15.2: Lab: Manage Files from the Command Line (E-Learn)
RH124: Section 15.3: Lab: Manage Users and Groups, Permissions, and Processes
Practical Paper The student is eligible to RH134: Section 7.5: Lab: Manage Basic Storage
Quiz (week 7, take a make-up Week RH124: Section 15.5: Lab: Manage Networks (E-Learn)
12) 13 RH134: Section 14.2: Lab: Fix Boot Issues and Maintain Servers (E-Learn)
RH134: Section 4.7: Lab: Archive and Transfer Files
RH134: Section 14.5: Lab: Run Containers
Official (Closed) \ Sensitive Normal
b. Team submission folder in LEO 2.0 by 23:59 of your lesson day, uploaded in Power Point slides.
• Include the following in your presentation slides.
• Include the CLI or scripts the shows the creation of users/groups and files/directories. Take necessary screenshots and
include in your presentation slides.
• Partial solution to the Problem Statement and clearly indicate if any assumptions made.
• Maximum numbers of slides are 20 (not more than 2 slides per team member)
• One slide on the challenges faced.
Member Individual Contribution within
• Include one slide for member contribution. Refer to the below:
Name the team to the solution(s) for
Example:
the problem statement
Member 1 50%
Member 2 30%
Member 3 15%
Member 4 5% 49
Member 5 0%
Official (Closed) \ Sensitive Normal
“PRACTICE makes
PERFECT”