Showing posts with label Linux. Show all posts

Thursday, October 7, 2021

thumbnail

How to Re-name Network Interface in Linux and Configuring Network Bonding or NIC Teaming

Re-naming Network Interface and Configuring Network Bonding or NIC Teaming in CentOS 7|RedHat 7 Linux



1. Previous versions of linux will have interface name like eth0 and eth1 and CentOS 7 later versions will have enp2s0f0  like that. but if you would like to rename  then follow the below steps.

1. Edit file /etc/default/grub and add following

# GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap net.ifnames=0 biosdevnames=0 rhgb quiet"

2. Regenerate a GRUB configuration file

# grub2-mkconfig -o /boot/grub2/grub.cfg

3. Edit NAME and DEVICE parameter in ifcfg file /etc/sysconfig/network-scripts

# mv ifcfg-enp2s0f0 ifcfg-eth0 
# mv ifcfg-enp2s0f1 ifcfg-eth1
# mv ifcfg-ens1f0 ifcfg-eth2
# mv ifcfg-ens1f1 ifcfg-eth3
# mv ifcfg-ens2f0 ifcfg-eth4
# mv ifcfg-ens2f1 ifcfg-eth5

4. Edit NAME and DEVICE parameter in ficfg file

# vi ifcfg-eth0 and rename NAME and DEVICE to eth0. similarly for all ifcfg-eth*
# systemctl disable NetworkManager

5. Then reboot the server to apply the changes.

# Shutdown -r now 

Configuring Network Bonding or Teaming:

1. Edit and update each of the all physical NIC per below configuration.

# [] ifcfg-eth0 - kickstart interface

	TYPE=Ethernet
	PROXY_METHOD=none
	BROWSER_ONLY=no
	BOOTPROTO=dhcp
	DEFROUTE=yes
	IPV4_FAILURE_FATAL=no
	IPV6INIT=yes
	IPV6_AUTOCONF=yes
	IPV6_DEFROUTE=yes
	IPV6_FAILURE_FATAL=no
	IPV6_ADDR_GEN_MODE=stable-privacy
	NAME=eth0
	UUID=1c126857-adca-436d-8ffe-5cf1a6497937
	DEVICE=eth0
	ONBOOT=no
	
        
  
	     [] ifcfg-bond0 - Bonging interface [Master]
	
	DEVICE=bond0
	BONDING_OPTS="mode=4 miimon=100 updelay=6000 lacp_rate1"
	BONDING_MASTER=yes
	BOOTPROTO=none
	NM_CONTROLLED=no
	IPV6INIT=no
	NAME=bond0
	ONBOOT=0
	   
	    [] ifcfg-bond0.351
	
	DEVICE=bond0.351
	BOOTPROTO=none
	IPADDR=192.168.46.131
	NETMASK=255.255.255.0
	DOMAIN="acg.com corp.acg.com"
	GATEWAY=192.168.46.1
	DNS1=192.168.24.30
	DNS2=192.168.25.30
	ONBOOT=yes
	NM_CONTROLLED=no
	IPV6INIT=no
	NAME=bond0.351
	VLAN=yes
	
	     [] ifcfg-eth1 - Slave interface
	
	TYPE=Ethernet
	IPV6INIT=NO
	NAME=eth1
	UUID=1a008bd9-f21d-42f9-905e-c5dc09f87745
	DEVICE=eth1
	ONBOOT=yes
	MASTER=bond0
	SLAVE=yes
	NM_CONTROLLED=no
	
	    [] ifcfg-eth2 - Slave interface
	
	TYPE=Ethernet
	IPV6INIT=no
	NAME=eth2
	UUID=9233e629-70a0-49cb-9f1d-b7deb39b1571
	DEVICE=eth2
	ONBOOT=yes
	MASTER=bond0
	SLAVE=yes
	NM_CONTROLLED=no
	
	    [] ifcfg-eth3 - iSCSI interface [Physical]
	
	TYPE=Ethernet
	BOOTPROTO=none
	IPV6INIT=no
	NAME=eth3
	UUID=8c233834-8d55-4071-9890-839989c15f85
	DEVICE=eth3
	ONBOOT=yes
	NM_CONTROLLED=no
	
	    [] ifcfg-eth3.705 - iSCSI interface
	
	DEVICE=eth3.705
	BOOTPROTO=none
	ONBOOT=yes
	IPADDR=172.16.5.131
	PREFIX=24
	NETWORK=172.16.5.0
	VLAN=yes
	
	
	    [] ifcfg-eth4 - iSCSI interface [Physical]
	
	TYPE=Ethernet
	BOOTPROTO=none
	IPV6INIT=no
	NAME=eth4
	UUID=9f5656af-ef5d-4073-a85f-856a3bcd1c17
	DEVICE=eth4
	ONBOOT=yes
	NM_CONTROLLED=no
	
	    [] ifcfg-eth4.706 - iSCSI interface
	
	DEVICE=eth4.706
	BOOTPROTO=none
	ONBOOT=yes
	IPADDR=172.16.6.131
	PREFIX=24
	NETWORK=172.16.6.0
	VLAN=yes
	
	    [] ifcfg-eth5
	
	TYPE=Ethernet
	PROXY_METHOD=none
	BROWSER_ONLY=no
	BOOTPROTO=dhcp
	DEFROUTE=yes
	IPV4_FAILURE_FATAL=no
	IPV6INIT=yes
	IPV6_AUTOCONF=yes
	IPV6_DEFROUTE=yes
	IPV6_FAILURE_FATAL=no
	IPV6_ADDR_GEN_MODE=stable-privacy
	NAME=eth5
	UUID=7aafaebe-dad8-4bfd-a778-f1a8e8f143b0
	DEVICE=eth5
	ONBOOT=no

2. Restart the server or network service

# systemctl restart network


thumbnail

How to Increase or Extend iSCSI Volume

Increasing or Extending iSCSI Volume on CentOS 7/RedHat 7 server. 




1. Increase the preferred storage value on the storage array. For example: on the Dell EMC, navigate to Storage -> Block -> LUNs and then increase the requires LUN size.

2. Check which multipath its using and their corresponding device like sdb, sdc etc.. on the linux server

3. Using below command you can find the multipath that has been using.

# multipath -l
dev-vm1_vws1 (3600601600ed04500bfc4f95ab84860ae) dm-3 DGC     ,VRAID           
	size=1.0T features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='1 alua' wp=rw
	`-+- policy='round-robin 0' prio=0 status=active
	  |- 1:0:0:0 sdb 8:16  active undef running
	  |- 2:0:0:0 sdc 8:32  active undef running
	  |- 3:0:0:0 sdd 8:48  active undef running
	  |- 4:0:0:0 sde 8:64  active undef running
	  |- 5:0:0:0 sdf 8:80  active undef running
	  |- 6:0:0:0 sdg 8:96  active undef running
	  |- 7:0:0:0 sdh 8:112 active undef running
  `- 8:0:0:0 sdi 8:128 active undef running

2. Rescan the device for the respective device. In the above example, it lists sdb, sdc, sdd, sde, sdf, sdg, sdh and sdi

# echo 1 > /sys/block/sdb/device/rescan 
# echo 1 > /sys/block/sdc/device/rescan 
# echo 1 > /sys/block/sdd/device/rescan 
# echo 1 > /sys/block/sde/device/rescan 
# echo 1 > /sys/block/sdf/device/rescan 
# echo 1 > /sys/block/sdg/device/rescan 
# echo 1 > /sys/block/sdh/device/rescan 
# echo 1 > /sys/block/sdi/device/rescan

3. Resize the multipath

# multipathd resize map dm-3

4. Resize the file system using xfs_growfs or resize2fs

# xfs_growfs /dev/mapper/dev-vm1_vws1 (use resize2fs for ext4 file system)

5. Then use df -h with the mount point for the extended file system to make sure it got updated.

thumbnail

How to Configure NIS client on Ubuntu_20 and Ubuntu_18

Configuring NIS Client on Ubuntu_20 and Ubuntu_18 version




1. Use the following nisclient_ubuntu20.sh script to configure the nisclient on ubuntu 20 system.

# nisclient_ubuntu20.sh
#!/bin/bash

## Install NIS and RPCbind packages
## During this step you need to enter the domain for NIS

apt-get install -y rpcbind nis

## domain can be updated under incase if you have entered wrong one during the setup /etc/defaultdomain 

## Add the following line to /etc/yp.conf

NISSERVER1="<NIS Server FQDN Name"
NISSERVER2="NIS Server2 FQDN Name"
DOMAIN="<NIS domain that has configured in your network>" echo "domain $DOMAIN server $NISSERVER1" >> /etc/yp.conf echo "domain $DOMAIN server $NISSERVER2" >> /etc/yp.conf ## Edit /etc/nsswitch.conf ## For Ubuntu 20.04 sed -i 's/systemd$/systemd nis/g;s/files$/files nis/g;s/dns$/dns nis/g' /etc/nsswitch.conf ##update NIS Domain echo "<NIS Domain>" > /etc/defaultdomain ## Restart NIS service systemctl restart rpcbind systemctl restart nis

2. Use the following nisclient.sh script to configure the nisclient on ubuntu 18 system.

# nisclient_ubuntu18.sh
#!/bin/bash

## Install NIS and RPCbind packages
## During this step you need to enter the NIS domain 

apt-get install -y rpcbind nis

## domain can be updated under /etc/defaultdomain

## Add the following line to /etc/yp.conf

NISSERVER1="<NIS Server FQDN Name"
NISSERVER2="<NIS Server2 FQDN Name"
DOMAIN="NIS Domain" echo "domain $DOMAIN server $NISSERVER1" >> /etc/yp.conf echo "domain $DOMAIN server $NISSERVER2" >> /etc/yp.conf ## Edit /etc/nsswitch.conf ## For Ubuntu 20.04 sed -i 's/systemd$/systemd nis/g;s/compat$/compat nis/g;s/dns$/dns nis/g' /etc/nsswitch.conf ##update NIS Domain echo "NIS Domain" > /etc/defaultdomain ## Restart NIS service systemctl restart rpcbind systemctl restart nis


Wednesday, October 6, 2021

thumbnail

How to start stop clearcase services

Stop and Start clearcase services



1. Use the following command to start and stop clearcase service during the server maintenance.

# /etc/rc.d/init.d/clearcase start 
# /etc/rc.d/init.d/clearcase stop

2. Use the following command to verify if the service is running

# ps -ef | grep albd

3. To verify if the clearcase installed you can refer the following path.

# /opt/ibm/RationalSDLC/clearcase/linux_x86

4. To verify if the build is running on that clearcase running build server

# ps -ef | grep -E "make|emake|emake_wrapper|build_harness"


thumbnail

Using rsync to migrate data from one storage to another storage

Migrating data from one server to another server || Migrating data from old storage to new storage



To migrate or copy the data from one server to another server we can use rsync or scp tool. for better results i would suggest to use rsync so that we can preserve the same kind of permission, symlink and everything when it copied over to the new location.

In this example, am migrating data from older VNX storage to new Unity 680F storage. so first i had created the new file system on the new storage with required size to accommodate old storage data and also enabled SMB storage to access the same share from windows side

To find out how to create file system on the Unity storage refer another link.

I have created new file system on the Unity storage and then mounted that new file system and older one in the acg-vm1 centos 7 server and from there i will be running rsync to copy the data to new file system with preserving file permissions.

1. Use the following rsync command to migrate the data. .ckpt is for the snapshot to be excluded, & sign at the end to run the job in the background and 2>&1 for sending the standard error and output to the log file

# vi home-data-sync.sh
#!/bin/bash

/usr/bin/rsync -v -v -a -P -x -H -p -E --exclude '.ckpt*' --delete-excluded --ignore-errors --delete /mnt/oldhome/* /mnt/new-home1/ > /root/oldhome/oldhome.log 2>&1 &

2. Once data copied or rsync job completed you can verify the logs if there is any error reported or you can also run echo $? to see if the error code 0 means no error


# echo $?
0

3. You can then verify the size on both old and new location if it matches to make sure all data copied

4. You can use the following command to find the usage. if you do not want to sort the size then you can remove sort -rh option. This will get the all the folders usage size under /mnt/oldhome/ directory

# cd /mnt/oldhome/
# du -h --max-depth=1 *   --exclude=terminated   | sort -rh > /root/oldhomedir_usage-10062021.txt


thumbnail

How to schedule a cron job in linux

Scheduling cron job on Linux 

First you need to create bash or shell script for the job that you want to perform and then to schedule that job in a recurring manner we will be using cron tab to schedule it based on our requirement to run it whether hourly, daily, weekly or monthly



1. Sample script for deleting the files that are 5 days old so that i can keep only 5 days backup and later data will be deleted.

# vi deletebackup.sh
#!/bin/bash
find /opt/jirabackup/export/20* -type f -mtime +5 -exec rm -rf {} \;

2. Edit the crontab to schedule this delete backup job to run every day at 3AM

# crontab -e
00 03 * * * /root/deletejirabackup.sh >> /tmp/deletejirabackup.sh.log 2>&1

3. To edit the crontab for another user, use the following command:

# crontab -u acg_user1 -e

4. Cron job time format to refer and based on this format we need create the cron job to perform our regular task

# tail /etc/crontab 

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

5. To list the scheduled cron job use the following command

# crontab -l


thumbnail

How to use find command in Linux

Using find command to find and remove the files recursively 



1. Use the following command to find *.sql file type which is more than 15 days old and then delete all of them recursively. 

# find /path/to/database_dumps/ -name "*.sql" -type f -mtime +15 -exec rm -f {} \;

2. Use the following command to find 20* file type which is more than 15 days old and then delete all of them recursively. 

# find /path/to/file/ -type f -mtime +15 -exec rm -f {} \;
# find /opt/export/20* -type f -mtime +5 -exec rm -f {} \;
# find /root/ -name "*-20211109.log" -type f -exec cp {} /root/AllRsyncLogs/ \;
# find . -type f -not -name "*.html" -exec ls -l {} \;


 

Thursday, September 30, 2021

thumbnail

How to increase GitHub Appliance storage

 Increasing storage capacity

You can increase or change the amount of storage available for Git repositories, databases, search indexes, and other persistent application data.




Warning: The process for allocating new system resources varies by virtualization platform and resource type. You should always configure the monitoring and alerting of key system resources. For more information, see "Monitoring your GitHub Enterprise Server appliance."

As more users join your GitHub Enterprise Server instance, you may need to resize your storage volume. Refer to the documentation for your virtualization platform for information on resizing storage.

 Requirements and recommendations

Note: Before resizing any storage volume, put your instance in maintenance mode. For more information, see "Enabling and scheduling maintenance mode."

 Minimum requirements

User licensesvCPUsMemoryAttached storageRoot storage
Trial, demo, or 10 light users432 GB150 GB200 GB
10 to 3,000848 GB300 GB200 GB
3,000 to 50001264 GB500 GB200 GB
5,000 to 80001696 GB750 GB200 GB
8,000 to 10,000+20160 GB1000 GB200 GB

If you plan to enable GitHub Actions for the users of your instance, review the requirements for hardware, external storage, and runners in "Getting started with GitHub Actions for GitHub Enterprise Server."

For more information about adjusting resources for an existing instance, see "Increasing storage capacity" and "Increasing CPU or memory resources."

 Increasing the data partition size

  1. Resize the existing user volume disk using your virtualization platform's tools.
  2. SSH into your GitHub Enterprise Server instance. For more information, see "Accessing the administrative shell (SSH)."
    $ ssh -p 122 admin@HOSTNAME
  3. Put the appliance in maintenance mode. For more information, see "Enabling and scheduling maintenance mode."
  4. Reboot the appliance to detect the new storage allocation:
    $ sudo reboot
  5. Run the ghe-storage-extend command to expand the /data/user filesystem:
    $ ghe-storage-extend

Increasing the root partition size using a new appliance

  1. Set up a new GitHub Enterprise Server instance with a larger root disk using the same version as your current appliance. For more information, see "Setting up a GitHub Enterprise Server instance."
  2. Shut down the current appliance:
    $ sudo poweroff
  3. Detach the data disk from the current appliance using your virtualization platform's tools.
  4. Attach the data disk to the new appliance with the larger root disk.

 Increasing the root partition size using an existing appliance

Warning: Before increasing the root partition size, you must put your instance in maintenance mode. For more information, see "Enabling and scheduling maintenance mode."

  1. Attach a new disk to your GitHub Enterprise Server appliance.

  2. Run the parted command to format the disk:

    $ sudo parted /dev/xvdg mklabel msdos
    $ sudo parted /dev/xvdg mkpart primary ext4 0% 50%
    $ sudo parted /dev/xvdg mkpart primary ext4 50% 100%
  3. Run the ghe-upgrade command to install a full, platform specific package to the newly partitioned disk. A universal hotpatch upgrade package, such as github-enterprise-2.11.9.hpkg, will not work as expected. After the ghe-upgrade command completes, application services will automatically terminate.

    $ ghe-upgrade PACKAGE-NAME.pkg -s -t /dev/xvdg1
  4. Shut down the appliance:

    $ sudo poweroff
  5. In the hypervisor, remove the old root disk and attach the new root disk at the same location as the old root disk.

  6. Start the appliance.

  7. Ensure system services are functioning correctly, then release maintenance mode. For more information, see "Enabling and scheduling maintenance mode."

thumbnail

How to login to GitHub Appliance

 For logging to GitHub appliance please follow the following steps using key pair:



1. First you need to create a keypair using "ssh-keygen" command. in this example am creating the private/public key as separate key without using existing id_rsa name.

# ssh-keygen 

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/github-test

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /root/.ssh/github-test.

Your public key has been saved in /root/.ssh/github-test.pub.

The key fingerprint is:

SHA256:G+dgUmIusjsaCQsHoo1JClafiQE10jFd4AmkKfd0hLA root@acg-vm1

The key's randomart image is:

+---[RSA 2048]----+

| o*@oo+.         |

|  =oXo+          |

|==E..*+ .        |

|O* o + o         |

|B + o o S .      |

|o+ o . o *       |

|+ .     . .      |

| ...             |

|....             |

+----[SHA256]-----+

2. github appliance uses port 122 to ssh into it. since we have created custom key pair we need to specify it when ssh into it.

# ssh -i /root/.ssh/github-test -p 122 admin@github-test

# ssh -i /root/.ssh/github-test -p 122 admin@github-test
     ___ _ _   _  _      _      ___     _                    _
    / __(_) |_| || |_  _| |__  | __|_ _| |_ ___ _ _ _ __ _ _(_)___ ___
   | (_ | |  _| __ | || | '_ \ | _|| ' \  _/ -_) '_| '_ \ '_| (_-</ -_)
    \___|_|\__|_||_|\_,_|_.__/ |___|_||_\__\___|_| | .__/_| |_/__/\___|
                                                   |_|

Administrative shell access is permitted for troubleshooting and performing
documented operations procedures only. Modifying system and application files,
running programs, or installing unsupported software packages may void your
support contract. Please contact GitHub Enterprise technical support at
https://enterprise.github.com/support if you have a question about the
activities allowed by your support contract.

INFO: Release version: 3.1.7
INFO: 4 CPUs, 31GB RAM on VMWare
INFO: License: production; Seats: 655 of 932; Will expire in 25 days.
INFO: Load average: 1.57 1.22 1.28
INFO: Usage for root disk: 30G of 98G (33%)
INFO: Usage for user data disk: 81G of 271G (32%)
INFO: TLS: enabled; Certificate will expire in 61 days.
INFO: HA: standalone
INFO: Configuration run in progress: false
Last login: Thu Sep 30 05:21:44 2021 from 10.6.46.51

3. To check the partition details and disk usage use the following command.

# lsblk
NAME                                 MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                                    8:0    0  250G  0 disk 
\u251c\u2500sda1                                 8:1    0  100G  0 part 
\u2514\u2500sda2                                 8:2    0  100G  0 part /
sdb                                    8:16   0  275G  0 disk 
\u2514\u2500ghe_storage_74ae6d58-ghe_user_data 254:0    0  275G  0 lvm  /data/user

# df -h /data/user
Filesystem                                      Size  Used Avail Use% Mounted on
/dev/mapper/ghe_storage_74ae6d58-ghe_user_data  271G   81G  177G  32% /data/user

 

 

Tuesday, September 28, 2021

thumbnail

How to extend an LVM partition in Linux

 How to extend LVM based filesystem



To increase the space for LVM partition follow the steps given below:

1. Verify availability of the new space.

# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  500G  0 disk 
\u251c\u2500sda1            8:1    0  512M  0 part /boot
\u251c\u2500sda2            8:2    0 29.5G  0 part 
\u2502 \u251c\u2500centos-root 253:0    0  799G  0 lvm  /
\u2502 \u2514\u2500centos-swap 253:1    0  512M  0 lvm  [SWAP]
\u251c\u2500sda3            8:3    0  220G  0 part 
\u2502 \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
\u2514\u2500sda4            8:4    0  250G  0 part 
  \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
sdb               8:16   0  100G  0 disk 
\u2514\u2500sdb1            8:17   0  100G  0 part 
  \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
sdc               8:32   0  200G  0 disk 
\u2514\u2500sdc1            8:33   0  200G  0 part 
  \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
sdd               8:48   0  200G  0 disk 
sr0              11:0    1 1024M  0 rom 

2. Create additional partition for the new swap partition.

# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x165e0fac.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
First sector (2048-419430399, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): 
Using default value 419430399
Partition 1 of type Linux and of size 200 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdd: 214.7 GB, 214748364800 bytes, 419430400 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
Disk label type: dos
Disk identifier: 0x165e0fac

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048   419430399   209714176   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3. Activate the new partition.

# partprobe

4. Verify the new partition is available.

# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  500G  0 disk 
\u251c\u2500sda1            8:1    0  512M  0 part /boot
\u251c\u2500sda2            8:2    0 29.5G  0 part 
\u2502 \u251c\u2500centos-root 253:0    0  799G  0 lvm  /
\u2502 \u2514\u2500centos-swap 253:1    0  512M  0 lvm  [SWAP]
\u251c\u2500sda3            8:3    0  220G  0 part 
\u2502 \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
\u2514\u2500sda4            8:4    0  250G  0 part 
  \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
sdb               8:16   0  100G  0 disk 
\u2514\u2500sdb1            8:17   0  100G  0 part 
  \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
sdc               8:32   0  200G  0 disk 
\u2514\u2500sdc1            8:33   0  200G  0 part 
  \u2514\u2500centos-root 253:0    0  799G  0 lvm  /
sdd               8:48   0  200G  0 disk 
\u2514\u2500sdd1            8:49   0  200G  0 part 
sr0              11:0    1 1024M  0 rom 

Note: a reboot may be needed if the change does not show at this point.

5. Create a new physical volume on the LUN.

# pvcreate /dev/sdd1

6. Add the new volume to the volume group for the swap volume. Our examples use centos and /dev/sdd1; replace with the volume names and devices as appropriate to your deployment.

# vgextend centos /dev/sdd1

7. Using vgdisplay command we can find out available Free PE(Physical Extents)/ Size

# vgdisplay 
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        6
  Metadata Sequence No  12
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                6
  Act PV                6
  VG Size               <999.48 GiB
  PE Size               4.00 MiB
  Total PE              255866
  Alloc PE / Size       204667 / 799.48 GiB
  Free  PE / Size       51199 / <200.00 GiB
  VG UUID               s9r38a-nQQX-eDR7-l9AW-PiTV-xW6i-o6H4rg

8. Resize the logical volume to the desired size.

# lvextend -l +51199 /dev/centos/root
  Size of logical volume centos/root changed from 798.98 GiB (204539 extents) to <998.98 GiB (255738 extents).
  Logical volume centos/root successfully resized.

9. Format the extended volume for xfs file system. use "resize2fs /dev/centos/root"

# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512    agcount=111, agsize=1900288 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=209447936, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=3711, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 209447936 to 261875712

10. Enable the logical volume.

# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  500G  0 disk 
\u251c\u2500sda1            8:1    0  512M  0 part /boot
\u251c\u2500sda2            8:2    0 29.5G  0 part 
\u2502 \u251c\u2500centos-root 253:0    0  999G  0 lvm  /
\u2502 \u2514\u2500centos-swap 253:1    0  512M  0 lvm  [SWAP]
\u251c\u2500sda3            8:3    0  220G  0 part 
\u2502 \u2514\u2500centos-root 253:0    0  999G  0 lvm  /
\u2514\u2500sda4            8:4    0  250G  0 part 
  \u2514\u2500centos-root 253:0    0  999G  0 lvm  /
sdb               8:16   0  100G  0 disk 
\u2514\u2500sdb1            8:17   0  100G  0 part 
  \u2514\u2500centos-root 253:0    0  999G  0 lvm  /
sdc               8:32   0  200G  0 disk 
\u2514\u2500sdc1            8:33   0  200G  0 part 
  \u2514\u2500centos-root 253:0    0  999G  0 lvm  /
sdd               8:48   0  200G  0 disk 
\u2514\u2500sdd1            8:49   0  200G  0 part 
  \u2514\u2500centos-root 253:0    0  999G  0 lvm  /
sr0              11:0    1 1024M  0 rom  

11. View the new size.

# df -h /
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  999G  755G  245G  76% /
Powered by Blogger.