System Ex200

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

NODEB-ASK

Setup an ip address for node2 virtual machine:

hostname: node2.lab.example.com
Password: TombigSmall
IP: 172.25.250.11/24
GW: 172.25.250.254
DNS: 172.25.250.254

00: First crack password of node2 Machine & set it to the instruction
is above instructions:
ans: #reboot the vm. press ESC then select boot loader, press
'e' to enter grub mode.
then type: rd.break console=tty1 rw
Press Ctrl + x to start:

# chroot /sysroot/
# passwd root
give the password and re-type it.
# touch /.autorelabel
# exit
# exit to logout.

if we mount readonly then we can use this:


switch_root:/# mount -o remount,rw /sysroot/
switch_root:/# chroot /sysroot

FILE LABELING
All files, directories, devices ... have a security context/label
associated with them. These context are stored in the extended
attributes of the file system. Problems with SELinux often arise from the
file system being mislabeled. This can be caused by boot‐
ing the machine with a non SELinux kernel. If you see an error message
containing file_t, that is usually a good indicator that you
have a serious problem with file system labeling.

The best way to relabel the file system is to create the flag
file /.autorelabel and reboot. system-config-selinux, also has this
capability. The restorecon/fixfiles commands are also available for
relabeling files.

network connection:

# hostnamectl set-hostname node2.lab.example.com

# ifconfig to check your physical or virtual interface


name: here is: enp1s0
# nmcli connection show
# nmcli connection add con-name lan1 ifname enp2s0 type
ethernet ipv4.method manual ipv4.addresses 172.25.250.11/24 ipv4.gateway
172.25.250.254 ipv4.dns 172.25.250.254 autoconnect yes
# nmcli connection up lan1

or, we can create a new config file or modify existing


config file
# vim /etc/sysconfig/network-scripts/ifcfg-lan1
01: SElinux Must be Running in Enable.

ans: # getenforce
# setenforce 1 or # setenforce 0 to change the selinux policy on
runtime. so you should change the config file.

# vim /etc/selinux/config
selinux=enforcing
To change the sestatus from config file then reboot your system.

02: Yum repository configuration on node1 machine:


◾Packages are available at: url1=
http://content.example.com/rhel8.0/x86_64/dvd/AppStream/
◾Packages are available at: url2=
http://content.example.com/rhel8.0/x86_64/dvd/BaseOS/
ans: #vim /etc/yum.repos.d/appstream.repo

[appstream_any_name_you_can_assign_but_no_space_here]
name=any name or if specify any name in the exam

baseurl=http://content.example.com/rhel8.0/x86_64/dvd/BaseOS/
gpgcheck=0

Test:
#yum clean all
#yum repolist all

##BaseOS is same:

03: Set a recommended tuning profile for your system. (profile already
available).
ans: # rpm -qa tuned to check package is installed or not.
# yum install tuned -y
# systemctl restart tuned.service
# systemctl enable tuned.service

# tuned-adm active [to see the active profile]


# tuned-adm list [check how many profiles are available]
# tuned-adm recommend [check which profile recommend to your
system]
# tuned-adm profile virtual-guest [set the profile]

04: Create a SWAP partition of 250 megabyte & make available at next
reboot.

# fdisk /dev/vdb
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap /
Solaris'.
# lsblk
# fdisk -l
# partprobe [ to update partition table. if the partition shows #
fdisk -l comman but not # lsblk then we can use # partprobe or just reboot the
system.]
# mkswap /dev/vdb1
# blkid
/dev/vdb1: UUID="b2337e16-691e-4a2a-92d1-35d5c1be3f18"
TYPE="swap" PARTUUID="d8f3c21a-01"
# vim /etc/fstab
UUID="b2337e16-691e-4a2a-92d1-35d5c1be3f18" swap
swap defaults 0 0

# swapon -av
verification: # swapon -s # free -h

05: Create the volume group with name myvolume with 8MiB P.E. and
create the lvm name
mydatabase with the 100P.E. format this lvm with ext4 and
create a directory /database & mount this lvm permanently on /database.

ans:

# fdisk /dev/vdb
Last sector, +sectors or +size{K,M,G,T,P} (514048-10485759,
default 10485759): +850M
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
# lsblk
# fdisk -l

# pvcreate /dev/vdb2
Physical volume "/dev/vdb2" successfully created.
# pvdisplay or, # pvs

# vgcreate myvolume -s 8M /dev/vdb2


Volume group "myvolume" successfully created
# vgdisplay or, # vgs

# lvcreate -n mydatabase -l 100 myvolume


# lvdisplay or, lvs

# mkfs.ext4 /dev/myvolume/mydatabase or, # mkfs.ext4


/dev/mapper/myvolume-mydatabase
# blkid
/dev/mapper/myvolume-mydatabase: UUID="a747660c-8d14-4943-
a227-a1320a31e943" TYPE="ext4"

# vim /etc/fstab +
UUID="a747660c-8d14-4943-a227-a1320a31e943" /database
ext4 defaults 0 0

# mkdir /database
# mount -av
06: Extend or Resize the LVM partition /dev/myvolume/mydatabase into
500 MiB from the current size and mount the
LVM /dev/myvolume/mydatabase to a mount point /database.
The extended partition size must be within approximately 450MiB
to 550MiB.
ans:
# lvresize -r -L 500M /dev/myvolume/mydatabase
# df -HT

07: You have been provided with a disk drive attached to your system
/dev/vdX. Make use of it to create a VDO. VDO device name
is myvdo1 with a logical size of 100GiB & format this vdo storage
as xfs & create a mount point /vdostorage & mount it permanently.

Step 1: Install the VDO in RHEL 8:

# rpm -qa vdo kmod-kvdo


# yum install kmod-kvdo vdo
# systemctl restart vdo.service
# systemctl enable vdo.service

Step 2: Create a VDO Volume in RHEL 8:


# man vdo [to see the manual simply copy an example] # vdo create
--name=vdo0 --device=/dev/sdb1 --vdoLogicalSize=10T

# lsblk
# vdo create --name=myvdo1 --device=/dev/vdb --vdoLogicalSize=100G

>> create --This initiates the creation of the VDO volume.


>> --name=myvdo1 --This gives the volume a label known as
myvdo1.
>> --device=/dev/sdX --The device option specifies the disk on
which
the volume will be created.
>> --vdoLogicalSize=100G --This indicates the effective volume capacity
to be used by the operating system, in this
case, 100G.
# blkid
/dev/vdb: UUID="9a19fe3d-0000-442b-aea9-840be34f22bb" TYPE="vdo"
# lsblk
# fdisk /dev/mapper/myvdo1

# lsblk
# fdisk -l
# fdisk -l /dev/mapper/myvdo1
/dev/mapper/myvdo1-part1 256 26214399 26214144 100G 83
Linux

# mkfs.xfs /dev/mapper/myvdo1 -K -f
# blkid
/dev/mapper/myvdo1: UUID="5f4fbb6e-9f31-4b66-b6c3-c87df039db7f"
TYPE="xfs"
/dev/vdb: UUID="9a19fe3d-0000-442b-aea9-840be34f22bb" TYPE="vdo"

# vim /etc/fstab
UUID="5f4fbb6e-9f31-4b66-b6c3-c87df039db7f" /vdostorage xfs
defaults,x-systemd.requires=vdo.service 0 0

# mkdir /vdostorage
# mount -av
NOTE:

##Usually, when a filesystem is created, a trim operation is carried


out on the device.
This is undesirable in the case of the VDO. When formating using the
mkfs command,
use the -K option to instruct the command not to discard blocks during
the creation to the filesystem.

# ls -l /dev/mapper/myvdo1 >> We can use the ls command as shown to


investigate file permissions &
ownership.

# vdostats --hu >> vdostats command to retrieve statistics on


the
size and the usage of the volume.

# vdostats --verbose /dev/mapper/myvdo1 | grep -B6 'saving percent'


>>The vdostats command can be used with the
--verbose flag to retrieve more detailed
information as shown.

08. Configure the rhcsa application so that when run as "pandora" it shows
below message "Labla lbal lahs ksbhs".

# vim /etc/bashrc
pandora ()
{
(echo "Labla lbal lahs ksbhs")
}

save & exit

# source /etc/bashrc
# pandora

Customize user environment:


- Create a command called starton on your server.
- It should able to execute the following command (ps -eo
pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,comm).

# vim /etc/bashrc

starton ()
{
(ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,comm)

};
# source /etc/bashrc >>reload file
# starton

You might also like