Monday, March 11, 2019

PARTED on SUSE Linux 12

PARTED on SUSE Linux 12

For creating new partition on SUSE 12 Linux admin generally use "PARTED" command. Also one very important thing want to highlight here is, Linux admin can not create partition larger than 2 TB using fdisk, so in this situation "PARTED" command come in picture.

Also when Linux admin want to extend existing disk on SUSE 12 then parted command is useful, because when Linux admin try to extend existing disk and try to create 2nd or any new partition "fdisk" will not work. It will throw error on SUSE 12 as below

Error :

Value out of range. 

so solution to this issue is always use "parted" command on SUSE 12 for partitioning existing disk.

Now here i will discuss  how to create partition on new disk on SUSE 12.

scenario :

Create new partition on /dev/sdb of  size 100 GB

root@/root : parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
(parted) mklabel gpt         // assign "gpt" lable type to disk.
(parted) mkpart primary 1049K 100%          // Create primary partition of using 100% free space.
(parted) set 1 lvm on                              // SET lvm flag to partition 1.
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags

 1      1049kB    100 GB  100 GB               primary  lvm

(parted) q

Information: You may need to update /etc/fstab.

root@:/root : partx -a /dev/sdb   // add newly created partitions.

root@:/root : pvcreate /dev/sdb1    // create new PV 


This is how we created 100 GB partition on SUSE Linux using parted. Newly created PV admin can use for expanding existing Volume group or can use to create new volume group.

Example.

1.
Add /dev/sdb1  to existing volume group vg01

#vgextend vg01 /dev/sdb1

Or
2.

Create new volume group vg02 using /dev/sdb1 PV.

#vgcreate vg02 /dev/sdb1


Thanks !!!!!



Sunday, January 13, 2019

Suse Linux SLES 12 fdisk error "Value out of range"

Hello everyone this post i am writing for Linux admin who faced or will going to face following error , when they use fdisk command for doing partition on Suse Linux 12.

"Error : Value out of range"

Task details 
==============

Increase size of following file system to 100 GB

Procedure followed :
=================
Filesystem details 

# df -hT /data
Filesystem                 Type      Size    Used      Avail  Use% Mounted on

/dev/mapper/vg01-lvdata      50G   1.0G        49G   2% /data

# vgs
  VG     #PV #LV #SN Attr     VSize    VFree
  vg00     1       3     0      wz--n- 19.47g   1.47g

  vg01     1        8   0       wz--n-  50.0g   0.00 

Disk layout on which "/data" reside

sdb                          8:16   0  50G  0 disk
`-sdb1                       8:17   0  50G  0 part

  |-vg01-lvdata    254:3    0   50G  0 lvm  /data

SCSI details

root#  lsscsi

[0:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb

On vg01 there was no free space, so decided to extend existing disk to to 100 GB. so we provided SCSI details to VM team and requested increase size of /dev/sdb from 50 GB to 100 GB. after size increase from vmware team, we did disk re-scan using following command

#echo 1 >/sys/block/sdb/device/rescan

After re-scan output of lsblk is :

#lsblk |grep -i sdb
sdb                          8:16   0  100G  0 disk

now next step was to create new partition using fdisk utility. So i use command #fdisk /dev/sdb and printed existing partition table before creating new partition and observed that there is already one partition /dev/sdb1 there so new partition will be /dev/sdb2.

Steps followed for partitioning using fdisk :

#fdisk /dev/sdb

by pressing "n" started new partition creation process.

First sector : Press enter (it will take default value) // it will take value from where disk extended.

End sector , +sectors or +size{K,M,G}: +50G    // when press enter got following error

  "Error : Value out of range".  

After searching on google and took suggestion from senior,  always use "parted" for doing partition on SLES 12 when situation is like above, where disk is having one primary partition already then we need to create 2nd partition /dev/sdb2, then use "parted" command.

After this i used parted for creating partition on /dev/sdb like :

Procedure for doing partition using parted :
***please use parted command carefully , it can erase all data on your disk if you use it wrongly.



Linux#: parted /dev/sdb

GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print      //print partition details on /dev/sdb
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system
believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? fix     // enter fix

Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an
extra 629145600 blocks) or continue with the current setting?
Fix/Ignore? Fix   // enter fix

Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt_sync_mbr
Disk Flags:

Number  Start         End          Size   File system  Name     Flags
 1             1049kB  50GB      50GB                      primary  lvm         // Existing /dev/sdb1 partition

(parted) mkpart primary 50GB 100%      // Create /dev/sdb2  partition which start from 50 GB and end is use 100% space from 50GB onward.
(parted) print

Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt_sync_mbr
Disk Flags:
Number  Start   End    Size   File system  Name     Flags
 1      1049kB  50GB   50GB                  primary        lvm
 2       50GB    100GB   50GB                 primary  

(parted) set 2 lvm                                // setting flag to "lvm" for 2nd partition /dev/sdb2
New state?  [on]/off? on
(parted) print

Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt_sync_mbr
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  50GB  50GB               primary  lvm
 2      50GB   100GB  50GB               primary  lvm

(parted) quit
Information: You may need to update /etc/fstab.

#partx -a /dev/sdb      // Add the specified partition
#pvcreate /dev/sdb2
#vgextend vg01 /dev/sdb2

#vgs
VG       #PV #LV #SN Attr   VSize  VFree
  vg00     1      3      0     wz--n- 19.47g   1.47g
  vg01     1      1      0     wz--n-  100.0g    50.0g

#lvextend -L +50G /dev/mapper/vg01-lvdata
#xfs_growfs  /dev/mapper/vg01-lvdata

# df -hT /data
Filesystem                 Type      Size    Used      Avail  Use% Mounted on

/dev/mapper/vg01-lvdata      100G   1.0G   99G   1% /data


This way resized xfs filesysetm on Suse Linux 12, when  fdisk partitioning failing then used parted for partition and added that pv to vg01 and increased /data.

Thanks !!!

How to change existing user ID on Suse Linux using usermod command

Hello Friend ,

Today i am going to share how Linux admin can change existing user id. while doing day-today user administration task we got ticket for change existing user ID.

Request Details:

Change oracle user ID from 3600 to 3800.

Prerequisite check before changing user ID .

1. Make sure that new user ID which we going to use is not in use by any other user.
here 3800 is the new user id, so we can check whether its in use or not by using following command.

#cat /etc/passwd |grep -i 3800

2. No process with user id 3600 ,should be running while changing userid.
If any process is in running state(using user id 3200) while changing user id it will throw following error .

usermod: user oracle is currently used by process 17340


Now after checking all prerequisite we executed below command for userid change.

Syntax :  usermod -u [new_user_id]  [user_name]

root@Linux:/root : usermod -u 3800 oracle

-u new user ID for oracle user.

After executing above command we got some error message like below

"usermod: user oracle is currently used by process 17340"

After checking process details we found that its oracle process running with user id oracle[3600], So we checked with DBA team should we kill that process??. After there confirmation we killed process using command "#kill -9 17340" and re-run usermod command again and this time it executed successfully.

*** in production environment double check impact of killing any existing process. It will have impact on currently running application/database.

Check modified uid using below command.

#cat /etc/passwd |grep -i  oracle.

Thanks !!!





Thursday, November 22, 2018

sshd[22107]:SSH Authentication Refused Bad Ownership or Modes for Directory

Hello everyone ,

Lets discuss how to troubleshoot following error while trying to login remotely using pass wordless ssh.
"sshd[22107]: Authentication refused: bad ownership or modes for directory"

One user from development team was trying to run some pearl script and while executing that script he getting permission denied and prompting for password(pass wordless authentication environment)

When user executing pearl script he was getting following message

please authenticate for oracle|Authenticated with 
partial success|Permission denied (keyboard-interactive,password

 So I decided to check /var/log/authlog  file for any clue. After checking file found following line in authlog.

sshd[20856]: Authentication refused: bad ownership or modes for directory /home/oracle

from this clue it indicating that ownership or mode on home directory not correctly set. when i checked found that ownership is correct but permission on home directory wasn't correct . "/home/oracle" directory was group writable and this causing error "sshd[22107]: Authentication refused: bad ownership or modes for directory".

So here are  step which i performed to correct this error 

#chmod g-w /home/oracle

#ls -ld /home/oracle

#Linux: /home/oracle# ls -ld /home/oracle

drwxr-x--- 2 oracle dba 4096 Nov  3  2017 /home/oracle

so here important thing is home directory must not group writeable.

After removing write permission from group development user able successfully execute pearl script and able to do passwordless login.

Some other pre-requisite for passwordless ssh configuration are like below.......

1 User home directory permission :755 and correct ownership 
2 .ssh: 700 and correct ownership
3  authorized_keys :600 and correct ownership
4 correct public key at both source and destination server

Thanks !!!!!!!!!!!





Extend file system when max primary partition limit reached on Linux.

Extend file system when max primary partition limit reached on Linux.

Example

VG01- /dev/sdb    // sdb having  4 Primary partition.
   -/dev/sdb1
   -/dev/sdb2
   -/dev/sdb3
   -/dev/sdb4

Now VG01 having FS /oracle/log of size 500GB and Linux admin want it to increase by 100GB.
But on VG01 there is no free space available , so admin decided to expand existing disk /dev/sdb.
After analysis found that /dev/sdb already having 4 primary partition and we cant create 5th primary partition.

Why existing disk expand is not possible?
answer to this query if on existing disk  Linux admin already created 4 primary partition so now creation of 5th primary partition is not possible. Linux will not allow creation of 5 primary partition on single disk.

Solution to this situation is add new disk to Virtual machine and create required partition on it and create PV and add it to volume group where FS reside. So after adding PV to volume group VG01 total free space in VG01 will be 100 GB . Now Linux admin can add 100 GB to /oracle/log.

How to detect new disk on suse linux ?

Run command rescan-scsi-bus.sh , this add scsi devices to Linux virtual machine without reboot.
take lssci before and after running rescan-scsi-bus.sh. find difference and it will show new disk.

Output of lsscsi before running rescan-scsi-bus.sh
#lsscsi
[0:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda

[0:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb

After running rescan-scsi-bus.sh

#lsscsi
 [0:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda
 [0:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb    
 [0:0:2:0]    disk    VMware   Virtual disk     1.0   /dev/sdc       // /dev/sdc is new disk .
After create required size partition and add it to VG01 and expand FS.


#lvextend -L +100G /dev/mapper/VG01-lvora_log
#lvs    

#resize2fs /dev/mapper/VG01-lvora_log   //resizing EXT3 Filesystem

Check using df -hT /oracle/log whether FS is resized or 

command for resizing XFS file system.

#xfs_growfs /dev/mapper/VG01-lvora_log

Extended partition  is solution to overcome max 4 primary partition but if Linux environment where creation of extended partition is not allowed then this approach is useful.





Thanks !!!!



Understand /etc/fstab last two field

Have you ever wondered what exactly last 2 field of /etc/fstab in Linux.
Lets see what they suggest.

Fstab syntax is like below

file-system                      mount point   type            options       dump  pass

/dev/vg00/lvsysmgmt  /sysmgmt             ext3       defaults              1     2
NFS-server-hostname:/share   /mnt         nfs         defaults,bg,intr 0 0

Here i am going to discuss what exactly last 2 field dump and pass tells operating system during boot.

dump - 0 and 1
pass - 0 , 1 and 2

DUMP
dump backup  of Filesystem
0 - disable 
1- enable 

PASS 
fsck on filesystem 0 -Disable fsck 
1- Enable fsck
2 - Perform fsck on other FS after / fsck done.simply order of FSCK , 1 for / and 2 for all other FS.

Dump - This tells OS to create dump backup of Linux file system.
Pass -  This Tell OS that do FSCK on this file system after " /" FSCK done. It defines FSCK order , generally / having priority over other File system and / having 1 value if you observe this in Linux /eetc/fstab configuration file.

If you observe fstab you will found that / having pass value 1 and other FS having 2 , So its order of doing fsck on filesystem while booting Linux operating system.

Then what about NFS file system which also occupying stanza in /etc/fstab ??

for NFS file system dump and pass value always 0 . 0 means disable fsck and dump during boot .

Why NFS having pass and dump value always 0 ??
1. NFS file system resides on remote server.



Thanks !!!



Running fsck on AIX filesystem

Hello Friends , 
Today i am sharing how to run fsck on AIX non rootvg file system.

When AIX LPAR rebooted without proper application stop and umount of file system then next when AIX LPAR up then non rootvg file system may not get mounted. Sometime following error can be seen when admin try to mount that File system.

#mount /oracle
mount: 0506-324 Cannot mount /dev/oralv01 on /oracle: The media is not formatted or the format is not correct.
0506-342 The superblock on /dev/oralv01 is dirty.  Run a full fsck to fix


Solution to this type of error is Run a full fsck .

#fsck /dev/oralv01

After successfull fsck command execution mount filesystem using following command.

#mount /oracle
#df -gt /oracle   // check whether mounted or not


Thanks !!!!!!