0% found this document useful (0 votes)
57 views27 pages

C330 LPP01 Lesson 5 Slides v1

Uploaded by

dharyny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views27 pages

C330 LPP01 Lesson 5 Slides v1

Uploaded by

dharyny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Official (Closed) \ Sensitive Normal

LPP01: Users/Groups &


Storage Management to
Access files/directories

Linux Administration and Virtualisation


Official (Closed) \ Sensitive Normal

LPP01 Academic Week 5


Block I
Mounting Persistent File System
Official (Closed) \ Sensitive Normal

Persistent Mounting

1. Attach a new hard disk of size 2B


2. Back-up partition table (best practice)
3. Write a disk label to identify the partition
scheme used
4. Create 2 Partitions (1 primary partitions of
size 256MB and one logical partition of
size 512MB using the newly added hard
disk.)
5. Update Kernel Lecturer Demonstration
6. Create file system
7. Persistent mounting (permanent)
Official (Closed) \ Sensitive Normal
Lecturer Demonstration
Attach New Storage Device

• Before adding a storage device,


decide what type of storage
device interface to be used.
Commonly used devices are
SCSI, SATA and NMVe

• Steps to add new hard


disk of size 2GB using 1 3
SCSI
• Refer to the video
4

2
5
Official (Closed) \ Sensitive Normal
Lecturer Demonstration

Attach New Storage Device

7
8
6

9 10

To be completed by students using local VM and show your work


to lecturer before proceeding to next step
Official (Closed) \ Sensitive Normal

Creating Primary and Logical Partitions


Watch the video to create 2 partitions of size 256MB and 512MB respectively using sdb
and sdc

First Partition - Primary (to be completed by students)


1. use sdb
2. create a primary partition of size 256MB using primary partition
3. mount point /mnt/primary_mount
4. manual mount

Second Partition - Logical (to be completed by students)


1. use sdc
2. create a logical partition of size 512MB using extended partition

Refer to the video to create two partitions


Official (Closed) \ Sensitive Normal

Protecting /etc/fstab file


Lecturer Demonstration

• 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

Refer to the video for manual and persistent mounting

Best practice is to protect /etc/fstab entries using chattr command


Official (Closed) \ Sensitive Normal

Verifying /etc/fstab entries


Lecturer Demonstration

• The/etc/fstab last line contains the entries of the first


partition mounted.

• To find the UUID for /dev/sdb1use blkid command


Official (Closed) \ Sensitive Normal

Persistently Mounting File Systems


Lecturer Demonstration
• Whenever /etc/fstab is modified, run the below command or reboot
the server for system to register the new configuration

• Use lsblk –fs command to scan the block devices connected


Official (Closed) \ Sensitive Normal

Mounting second partition persistently


Lecturer Demonstration

• Unprotect the fstab (use lsattr to see extended attributes on


files. )
# chattr -a /etc/fstab

• Edit /etc/fstab file to include the last line to mount /dev/sdc1


#
# /etc/fstab
# Created by anaconda on Thu Oct 20 06:18:51 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel_c330-root / xfs defaults 0 0
UUID=6f69b8a5-3ad8-4cb8-99eb-740f9df704ee /boot xfs defaults 0
0
UUID=847B-E2F8 /boot/efi vfat umask=0077,shortname=winnt 0 2
/dev/mapper/rhel_c330-swap none swap defaults 0 0
UUID=2022-04-19-20-42-48-00 /media/disc iso9660 ro,user,auto 0 0

/dev/sdb1 /mnt/primary_mount ext4 rw,seclabel,relatime 0 0


/dev/sdc5 /mnt/logical_mount ext4 defaults 0 0
Official (Closed) \ Sensitive Normal

Verify the mounted partitons


Lecturer Demonstration

• Use either df –h command of mount with grep commands to verify


the partitions mounted
[root@C330-RH9-01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 844M 0 844M 0% /dev
tmpfs 875M 0 875M 0% /dev/shm
tmpfs 350M 9.4M 341M 3% /run
/dev/mapper/rhel_c330-root 27G 4.0G 23G 16% /
/dev/sr0 8.0G 8.0G 0 100% /media/disc
/dev/sda2 1014M 254M 761M 25% /boot
/dev/sda1 599M 7.0M 592M 2% /boot/efi
tmpfs 175M 92K 175M 1% /run/user/0
/dev/sdb1 115M 14K 106M 1% /mnt/primary_mount
/dev/sdc5 488M 24K 452M 1% /mnt/logical_mount

[root@C330-RH9-01 ~]# mount | grep sdb /etc/fstab


/dev/sdb1 /mnt/primary_mount ext4 rw,seclabel,relatime 0 0

[root@C330-RH9-01 ~]# mount | grep sdc /etc/fstab


/dev/sdc5 /mnt/logical_mount ext4 defaults 0 0
Official (Closed) \ Sensitive Normal

Accessing the mounted directory


• We have successfully mounted both primary and logical
partitions
• Access the primary partition by copying the contents of
/var/log/messages file and access the logical partition by
creating a new file.
[root@C330-RH9-01 ~]# cd /mnt/primary_mount
[root@C330-RH9-01 primary_mount]# cp /var/log/messages .
[root@C330-RH9-01 primary_mount]# ls -l
total 448
drwx------. 2 root root 12288 Nov 5 20:49 lost+found
-rw-------. 1 root root 442435 Nov 5 21:25 messages
-rw-r--r--. 1 root root 2984 Nov 5 21:24 passwd
[root@C330-RH9-01 primary_mount]# cd
[root@C330-RH9-01 ~]# cd /mnt/logical_mount
[root@C330-RH9-01 logical_mount]# ls
lost+found
[root@C330-RH9-01 logical_mount]# touch test.sh
[root@C330-RH9-01 logical_mount]# ls -l
total 16
drwx------. 2 root root 16384 Nov 5 20:49 lost+found
-rw-r--r--. 1 root root 0 Nov 5 21:25 test.sh
Official (Closed) \ Sensitive Normal

Unmount primary and logical partitions


• The following commands will unmount both partitions

[root@C330-RH9-01 ~]# umount /dev/sdb1


[root@C330-RH9-01 ~]# umount /dev/sdc5

[root@C330-RH9-01 ~]# cd /mnt/primary_mount


[root@C330-RH9-01 primary_mount]# ls -l
total 0
[root@C330-RH9-01 primary_mount]# cd /mnt/logical_mount
[root@C330-RH9-01 logical_mount]# ls -l
total 0
[root@C330-RH9-01 logical_mount]#

• What happened to the directory contents mounted on primary and


secondary partitions?
Class Discussion
Official (Closed) \ Sensitive Normal

LPP01 Academic Week 5


Block II
Virtual Memory
Official (Closed) \ Sensitive Normal

Swap Space
• If you have too many processes running on a machine, the kernel
will try to free up RAM by writing pages to disk. This is what swap
space is for.
• It effectively increases the amount of available memory you have.
However, disk I/O is very slow compared to reading from and writing
to RAM.
• For better performance - put your swap on a fast disk with many
heads that is not busy doing other things. If you have multiple disks:
Split swap and scatter it over all your disks or even different
controllers.
• The combined system RAM plus swap space is called virtual
memory

Amount of RAM in the Recommended swap space if allowing


system Recommended swap space for hibernation
⩽ 2 GB 2 times the amount of RAM 3 times the amount of RAM
> 2 GB – 8 GB Equal to the amount of RAM 2 times the amount of RAM
> 8 GB – 64 GB At least 4 GB 1.5 times the amount of RAM
> 64 GB At least 4 GB Hibernation not recommended

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/storage_administration_guide/ch-swapspace
Official (Closed) \ Sensitive Normal

Creating a Swap Space

• Virtual Memory utilizes swap space


• Can be a file (reduced performance) or partition
• To add swap space,
1. Create swap partition or file
2. Write special signature using mkswap
3. Add appropriate entries to /etc/fstab
4. Activate swap space with swapon –a
5. Deactivate swap space with swapoff
• The more swap space over multiple disks, the better the
performance. As a rough gauge - swap file size should be max 3x the
size of RAM.

Lecturer Demonstration
Official (Closed) \ Sensitive Normal

Create Swap Space (using file)


• Create a file and this file is used as swap space
# touch /var/local/swapfile

• Write zeros to the file and grow it 256MB. (256K counts x 1K blocks)
# dd if=/dev/zero of=/var/local/swapfile bs=1K count=256K

• Verify the file creation and its size

Lecturer Demonstration
Official (Closed) \ Sensitive Normal

Write Special Signature (Format)


Write special signature using mkswap
• Write the swap signature to the file to initialize it.
#mkswap /var/local/swapfile

• Change to secure permissions and verify the permissions


#chmod 600 /var/local/swapfile

Lecturer Demonstration
Official (Closed) \ Sensitive Normal

Activating Swap Space


Before activating swap space

Activate swap space with swapon command


#swapon /var/local/swapfile Lecturer Demonstration

After activating swap space with swapon


Official (Closed) \ Sensitive Normal

To check usage of swap space


Lecturer Demonstration

• Open a few Firefox windows and note the usage of the swap
space with swapon –s
• Try this to watch the utilization of swap space
# watch swapon –s
Official (Closed) \ Sensitive Normal

Add entries to /etc/fstab file


Add an entry in /etc/fstab for making swap entries
persistent
[root@C330-RH9-01 ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Oct 20 06:18:51 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel_c330-root / xfs defaults 0 0
UUID=6f69b8a5-3ad8-4cb8-99eb-740f9df704ee /boot xfs defaults 0
0
UUID=847B-E2F8 /boot/efi vfat umask=0077,shortname=winnt 0 2
/dev/mapper/rhel_c330-swap none swap defaults 0 0
UUID=2022-04-19-20-42-48-00 /media/disc iso9660 ro,user,auto 0 0

/dev/sdb1 /mnt/primary_mount ext4 rw,seclabel,relatime 0 0


/dev/sdc5 /mnt/logical_mount ext4 defaults 0 0
/var/local/swapfile swap swap defaults 0 0
Lecturer Demonstration
Official (Closed) \ Sensitive Normal

Manage swap space

• Swap files can be re-prioritized.


#swapon –p 1 /var/local/swapfile
• UUID=af30cbb0-3866-466a-825a-58889a49ef33 swap swap defaults 0 0
• UUID=39e2667a-9458-42fe-9665-c5c854605881 swap swap pri=4 0 0
• UUID=fbd7fa60-b781-44a8-961b-37ac3ef572bf swap swap pri=10 0 0

• Try this if you are sick of re-entering the commands again and
again
# watch swapon –s
Lecturer Demonstration
Official (Closed) \ Sensitive Normal

Activating Swap Space Persistently


• To activate a swap space at every boot, add an entry to /etc/fstab

/var/local/swapfile swap swap defaults 0 0

• Whenever /etc/fstab is modified, run the below command or reboot


the server for system to register the new configuration

[root@c330-test-01 ~]#systemctl daemon-reload

Deactivate swap space with swapoff Lecturer Demonstration


Official (Closed) \ Sensitive Normal

Lesson Deliverables for LPP01


Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7

- - - Online Quiz - Individual Submission Practical


(AKS-20%) by 2359 – Red Hat Labs Quiz
(Refer to below table) (AKS -40%)
(SDL – 20%)

Team Submission by
2359 - Week 3 Team
Activity (CoL 20%)

Mode of Quiz Impact of LOA on the date Red Hat Labs for individual submissions
of Quiz Week 6 • RH124: Section 15.2: Lab: Manage Files from
Online Quiz The entire weighting of the the Command Line
(week 4) quiz will be transferred to • RH124: Section 15.3: Lab: Manage Users and
week 7 which he/she is Groups, Permissions, and Processes
required to sit for • RH124: Section 15.6: Lab: Mount File
Systems and Find Files
Practical Paper The student is eligible to • RH134: Section 14.3: Lab: Configure and
Quiz (week 7) take a make-up Manage File Systems and Storage
Official (Closed) \ Sensitive Normal

Submissions for Academic Week 6


a. Individual submission folder in LEO 2.0 by 23:59 of your lesson day, uploaded in word document
• Complete the following Red Hat labs.
➢ RH124: Section 15.2: Lab: Manage Files from the Command Line
➢ RH124: Section 15.3: Lab: Manage Users and Groups, Permissions, and Processes
➢ RH124: Section 15.6: Lab: Mount File Systems and Find Files
➢ RH134: Section 14.3: Lab: Configure and Manage File Systems and Storage
• Once you have completed, capture the screenshot of your lab completion together with your Red Hat login ID. Save
all screenshots in a word document and submit to individual submission folder in LEO 2.0 by 23:59 of your lesson
day.
• Refer to the sample screen shot submitted in week 2. Make sure that all tasks are completed in the lab and the lab
grade should be “PASS”.

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.
• 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.
• Include one slide for member contribution. Refer to the below:
Example: Member Name Individual Contribution within the team
to the solution(s) for the problem
statement
Member 1 50%
Member 2 30% 25
Member 3 15%
Official (Closed) \ Sensitive Normal

What have you learned?


• Manage users and groups permissions for accessing files & folders in
a Linux system.
• Implement storage access and management in a Linux system.
• Identify the storage devices for a file/directory
• Describe the need for virtual memory (swap space) to
supplement physical memory
• Explain the need for logical volumes and identify the Logical
Volume Management (LVM) components
• Create and manage storage devices, partitions and file
systems using CLI
• Create and manage virtual memory using swap files or
partitions using CLI
• Create and manage logical volumes containing file system
using CLI
• Demonstrate the different ways of partitioning and managing
volumes using CLI, for a given scenario
• Manage system resources to implement performance monitoring,
task scheduling, and log analysis for troubleshooting in a Linux
system.
• Manage software packages and services in a Linux system.
Official (Closed) \ Sensitive Normal

“PRACTICE makes
PERFECT”

You might also like