Posts

Showing posts with the label CentOS

How to monitor disk performance on RHEL or CentOS 7 ?

Image
How to monitor disk performance on RHEL or CentOS 7 ? iotop : Watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes or threads on the system. At least the CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_IO_ACCOUNTING, CONFIG_TASKSTATS and CONFIG_VM_EVENT_COUNTERS options need to be enabled in your Linux kernel build configuration. iotop displays columns for the I/O bandwidth read and written by each process/thread during the sampling period. It also displays the percentage of time the thread/process spent while swapping in and while waiting on I/O. For each process, its I/O priority (class/level) is shown. [root@localhost ~]# iotop Total DISK READ :       0.00 B/s | Total DISK WRITE :       0.00 B/s Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s    TID  PRIO  USER  ...

How to add more swap space by adding new swap partition in RHEL or CentOS 7 ?

How to add more swap space by adding new swap partition in RHEL or CentOS 7 What is swap? Swap space on a disk is used when the amount of physical RAM is full in the Linux system. When the system runs out of RAM, inactive pages are moved from the RAM to the swap space. Swap space can be either a dedicated swap partition or a swap file. So here we will see how you can add more swap space as a swap file. In this article we will see how we can add more swap space using a new swap partition. Steps : Let's check how much swap is available on the system currently: [root@localhost ~]# swapon --show [root@localhost ~]# free -h I have a new 10GB disk named "/dev/sdb" and i want to use it as a swap space. [root@localhost ~]# fdisk -l Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Step 1 : Create a...

How to add more swap space as a swapfile on RHEL or CentOS 7 ?

How to add more swap space as a swapfile on RHEL or CentOS 7 What is swap? Swap space on a disk is used when the amount of physical RAM is full in the Linux system. When the system runs out of RAM, inactive pages are moved from the RAM to the swap space. Swap space can be either a dedicated swap partition or a swap file. So here we will see how you can add more swap space as a swap file. In this article we will see how we can add more swap space using a swapfile. Steps : Let's check how much swap is available on the system currently: [root@localhost ~]# swapon --show NAME      TYPE      SIZE USED PRIO /dev/dm-1 partition 3.9G    0B   -2 [root@localhost ~]# free -h               total        used        free      shared  buff/cache   available Mem:           3.7G      ...

How to recover /boot partition on RHEL or CentOS 7?

Image
What if mistakenly you delete all the files from /boot partition or files got corrupted due to some reason ! You will see below error on the screen at the time of system boot. But there is a way to recover /boot partition files :) Follow these steps to recover /boot partition : Step 1 :  Mount RHEL or CentOS 7 ISO image on your physical server and boot from it. In case you are using HPE Prolient server you can mount this ISO image on iLO, if this is virtual environment then mount it accordingly and reboot server or VM from ISO. Once rebooted you will see below options: Step 2 :  Scroll down and select "Troubleshooting" option from menu and PRESS "Enter" Step 3 :  Select "Rescue a CentOS system" and press ENTER: Step 4 :  Press ENTER key again to continue: Step 5 :  To continue, Type "1" and press ENTER, this will bring you to rescue mode, chroot sysimage filesystem using below command: ...

Recover or restore initramfs file in RHEL or CentOS 7

Image
What if "initramfs" file is deleted or corrupted on your RHEL or CentOS 7 ? Lets know what is initramfs image ? The INITial RAM Disk (initrd) is an initial root file system that usually get mounted prior to when the real root file system gets available. The "initrd" image is also known as "initramfs (Initial RAM FileSystem)" from RHEL 6.x onwards. The initrd/initramfs gets bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd/initramfs as part of the two-stage boot process to load the modules to make the real file systems available and mount's the real root file system. Initrd/Initramfs image provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root filesystem and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root filesystem which was mounted from initrd/initramfs is then ...

Extending root partition size online in RHEL or CentOS 7

Why do we need to extend root partition size? There are couple of reasons that root filesystem should always be having free space, else: 1. Without free space programs and OS can crash. 2. No new services or application can be started on the server. 3. Can't write anymore data resulting DU Hence admin will be left with two options either remove unnecessary files and free up some space or extend root partition size online i.e. without impacting running application or downtime. Below detailed steps will help you to extend your root partition space online: Step 1. Check current root partition size: # df -kh Filesystem               Size  Used Avail Use% Mounted on /dev/mapper/centos-root   46G  6.1G   40G  14% / Here root partition is of "46GB". Step 2. Add a new disk and re-scan HBA's to discover it: # fdisk -l Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1...

Installing and configuring Crash utility for kernel dumps analysis on RHEL OR CentOS 7

Installing and configuring Crash utility for kernel dumps analysis on RHEL OR CentOS 7 What is Crash utility? Crash is a linux utility which analyses the core dump file created by kdump. Crash utility depends on the kdump and kexec utilities to obtain its input file. A linux kernel, when boots with the crashkernel argument, it reserves some memory space to capture kernel dump in panic conditions. In case kernel panic's, the kexec utility triggers a warm reboot into a dump kernel, where the memory contents of the panicked kernel get's backed up. Once the core dump copied to the configured location then system does cold reboot and loads up standard default kernel. Step 1. Install Crash utility and Kernel-debug package: # yum install crash OR You can download "Crash" source, compile it and install: # wget http://people.redhat.com/anderson/crash-7.2.5.tar.gz # tar -zxvf crash-7.2.5.tar.gz # cd crash-7.2.5 # make && make install ...

Compiling and installing latest kernel from source on RHEL or CentOS 7

Image
Compile and install latest kernel from source on RHEL or CentOS 7 OS ... In this blog i will show you, how you can compile and install latest kernel from source on RHEL 7 Or CentOS 7 Operating system. Check currently installed kernel version : # uname -r 3.10.0-957.el7.x86_64 As you can see current kernel version is 3.10, but i want to upgrade it to the latest stable available version, which you can find on  https://www.kernel.org/  official website. As of today current stable available version is "5.0.5" To download this "5.0.5" kernel source, you can click either the big Yellow download button or you can click on the "tarball" link as shown in above screenshot. You can also download this version from below link: https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz Step 1 : Install build tools and other mandatory dependencies which are needed to compile and install new kernel from source. Before you ins...

Recovering or restoring grub in CentOS or RHEL 7

Image
What if GRUB is corrupted on your RHEL or CentOS 7 ? GRUB corruption is a common problem in RHEL or CentOS, which could occur due these reasons: If any file is missing or deleted from "/boot/grub2/" folder e.g. "grub.cfg" Mistakenly ran "dd" utility to clear boot sector Due to bad sector or corrupted disk Bad or incompatible firmware/driver installation  e.t.c. In case GRUB is corrupted, usually after powering on your server you see below kind of shell, also known as GRUB shell: Once you get to this prompt there is a way to restore or recover GRUB so that your system can boot up properly. To recover GRUB we need to have RHEL or CentOS 7 ISO image, which we usually use for OS installation. Make sure you mount same OS version iso image which is already installed on system. Below procedure will work only on BIOS based X86 servers and virtual machines. Follow these steps to recover GRUB: Step 1 : Mount RHEL or CentOS 7 ISO image ...

Recovering root user password in CentOS or RHEL 7

Image
What if you forget root user password?  RHEL/CentOS 7 has a way to recover root user password, but this will need downtime of your linux host. To recover your root user password follow below procedure as shown in screenshots: Step 1 :   Reboot host, come to GRUB screen and select Kernel without "rescue" option: PRESS "e" Step 2 :   Scroll your cursor down till you see line starting from " linux16 ".  Come  to the end of line after " UTF-8 " give a space and write " rd.break ": PRESS "CTRL + x", this will interrupt the boot process and leave you to the shell prompt : Step 3 : Once you come to shell prompt, remount "/sysroot" with "rw" permission i.e. read/write and then chroot to "/sysroot" directory: # mount -o remount,rw /sysroot/ # chroot /sysroot/ Step 4 :   Now we can go ahead and reset "root" user password using "passwd" comm...