Extend Root LVM Configured Partition – RHEL8 / RHEL7 / CentOS 8 / CentOS 7 – No Reboot Required

In below example, I have RHEL 8 server with 100 GB OS disk, the partitions are distributed between:

  • root = 50 GB
  • home = 46.3 GB
  • swap = 2.1 GB

Filesystem: xfs, however it should work with ext partitions.

The requirement to fulfill here is to extend the root partition from 50 GB to 100 GB.

Ok, Let’s find the device where root “/” partition is:

# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  100G  0 disk
├─sda1            8:1    0  600M  0 part /boot/efi
├─sda2            8:2    0    1G  0 part /boot
└─sda3            8:3    0 98.4G  0 part
├─rhel-root   253:0    0   50G  0 lvm  /
├─rhel-swap   253:1    0  2.1G  0 lvm  [SWAP]
└─rhel-home   253:2    0 46.3G  0 lvm  /home

#==> /dev/sda is my OS disk, root partition is on /dev/sda3

Find device with LVM PV Scan

#pvs

PV         VG    Fmt  Attr PSize    PFree
/dev/sda3  rhel  lvm2 a--    98.41g    0
/dev/sdb1  vgapp lvm2 a--  <200.00g    0

My server is running on VMware vSphere environment, I have increased the disk size on VM from 100 GB to 150 GB and we will be increasing the space without rebooting/restarting the server.

VM Edit Settings > Disk Size Increase from 100 to 150 GB

Note: My server was already deployed with LVM configuration in place initially, we are just leveraging the LVM to extend the partition in this case.

Let us Rescan Extended Disk in OS to make Linux Kernel Aware, non-reboot method

# echo 1 > /sys/class/block/sda/device/rescan

Validate New Disk Size on sda

#lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  150G  0 disk
├─sda1            8:1    0  600M  0 part /boot/efi
├─sda2            8:2    0    1G  0 part /boot
└─sda3            8:3    0 98.4G  0 part
├─rhel-root   253:0    0   50G  0 lvm  /
├─rhel-swap   253:1    0  2.1G  0 lvm  [SWAP]
└─rhel-home   253:2    0 46.3G  0 lvm  /home

#==> sda size changed from 100 GB to 150 GB

Note: The partition is not automatically adjusted and needs to be resized in two steps

  1. resizing the partition
  2. make the kernel aware of the bigger partition

Now typically we use fdisk for the first step and a utility like partprobe (or a reboot) for the second step. But we now have a great software called growpart which we will use here. growpart is part of the cloud-utils-package, and should be available in your distro’s repositories. In my case it was not installed so let’s install it.

#yum install -y cloud-utils-growpart

Let’s increase the partition now with growpart.

As identified by #lsblk, our:

Device = /dev/sda ==> Disk of Root Partition

Partition = /dev/sda3 ==> Where our Root partition is.

#growpart /dev/sda 3
CHANGED: partition=3 start=3328000 old: size=206385152 end=209713152 new: size=311244767,end=314572767

#Note: there is a space in /dev/sda & 3 (3 was our partition number)

Let’s validate new partition size

#lsblk

NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   150G  0 disk
├─sda1            8:1    0   600M  0 part /boot/efi
├─sda2            8:2    0     1G  0 part /boot
└─sda3            8:3    0 148.4G  0 part
├─rhel-root   253:0    0    50G  0 lvm  /
├─rhel-swap   253:1    0   2.1G  0 lvm  [SWAP]
└─rhel-home   253:2    0  46.3G  0 lvm  /home

#==> sda3 size changed from 98.4 GB to 148.5 GB

Let’s resize Physical Volume to occupy all new space

#pvresize /dev/sda3
1 physical volume(s) resized or updated / 0 physical volume(s) not resized

Validate with LVM PV Scan

#pvs

PV         VG    Fmt  Attr PSize    PFree
/dev/sda3  rhel  lvm2 a--   148.41g 50.00g
/dev/sdb1  vgapp lvm2 a--  <200.00g     0

#==> PSize changed for /dev/sda3

Let’s check the LVM volume group status

#vgs

VG    #PV #LV #SN Attr   VSize    VFree
rhel    1   3   0 wz--n-  148.41g 50.00g
vgapp   1   1   0 wz--n- <200.00g     0

#==> We have free space of 50 GB for rhel VG i.e our root partition VG

Let’s resize Logical Volume to occupy all new space

#lvextend -r -l +100%FREE /dev/rhel/root

Size of logical volume rhel/root changed from 50.00 GiB (12800 extents) to 100.00 GiB (25600 extents).
Logical volume rhel/root successfully resized.
meta-data=/dev/mapper/rhel-root  isize=512    agcount=4, agsize=3276800 blks
=                       sectsz=512   attr=2, projid32bit=1
=                       crc=1        finobt=1, sparse=1, rmapbt=0
=                       reflink=1
data     =                       bsize=4096   blocks=13107200, imaxpct=25
=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=6400, version=2
=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 26214400

#==> example: #lvextend -r -l +100%FREE /dev/<name-of-volume-group>/root

Validate root partition should be increased to 100 GB now:

# lsblk

NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   150G  0 disk
├─sda1            8:1    0   600M  0 part /boot/efi
├─sda2            8:2    0     1G  0 part /boot
└─sda3            8:3    0 148.4G  0 part
├─rhel-root   253:0    0   100G  0 lvm  /
├─rhel-swap   253:1    0   2.1G  0 lvm  [SWAP]
└─rhel-home   253:2    0  46.3G  0 lvm  /home

#==> rhel-root increased size.

Hope you find this article useful, share the love with others if you feel worth it.

Have a nice day.

Multi-writer Shared / Clustered Disk for Windows or Oracle Cluster – vSphere / ESXi / vSAN 6.7.x

For the sake of this blog, it will be a Two VM’s Use Case, running on separate ESXi Hosts (Anti-Affinity Rule in Place)

The step of second node will apply on third / fourth node if to be introduced.

Environment

FS-VM1 – OS = Windows 2019 OS Disk 1 = 100 GB

FS-VM2 – OS = Windows 2019 OS Disk 1 = 100 GB

Created a thick provisioned eager zeroed storage policy as I was configuring on this setup on vSAN, thick disk is required for this setup to work as expected

Required disk for clustering:
Shared Disk 1 = 70 GB
Shared Disk 2 = 140 GB

Configuration Steps:

Shutdown Guest OS or Power Off FS-VM1 & FS-VM2

FS-VM1

  • Edit Settings – FS-VM1
  • Add New Devices > SCSI Controller
    • Select type: VMware Paravirtual
    • Select SCSI Bus sharing mode: Physical
  • Add New Disk
    • Size: 70 GB (1:0)
    • Type: Thick provisioned eager zeroed (using thick policy)
    • Sharing: Multi-writer
    • Disk Mode: Independent – Persistent
    • Virtual Device Node: SCSI controller 1 = SCSI(1:0)
  • Add New Disk
    • Size: 140 GB (1:1)
    • Type: Thick provisioned eager zeroed (using thick policy)
    • Sharing: Multi-writer
    • Disk Mode: Independent – Persistent
    • Virtual Device Node: SCSI controller 1 = SCSI(1:1)

Save Settings for VM by Pressing OK

FS-VM2

  • Edit Settings – FS-VM2
  • Add New Devices > SCSI Controller
    • Select type: VMware Paravirtual
    • Select SCSI Bus sharing mode: Physical
  • Add “Existing Hard Disk”
    • Find for FS-VM1 Folder in Search Browser
    • Select 70 GB .vmdk
    • Sharing: Multi-writer
    • Disk Mode: Independent – Persistent
    • Virtual Device Node: SCSI controller 1 = SCSI(1:0)
  • Add “Existing Hard Disk”
    • Find for FS-VM1 Folder in Search Browser
    • Select 140 GB .vmdk
    • Sharing: Multi-writer
    • Disk Mode: Independent – Persistent
    • Virtual Device Node: SCSI controller 1 = SCSI(1:1)

In case of vSAN it will be Storage Identifier ID with VM name and code.vmdk

Sample: [VxRail-Virtual-SAN-Datastore-8fe79a34-32432-45d4-affb-cdf6a37dd110] 62479960-6cf5-58d0-77bb-e4434bf848f0/FS-VM1-cXNb_1.vmdk

To further validate make sure it’s same path in FS-VM1 Disk File (VM Edit Settings > Hard Disk > Disk File)

Make sure configuration is identical on both VM’s such as SCSI Controller, SCSI Number, Multi-writer, Independent-Persistent etc.

Save Settings for VM by Pressing OK

Validation Steps

Power on both Virtual Machines

Login – FS-VM1 (RDP or Console Access)

  • Navigate to Disk Management
  • Validate Disks are Visible
  • Rescan Disk
  • Initialize Disk
  • Create Partition

Login – FS-VM2 – Repeat same steps

  • Navigate to Disk Management
  • Validate Disks are Visible
  • Rescan Disk
  • Initialize Disk
  • Create Partition

Servers are ready for you to configure your Clustering application

Reset root password – RHEL7/8 CentOS 7/8

https://images.unsplash.com/photo-1584433144859-1fc3ab64a957?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb

Reboot your Server, at the bootloader screen select the kernel you would like to boot it with (usually the latest one) and hit ‘e’

In the next screen, find the line that refers to the kernel

  • For RHEL/CentOS 7, the line starts with ‘linux16’.
  • For RHEL/Centos 8x, and Fedora the line starts with ‘linux’.

Add ‘rd.break‘ at the end of kernel line and press Ctrl-x

Now the server will boot into OS rescue mode

switch_root:/#.

Now, remount root partition in read/write mode

#mount -o remount rw /sysroot

Next, switch to root directory

#chroot /sysroot

At this point you can change the root password

#passwd <enter>
*<new password>*
*<repeat new password>*

Next step is for SELinux to allow new file changes – such as password reset in our case.

#touch /.autorelabel

This step will take some time to relabel, as it depends on filesystem size

Once complete, Exit Server

#exit

then, Restart server

#reboot

Validate new password has been set on Server after reboot by logging in with root account.

Scan for new SCSI drives without the need to reboot the VM – LINUX

New disk presented to the running LINUX virtual machine will not display the device into operating system unless you reboot the server.

Found another way to achieve this and thought to note it down here for my future reference.

Run the following commands:

The first command returns the SCSI host in use which in this case is host2.:

grep mpt /sys/class/scsi_host/host?/proc_name

The next command, performs a bus scan.

echo “- – -“ > /sys/class/scsi_host/host2/scan

Fdisk is used to list all the available drives on the machine.

Validate if you can view new disk:

fdisk -l

If the newly added drive is still not discovered, then unfortunately just reboot the VM.

Content Referenced article: https://www.altaro.com/vmware/managing-disk-space-linux-vm/

 

Install MHA on RHEL6 / CentOS6 for mySQL

Configure Proxy for Internet

#export http_proxy=http://proxy.xxxx.intra:00
#export https_proxy=https://proxy.xxxx.intra:00

Note: My environment is using a proxy server for Internet access, if you have direct access to internet ignore this step.

Configure RedHat subscription for yum

#subscription-manager register –username admin-example –password secret –auto-attach

Download epel-release package on machine

#wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

Note: the package will be downloaded on the path you are standing – verify from “pwd” command

Install epel-package

#yum install -y epel-release-latest-6.noarch.rpm

Install perl packages

#yum -y install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-Config-IniFiles ncftp perl-Params-Validate perl-CPAN perl-Test-Mock-LWP.noarch perl-LWP-Authen-Negotiate.noarch perl-devel

Install more perl packages

#yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

Download MHA Packages (Node & Manager)

https://code.google.com/p/mysql-master-ha/wiki/Downloads?tm=2

– MHA Manager 0.56 rpm RHEL6 – mha4mysql-manager-0.56-0.el6.noarch.rpm
– MHA Node 0.56 rpm RHEL6 – mha4mysql-node-0.56-0.el6.noarch.rpm

Once downloaded copy to server via WinSCP or SSH (somehow it is not working properly in wget for me)

Install MHA Packages

#yum -y install mha4mysql-node-0.56-0.el6.noarch.rpm

#yum -y install mha4mysql-manager-0.56-0.el6.noarch.rpm

Note: Move to directory where packages are downloaded

Add static proxy as Env Variable in CentOS / RedHat

PROXY

PROXY

My office environment like many others are providing us Internet via proxy, on Windows Machine/Servers as they are part of domain the policy is pushed and as you login with your domain account you will find it available.

However on Linux servers I always go ahead with doing the following:

export http_proxy=http://proxy.blah.blah:80

And whenever the servers were required to reboot the proxy used to wipe out.

This time I made sure to make it static and plan to push it via Ansible to all the Linux babies I love.

Logged in from root account:

vim /etc/environment
http_proxy=http://proxy.blah.blah:80

Save the file – Re-initialize the shell or logout and login back. You will not have to re-add it back again.

To verify the variable

echo $http_proxy

How to Change Font Colors in CentOS / RedHat

Red & Turquoise Terminal

Red & Turquoise Terminal

One of my monitor display was bothering my eyes, therefore I decided to change the colors being displayed on the monitor I am using, especially for the directory as it was dark blue and I had to dig myself inside the screen to actually read in that color. (my eyes are not week but I love small fonts)

I was not sure how to do it but knew it can be changed as I studied them long time ago, did some research and found out there are multiple ways to perform it.

As my environment is an Ansible lab therefore it did not click me to just change it for a specific user therefore I changed in environment base:

This is what I did: (from root user)

vim /etc/DIR_COLORS
DIR 01;96

Just above DIR value, I found out FILE parameter but it was commented, so i edited it to

vim /etc/DIR_COLORS
FILE 01;91

Now my terminal is displaying 96  = turquoise as DIR and 91  = light red as FILE and I like it !!

For you reference color codes:

0 = default colour
1 = bold
4 = underlined
5 = flashing text
7 = reverse field
31 = red
32 = green
33 = orange
34 = blue
35 = purple
36 = cyan
37 = grey
40 = black background
41 = red background
42 = green background
43 = orange background
44 = blue background
45 = purple background
46 = cyan background
47 = grey background
90 = dark grey
91 = light red
92 = light green
93 = yellow
94 = light blue
95 = light purple
96 = turquoise
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background

I did not try it but if you are interested in changing it for specific user you can try this:

cp /etc/DIR_COLORS to $HOME/.dir_colors

once copied, edit you local copy i.e .dir_colors and play with it.

Don’t forget you need to re-initialize the shell or logout and login back for changes to take affect.

Install iftop, htop and NetHogs on RHEL / CentOS 6.x x86_64 [Internet Required]

Recently I was given a task to create two CentOS 6.5 Jump Servers in the environment I am working currently.

There was a specific requirement for the following packages.

  • iftop – Network Bandwidth Monitoring
  • htop – Linux Process Monitoring
  • NetHogs – Monitor per process Network Bandwidth

We have an internal secure proxy server via which Internet was easily available for my servers. This is how I did:

Step 1 – Enable EPEL (Extra Packages for Enterprise Linux) and install rpm

cd /tmp

wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm -ivh epel-release-6-8.noarch.rpm

Step 2 – Verify EPEL Repo

yum repolist

(it should display EPEL repo in the output)

Step 3 – Install packages

yum -y install iftop

yum -y install htop

yum – y install NetHogs

Note: Just in case you face the following error:

yum error “Cannot retrieve metalink for repository: epel. Please verify its path and try again”

You will have to edit the following repo’s by commenting entries ‘mirrorlist=..’ and un-comment entries ‘baseurl=…’

  • /etc/yum.repos.d/epel.repo
  • /etc/yum.repos.d/epel-testing.repo

How to install and configure sudo in Solaris Sparc 10

Sudo Vision

Sudo Vision

First you need following packages to install

gcc-3.4.6-sol10-sparc-local.gz
libiconv-1.13.1-sol10-sparc-local.gz
libintl-3.4.0-sol10-sparc-local.gz
sudo-1.7.2p5-sol10-sparc-local.gz

Install with following command

pkgadd -d downloadPath/filename

If you are unable to find sudo package online, your Solaris Sparc Companion disk contains it

Directory in Solaric Sparc Companion disk which contain sudo is “SFWsudo”

If I assume your path to package is /cdrom/Solaris_sparc/sparc/components/SFWsudo

Install by following command

pkgadd –d /cdrom/Solaris_sparc/sparc/components/  SFWsudo

After your installation is complete

First find the path of binary and configuration files, following is my example:

grep sudoers /var/sadm/install/contents

/opt/sfw/etc/sudoers f none 0440 root root 589 50133 1104945433 SFWsudo
/opt/sfw/man/man4/sudoers.4 f none 0444 root bin 57547 31697 1104945433 SFWsudo
/usr/local/share/vim/vim73/ftplugin/sudoers.vim f none 0644 bin bin 426 36373 1285497623 SMCvim
/usr/local/share/vim/vim73/syntax/sudoers.vim f none 0644 bin bin 19276 64681 1285497623 SMCvim 

Now my I can see that my configuration file i.e. sudoers is in /opt/sfw/etc/sudoers and for sudo it is always in the same path but in /bin directory i.e. /opt/sfw/bin/sudo

Steps for sudo to work properly:

  1. Add /opt/sfw/bin  in your PATH if it is not available – check with echo $PATH
  2. Sudoers file default permission will be read only, for making changes you will need to first change the permission of sudoers file and edit your changes and revert back the permission of sudoers file to (chmod 440)
  3. Sudo binary which is in /opt/sfw/bin should have the sticky bit set permission i.e. (chmod u+s )

And you are done here, enjoy and start using sudo

CrossOver: Run MsOffice / MsOutlook On Linux And Mac

CrossOver: Run MsOffice / MsOutlook On Linux And Mac

You have to pay a cost to get a Windows Operating System license whereas for Linux it is free; switching operating system is not an easy task with reference to years of experience over a single platform. But in recent years Ubuntu Linux have developed good amount of users running their OS. Microsoft Office is a major concern in the industry for users to revamp their thinking and divert their self to adopt another Operating System, everything takes time and now we have fully functional MsOffice / MsOutlook available.

A well-known program Wine is already available but numerous bug fixes are required, when it comes to install or configure MsOffice / MsOutlook therefore CrossOver; a project with collaboration of Wine is a much more matured, because everything developed at CrossOver revolves around Wine.

The matured products are usually priced, as it is an open-source development the cost is very minimal and initially you get a 14 days trail to test your product. They usually provide a free copy in offers for a limited time so you have to be updated what’s coming next from them.

Let us install it on Ubuntu 12.04 32 bit OS to see how handy the tool is.

Double click on the downloaded .deb file and Ubuntu Software Center will take care of it. Click Install and wait for the installation to complete.

Installer

Now, CrossOver is installed and ready to install a Windows application. Find it in Applications > CrossOver > Install Windows Software

Install Windows Application

Click Install Windows Software and CrossOver Software Installer will pop up, A list of supported applications will be viewed. The applications which can be downloaded directly from web will be installed by CrossOver just by selecting Supported Applications items under the list, whereas in our case it is MsOffice and a licensed product therefore executable should be provided.

Select the Application from the Supported List.

Choose Office 2007

Now provide the executable to the installer, which by default will install in winxp bottle. Bottles are the containers of application for binaries management.

Choose Installer

Now, click Install and CrossOver will start installing your desired application.

Note: Connectivity to internet is required as several backend dependencies with reference to application are being downloaded and executed in background in order to run the application.

Installation Started

After the installer resolves all the dependencies in order to start installing the core application a pop window of executable installing will be prompt just as it happens in any Windows OS.

Office Installation

Wait till the installation finish and you are ready to use your application. Your installed application will be available in Applications > Windows Applications > Microsoft Office

Installed ScreenShot

CrossOver is a product of CodeWeavers and providing excellent services since 1996, obtaining a license will not only provide you the complete version of CrossOver but also support for your desired application and troubleshooting will be entertained on priority basis either by generating a ticket or phone call support.

Download your free trail by registering your name and email address, and install the .deb file for Ubuntu users with reference to 32 bit or 64 bit both available. For Red Hat Enterprise Linus or CentOS users .rpm is also available and similarly a respective installation file for Mac Users