Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (11) AWS (5) numerology (5)
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, September 3, 2021

/ mountpoint increase in OEL (Oracle Enterprise Linux)

/ mountpoint increase in OEL (Oracle Enterprise Linux)


Below are the steps for increasing / mountpoint in OEL:

Step 1 :

Notedown the LV and VG details of / mountpoint. Here for root mountpoint we have mirror lvs LVDbSys1 and LVDbSys2. The size of LVDbSys1 is 30GB and suppose we are going to increase it by 6GB.

root@jk root]# lvs

LV                 VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

LVDbSwap1          VGJkDb -wi-ao----  24.00g

LVDbSys1           VGJkDb -wi-a-----  30.00g

LVDbSys2           VGJkDb -wi-ao----  30.00g

LVDoNotRemoveOrUse VGJkDb -wi-a-----   1.00g

[root@jk root]#

[root@jk root]# vgs

VG      #PV #LV #SN Attr   VSize    VFree

VGJkDb   2   5   0 wz--n- <834.89g <549.89g


Step 2: Here the primary root disk LV is LVDbSys2, so will increase it first by using lvextend command.

[root@jk root]# lvextend -L +6G /dev/mapper/VGJkDb-LVDbSys2

Size of logical volume VGJkDb/LVDbSys2 changed from 30.00 GiB (7680 extents) to 36.00 GiB (9216 extents).

Logical volume VGJkDb/LVDbSys2 successfully resized.

[root@jk root]#

[root@jk root]# resize2fs /dev/mapper/VGJkDb-LVDbSys2

resize2fs 1.42.9 (28-Dec-2013)

Filesystem at /dev/mapper/VGJkDb-LVDbSys2 is mounted on /; on-line resizing required

old_desc_blocks = 2, new_desc_blocks = 3

The filesystem on /dev/mapper/VGJkDb-LVDbSys2 is now 9437184 blocks long.

[root@jk root]#

[root@jk root]# df -h /

Filesystem                    Size  Used Avail Use% Mounted on

/dev/mapper/VGJkDb-LVDbSys2   36G   24G  9.8G  71% /


Step 3 : Now increase mirror lv of root ie LVDbSys1:

[root@jk root]# lvextend -L +6G /dev/mapper/VGJkDb-LVDbSys1

Size of logical volume VGJkDb/LVDbSys1 changed from 30.00 GiB (7680 extents) to 36.00 GiB (9216 extents).

Logical volume VGJkDb/LVDbSys1 successfully resized.

[root@jk root]#

[root@jk root]# resize2fs /dev/mapper/VGJkDb-LVDbSys1

resize2fs 1.42.9 (28-Dec-2013)

Please run 'e2fsck -f /dev/mapper/VGJkDb-LVDbSys1' first.


Step 4: While doing resize2fs on secondary root lv, the command is saying to run e2fsk on the secondary root lv.

[root@jk root]# e2fsck -f /dev/mapper/VGJkDb-LVDbSys1

e2fsck 1.42.9 (28-Dec-2013)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/mapper/VGJkDb-LVDbSys1: 111758/1966080 files (0.1% non-contiguous), 5772289/7864320 blocks

Step 5 : once it is successfull, run resize2fs command on LVDbSys1:

[root@jk root]# resize2fs /dev/mapper/VGJkDb-LVDbSys1

resize2fs 1.42.9 (28-Dec-2013)

Resizing the filesystem on /dev/mapper/VGJkDb-LVDbSys1 to 9437184 (4k) blocks.

The filesystem on /dev/mapper/VGJkDb-LVDbSys1 is now 9437184 blocks long.


Step 6 : Now run lvs command, will see increase LV size for LVDbSys2 and LVDbSys1:

[root@jk root]# lvs

LV                 VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

LVDbSwap1          VGJkDb -wi-ao----  24.00g

LVDbSys1           VGJkDb -wi-a-----  36.00g

LVDbSys2           VGJkDb -wi-ao----  36.00g

LVDoNotRemoveOrUse VGJkDb -wi-a-----   1.00g


Step 7 : Note down the increase size of / mount point in df command:

[root@jk root]# df -h /

Filesystem                    Size  Used Avail Use% Mounted on

/dev/mapper/VGJkDb-LVDbSys2   36G   24G  9.8G  71% /

[root@jk root]#



Regards,

Kalynajit 

Tuesday, December 22, 2020

How to check kernel version in linux

How to check kernel version in linux

There are various commands by which we can check current kernel version in linux:

1. #uname -r 

2. #cat /proc/version 

3. #dmesg |grep -i linux

4. #hostnamectl

by above commands we can get current kernel version installed on the system. 

If we want more information like installed date, release date etc.. of that kernel rpm then use below commands:

1. #rpm -qa --last |grep -i kernel  --> to get the date of kernel update

2. #cat /var/log/yum.log |grep -i kernel  ---> If the kernel update is done via yum repository then in the yum.log files will get information of when the kernel installed or kernel related packages updated.

3. #rpm -qi <kernel version name>  ---> We can get the complete kernel version name using above 1-4 commands.


Regards,

Kiraan B Jadhav

Tuesday, August 18, 2020

scriptlet failed, exit status 127 + RPM error

RPM error "scriptlet failed, exit status 127"


Sometime while patching the server, we may get message to delete some patches which create conflict.

And while deleting those conflicting rpms we get error something like this:

E
[root@cloud home]# rpm -e --nodeps ILMT-TAD4D-agent.i386-cs-cam.noarch

/var/tmp/rpm-tmp.XIuSM4[137]: /var/itlm/utilities/cit/wcitinst: not found [No such file or directory]

error: %preun(ILMT-TAD4D-agent-7.5-1.i386) scriptlet failed, exit status 127


We are erasing the rpms using -e option and not removing the rpm dependency   (Reason : The dependencies could be part of other rpms and by removing it we may encounter problem for other rpms). 
--nodeps Do not verify dependencies
  

 Solution:

 Delete the rpm using --noscripts option. The --noscripts option tells the rpm command not to run any uninstallation scripts

--noscripts  = Do not execute verification script

[root@cloud home]# rpm -e --nodeps  --noscripts ILMT-TAD4D-agent.i386

Regards,
Kalyanjit

Wednesday, March 8, 2017

Linux Query or Interview question - 6

Query 1. What is boot loader?

Ans: A boot loader is a small program which loads OS/kernel into memory (RAM). It is stored in the 1st sector of HDD i.e. MBR (Master Boot Record) partition table.
When your machine is powered-up or restarted, the BIOS perform some initial tests and then transfers control to the MBR where boot loader resides.

Note: The MBR contains boot loader information and the partition table information.

Without boot loader your OS will not be loaded in memory.

In Linux we use below two types of boot loader.
a.LILO – In older version
b. GRUB (GRand Unified Bootloader)

Grub configuration files and supported files are stored under /boot/grub/grub.conf and its symlink is /etc/grub.conf.
[root@ testmachine ~]# ls -l /etc/grub.conf
lrwxrwxrwx. 1 root root 22 Mar 26  2015 /etc/grub.conf -> ../boot/grub/grub.conf

You will see kernel information in your grub.conf file. The latest kernel in our case is “initrd /initramfs-2.6.32-573.3.1.el6.x86_64.img”
[root@ testmachine ~]# cat /etc/grub.conf|grep -i initrd
        initrd /initramfs-2.6.32-573.3.1.el6.x86_64.img
        initrd /initramfs-2.6.32-431.el6.x86_64.img


Query 2: What is load average cpu?

Load average shows the amount of traffic/load on your CPU in past 1, 5, 15 minutes. It is totally depend on how many CPU core you have in your machine.

If you are having 3 logical CPU in your machine and having load average value is less than 3 then your load average is OK means there is no processes in waiting or queued state in your CPU. 

1 CPU and 1 load average means there is 100% load on your CPU.

[root@ testmachine boot]# cat /proc/loadavg
2.54 1.73 1.53 3/368 25745

You can get CPU load average details from #top and #uptime command as well.

[root@ testmachine ~]# uptime
 14:49:34 up 455 days, 21:33,  5 users,  load average: 2.54, 1.73, 1.53

Thanks & Regards,

Kiran Jadhav 

Monday, March 6, 2017

Linux Query or Interview question - 5

Query 1. How to check run level of your system. Can we change runlevel and how?

Ans: A run level is a software program which tells your machine to run/process/allows defined group of processes. The default run level can be checked by below command:

[root@ testmachine ~]# who -r
         run-level 5  2015-12-08 16:39

Here we are having run level 5.

USe of runlevel:

#   0 - halt (Do NOT set initdefault to this); otherwise system will be in halt/power-down state permanently
#   1 - Single user mode - for administrative purpose
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this); otherwise system will keep on rebooting.

We can get default run level information from /etc/inittab as well.

[root@ testmachine ~]# grep initdefault /etc/inittab |grep -v reboot |grep -v halt
id:5:initdefault:

If we want keep default run level 3 means after reboot the system should come in run level 3 then edit /etc/inittab.

[root@ testmachine ~]# vi /etc/inittab
id:3:initdefault:

And then reboot the machine to re read the inittab file & see the changes.

[root@ testmachine ~]# reboot
Or
[root@ testmachine ~]# init 6

So if in your project, if someone ask you to reboot the machine then you can use either #reboot command or #init 6 command because

init 6 = reboot in /etc/inittab file

Or if someone asked you to halt/powerdown your machine then use below command:

[root@ testmachine ~]# init 0

Note: Please take necessary output (like #ifconfig –a, /etc/hosts etc..) before rebooting/halting machine. 

I will cover this point in next post J

Query 2. Is root account is main administrator account?

Ans: This kind of tricky question interviewer may ask you. The answer is “No”. root is not the main administrator.

The user who is having UID=0 will be your admin user.

By default, root has UID=0 which we can change and can assign different or any UID to him.

We can create user kiran with UID=0 and then user kiran will act as admin user.
[root@ testmachine ~]# grep root /etc/passwd
kiran:x:0:0:root:/kiran:/bin/bash


Thanks & Regards,
Kiran Jadhav 

Friday, March 3, 2017

Linux Query or Interview question - 4

Query 1. Why we put ‘- - -‘ in echo command which we use for scanning the lun.

Ans: We use below command to scan the new luns/disks.

[root@ testmachine~]# cd /sys/class/scsi_host/
[root@ testmachine scsi_host]# ls
host0  host1  host2
[root@ testmachine scsi_host]# echo “- - -“ > /sys/class/scsi_host/host0/scan
[root@ testmachine scsi_host]# echo “- - -“ > /sys/class/scsi_host/host1/scan
[root@ testmachine scsi_host]# echo “- - -“ > /sys/class/scsi_host/host2/scan

“- - -“ means we are echoing wild card entries of “Channel, SCSI targe ID & LUN” respectively and scanning it. So the OS will scan the device path connected to that particular host.

If the Luns are coming from HBA (fiber channel) then the echo command will slightly get differ.
[root@ testmachine~]# cd /sys/class/fc_host/
[root@ testmachine scsi_host]# ls
host0  host1 
[root@ testmachine fc_host]# echo “- - -“ > /sys/class/fc_host/host0/scan
[root@ testmachine fc_host]# echo “- - -“ > /sys/class/fc_host/host1/scan

After scanning of luns, if you still unable to see them then use below command.

[root@ testmachine fc_host]# echo 1 > /sys/class/fc_host/host/issue_lip

issue_lip refreshes the scsi bus (fiber channel interconnect).

Query 2. How to indentify CPU & core information.

1.a. Run lscpu command.
Socket =1 shows we have 1 CPU socket, nothing but 1 CPU
Core per socket = 4 shows that we are having 4 core in 1 socket.
Thread per core = 2 shows multithreading is there

CPU 8 = show logical cpu. We are having 8 logical CPU. (1*4*2 = 8)

[root@ testmachine:/root]lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                8
On-line CPU(s) list:   0-7
Thread(s) per core:    2
Core(s) per socket:    4
Socket(s):             1

1.b.To see CPU which are online in extended readable format.

[root@ testmachine:/root]lscpu -b -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE
0   0    0      0    0:0:0:0       yes
1   0    0      1    1:1:1:0       yes
2   0    0      2    2:2:2:0       yes
3   0    0      3    3:3:3:0       yes
4   0    0      0    0:0:0:0       yes
5   0    0      1    1:1:1:0       yes
6   0    0      2    2:2:2:0       yes
7   0    0      3    3:3:3:0       yes

2.In /proc/cpuinfo, the “Physical ID” shows number of CPU’s. 
In our case,
Physical id = 0 means we are having   only 1 CPU.

[root@ testmachine:/root]grep -i "physical id" /proc/cpuinfo
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 0


Thanks & Regards,
Kirann Jadhav




Thursday, March 2, 2017

Linux Query or Interview question - 3

Query 1. What is primary partitions on HDD.

We can create only 4 partition on HDD called as "Primary Partition" or "Physical Partition" & it is defined in partition table. 
There are two type of partition table.
a. MSDOS/MBR – Where limit is set as 4 for primary partitions
b. GPT – Where you can create 128 primary partitions

so the limit of creation of primary partitions is set in partition table type.
[root@testmachine ~]# parted -l /dev/sda
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start   End     Size    Type     File system  Flags
 1      1049kB  525MB   524MB   primary  ext4         boot
 2      525MB   21.5GB  20.9GB  primary               lvm
 3      21.5GB  31.1GB  9665MB  primary

In our example, we are having 3 partitions like /dev/sda1, /dev/sda2, /dev/sda3 etc.  

 [root@testmachine ~]# fdisk /dev/sda
Command (m for help): p
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           2         501      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             502       20480    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/sda3           20481       29697     9438208   83  Linux

If we want to create more than 4 partitions then we have to make 1 partition as extended out of 4 partitions. The use of extended partition is that it will create a boundary for extended and in that we can create multiple logical partitions.

Take example that our 4th partition is extended partition. Then /dev/sda4 will be used for that but it is just for name sake. It will not have data. The exact logical partition will start form /dev/sda5, /dev/sda7 etc…

If we want to create primary partition more than 4 then we have to use partition table type GPT where we can create 128 primary partitions.

We can change the partition table type from MSDOS to GPT by using “parted” command. Better to have a backup so data loss may not happen.


Query 2. Why we see HDD size less in OS.

The HDD manufacturers (like IBM, EMC, Dell, HP etc..) use the universal method of calculation . They divide the disk size by 1000.

Like 1GB= 1000MB

But in OS we divide the disk size by 1024. So the disk size is actually same but we may see less disk size when we use it in OS (Linux, windows etc..)

5GB = 5000MB (as per manufacturer)
5000MB/1024 = 4.88GB so in OS you will see disk size 4.88GB.


Thanks & Regards,
Kiran Jadhav




Wednesday, March 1, 2017

Linux Query or Interview question - 2

Query 1. How to remove junk character (^c).

If we cancel/interrupt the command by pressing ctrl+c we may sometime get junk character like (^c). To remove it you have to put:

[root@testmachine ~]# stty -ctlecho

This is applicable to that particular putty session. If we take new session we may get junk character again. So we have to make the changes persistent by adding above entry in bash profile.

 [root@testmachine ~]# vi /etc/bashrc
stty -ctlecho

Query 2. How many fields are there in /etc/fstab.

[root@testmachine ~]# vi /etc/fstab
/dev/mapper/vgroot-lvvar /var                    ext4    defaults        1 2

        1. Device driver
2    2. Mountpoint name
3    3. FS type = ext4,ext3, swap etc..
      4. describes the mount options associated with the filesystem
5    5. fsck/dump
6    6. fsck/on/off sequence

Where fsck means filesystem check. Command e2fsck is enhaced fsck and it is enhanced version of fsck. The sixth field is very important which determine whether fsck need to be run or filesystem or not.

Once server gets rebooted at the time of mounting fs, it will check which FS need fsck to do.

0 = No auto fsck.
1= It is used for / mountpoint. 1st priority. The mountpoint which are having value 1 will be grouped together and system will run fsck on those moutpoints.

2= 2nd priority for fsck.


With Regards,
Kirann Jadhav

Friday, February 24, 2017

Linux Queries - 1

Query 1 : How to remove commands history permanently.

Ans: We can see commands history by running command:

#history
When we run any commands on server then the commands history gets stored in 2 location
1. In Memory or RAM
2. In HDD under /root/.bash_history

#history -c
will clear the command history from memory & not from HDD.

So if we reboot the server then command history will get loaded again from HDD (/root/.bash_history) into the memory & we can see the commands history again.

So we have to clear it from RAM as well as from HDD. Have to clear file /root/.bash_history as well.

# > /root/.bash_history

Query 2: How to increase timeout of splash screen:

The Splash screen is the picture that you can see while Linux is booting. At the time of booting, if the timeout parameter is less then the splash screen will come and disappear immediately. To interrupt the boot process and to get the splash screen where you can see the kernel  info etc.. it is important to keep the timeout parameter slightly more.
[root@testmachine ~]# grep timeout /etc/grub.conf
timeout=5
[root@testmachine ~]# grep timeout /etc/grub.conf
timeout=1000
Machine will wait for 1000 seconds while booting. But the reboot time will increase if the timeout value is more as machine will wait more to get manual interruption. so when you want to do any activity then only try to increase the timeout parameter and bring it back to default value once you are done with activity.


Thanks,
Kiran Jadhav



Monday, December 19, 2016

rpm and yum commands are not working+ linux

At the time of patching I encountered a error and I wanted to check the version of yum on TEM server and the server which is going to patched. 

But found that neither the rpm or yum commands are working & session was getting hang.

#yum info yum or # rpm -qa |grep -i yum
session was hanging

 In such case, check whether any lock is created under  /var/lib/rpm/ & if it is there remove it because these locks are creating problem while running rpm commands.

1. # ls -lrt /var/lib/rpm/__db.*
-rw-------  1 root root   753664 Dec  9 07:05 __db.004
-rw-------  1 root root  1318912 Dec  9 07:05 __db.003
-rw-------  1 root root    24576 Dec  9 09:02 __db.001
-rw-------  1 root root   237568 Dec  9 09:05 __db.002

2. # rm /var/lib/rpm/__db.*


3. # ls -lrt /var/lib/rpm/__db.*

4. rpm commands and yum commands will run now.

Thanks,
Kiran Jadhav





Wednesday, September 14, 2016

New FS creation steps - Linux

Let’s take example that, admin wants to create a new FS with new VG.

VG name = vgbackup
LV name = lvbkp
mountpoint name = /backup
New disk added by VM team : /dev/sde

1. Scan new disk added by VM team
#fdisk -l |grep -i disk --> before adding new disk

#cd /sys/class/scsi_host/ --> we are having host0, host1 and host2

#echo ""- - -"" > /sys/class/scsi_host/host0/scan --> scanning new Lun for host0 , host1 & host2
#echo ""- - -"" > /sys/class/scsi_host/host1/scan
#echo ""- - -"" > /sys/class/scsi_host/host2/scan

#fdisk -l |grep -i disk --> after adding new disk

compare both fdisk output

2. create pv on new disk
#pvcreate /dev/sde

3. Create new VG:
#vgcreate vgbackup /dev/sde
#vgs --> to check all VG's details present on server.

4. Create new LV:
#lvcreate -n lvbkp -l 100%FREE vgbackup --> to use 100% disk space from VG
#lvcreate -n lvbkp -L 4G vgbackup --> to create LV of size 4GB

5. Create FS with FS type ext4:
#mkfs.ext4 /dev/mapper/vgbackup-lvbkp

6. Tune the FS
#tune2fs -m 1 /dev/vgbackup/lvbkp

where -m reserved-blocks-percentage

#tune2fs –c 0 –i 0 /dev/vgbackup/lvbkp

where, The Mount Count (-c) and check interval (i) values below are set to "-1" which disables any checking.

(If c=50 & i=1m then following command will modify the Check interval and Mount Count to only check after 100 mounts or a 1 month period.
#tune2fs -c 100 -i 1m /dev/vgbackup/lvbkp)

7. Create mountpoint:

#mkdir -p /backup

8. Edit /etc/fstab & make entry of new FS
#vi /etc/fstab
/dev/mapper/vgbackup-lvbkp       /backup     ext4    defaults        1 2"

9. Mount file-system

mount /dev/vgbackup/lvbkp /backup

Thanks & Regards,
Kiran Jadhav