Pages

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, December 12, 2016

Reformatting the one of the drive in the hard disk , which has boot loader



Reformatting the one of the drive in the hard disk , which has boot loader








To fix below error : “/dev/sda1 is apparently in use by the system; will not make a filesystem here!”


[root@ecmtest2 /]# mkfs.ext3 /dev/sda1
mke2fs 1.43-WIP (20-Jun-2013)
/dev/sda1 is apparently in use by the system; will not make a filesystem here!






System is not allowing to format one drive part of same hard disk which has Boot loader


Hard disk : /dev/sda
File mount / :
/dev/sda4 on / type ext4
/dev/sda3 on /boot type ext4 (rw)
/dev/sda1 on vfat : that should be changed to ext3


1. Get Disk Mapper by fdisk command



    fdisk -l /dev/sda1


/dev/sda1 1 121602 976762583+ ee GPT
Partition 1 does not start on physical sector boundary.

Disk /dev/mapper/OVM_SYS_REPO_PART_35000c50092db5a04: 993.9 GB, 993933656064 bytes


Here mapper ID : OVM_SYS_REPO_PART_35000c50092db5a04

2.remove the mapper



     dmsetup remove OVM_SYS_REPO_PART_35000c50092db5a04e


3.Run the format command again





    mkfs.ext4 /dev/sda1



4.Edit the /etc/fstab 

Thursday, July 14, 2016

Adding new hard disk in Oracle VM server XEN





A. Adding Hard disk

1. Checking current mount points drives

df -h                                                                                              

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2            9.4G  2.1G  7.3G  22% /
/dev/xvda1             99M   13M   82M  13% /boot
tmpfs                 2.1G     0  2.1G   0% /dev/shm

2 . Listing drives


[root@~]# fdisk -l                                                                         




Disk /dev/xvda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1264    10048657+  83  Linux
/dev/xvda3            1265        1566     2425815   82  Linux swap / Solaris

Disk /dev/xvdb: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdb doesn't contain a valid partition table



3. Creating Partion

[root@SERVER ~]# fdisk /dev/xvdb                                                  

The number of cylinders for this disk is set to 52216.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-52216, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-52216, default 52216):
Using default value 52216

Command (m for help):
Command (m for help): v
838860798 unallocated sectors



4. Format


[root@SERVER ~]# mkfs.ext3 /dev/xvdb                                 


mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
52428800 inodes, 104857600 blocks
5242880 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
3200 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@SERVER ~]# df -h




Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2            9.4G  2.1G  7.3G  22% /
/dev/xvda1             99M   13M   82M  13% /boot
tmpfs                 2.1G     0  2.1G   0% /dev/shm



5. Editing fstab

[root@SERVER ~]# vi /etc/fstab                                                               



Add entry like this
/dev/xvdb /data ext3 defaults 1 2



[root@SERVER ~]# mkdir /data

6, Mounting ..


[root@SERVER ~]# mount /dev/xvdb /data                                                 



[root@SERVER ~]# cd /data



[root@SERVER data]# ls -l
total 16
drwx------ 2 root root 16384 Oct 11 05:28 lost+found
[root@SERVER data]# vi ster
[root@SERVER data]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2            9.4G  2.1G  7.3G  22% /
/dev/xvda1             99M   13M   82M  13% /boot
tmpfs                 2.1G     0  2.1G   0% /dev/shm
/dev/xvdb             394G  199M  374G   1% /data



B. Adding in OVS cluster :



    /opt/ovs-agent-2.3/utils/repos.py -l
   fdisk /dev/sdb

Check : http://rreddy.blogspot.com/2011/06/create-rac-instance-using-oracle-vm.html

C.Adding VM manger:


[root@ecmtest running_pool]# /opt/ovs-agent-2.3/utils/repos.py -l
[ * ] 8b7c78d0-1578-41ce-b988-2c5ff686c12c => /dev/sda3
[   ] 94ef36a3-6221-46c6-a68d-ae5ff8f4b1c8 => /dev/sdb5



Add the files in newly created  /var/ovs/mount/94EF36A3622146C6A68DAE5FF8F4B1C8

Wednesday, July 6, 2016

How to install and configure kerbores for ssh authentication

How to install and configure kerbores for ssh authentication

Time should be in synchoroes between server and clients . Ticket is time based .
All variables are case senstive


In server :

Server Hostname : master



1. Install krb packages


yum install krb5-server krb5-libs krb5-auth-dialog
yum install krb5-pkinit-openssl


2. Edit kdc.conf & kadm5.acl files

Location : /var/kerberos/krb5kdc/

Currently only kdc.conf & kadm5.acl files located here

cd /var/kerberos/krb5kdc/

vi kdc.conf


Change EXAMPLE.COM to your relam

[kdcdefaults]
kdc_ports = 88
kdc_tcp_ports = 88

[realms]
COMPANY.COM= {
#master_key_type = aes256-cts
acl_file = /var/kerberos/krb5kdc/kadm5.acl
dict_file = /usr/share/dict/words
admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
}





3.


vi kadm5.acl


Edit */admin@COMPANY.COM *


*/admin@COMPANY.COM *


4. Edit krb5.conf
Location : /etc/



vi /etc/krb5.conf



[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log

[libdefaults]
default_realm = COMPANY.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true

[realms]
COMPANY.COM = {
kdc = master.COMPANY.COM
admin_server = master.COMPANY.COM
}

[domain_realm]
.COMPANY.COM = COMPANY.COM
COMPANY.COM = COMPANY.COM




5. Create Kerbores Database


cd /var/kerberos/krb5kdc/

kdb5_util create -s -r COMPANY.COM

Provide username/password

Loading random data
Initializing database '/var/kerberos/krb5kdc/principal' for realm 'COMPANY.COM',
master key name 'K/M@COMPANY.COM'
You will be prompted for the database Master Password.
It is important that you NOT FORGET this password.
Enter KDC database master key:
Re-enter KDC database master key to verify:
kdb5_util: File exists while creating database '/var/kerberos/krb5kdc/principal'



This action will create new files

principal ,principal.kadm5 etc

6. start krb5kdc service

service krb5kdc start


Starting Kerberos 5 KDC: [ OK ]

7. Access kadmin.local

kadmin.local

Authenticating as principal root/admin@COMPANY.COM with password.

kadmin.local:

8. In the kadmin.local add principal
a.
kadmin.local: listprincs

This will list it

b.
kadmin.local: addprinc root/admin

This will add principal root to admin group

Add Host Names



c.
kadmin.local: addprinc -randkey hosts/master.COMPANY.COM


d.
kadmin.local: ktadd hosts/master.COMPANY.COM

Add oracle user

e.

kadmin.local: addprinc oracle



9 . To get user token during login , then kerbores authentication should be enabled



authconfig-tui

OR


setup
(Then select authentication option)




Select Kerberos option



























Next and provide the kerbores server OPTION ( by default it will load from /etc/krb5. File


10. Verify login action (Existing user oracle)




a.
ssh -l oracle master

b.
kinit

Password for oracle@COMPANY.COM:

c.

klist

Ticket cache: FILE:/tmp/krb5cc_500
Default principal: oracle@COMPANY.COM

Valid starting Expires Service principal
07/06/16 23:35:47 07/07/16 23:35:47 krbtgt/COMPANY.COM@COMPANY.COM
renew until 07/06/16 23:35:47




11. Add the user with out password



a.

adduser sterin

b. Add in Kerberos DB


kadmin.local


kadmin.local: addprinc sterin

Provide username and password

c. Login using ssh


ssh -l sterin master

Now password is not stored in /etc/passwd of linux server, it will take from Kerberos DB

sterin@master's password:
[sterin@master ~]$ klist


Ticket cache: FILE:/tmp/krb5cc_501_Oc6cOn
Default principal: sterin@COMPANY.COM

Valid starting Expires Service principal
07/07/16 00:45:54 07/08/16 00:45:54 krbtgt/COMPANY.COM@COMPANY.COM
renew until 07/07/16 00:45:54

12. Check local user not in Kerberos DB


adduser notinkb
passwd notinkb

Changing password for user notinkb.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.


ssh -l notinkb master



kinit


kinit: Client not found in Kerberos database while getting initial credentials




To enable service in every restart 






 /sbin/chkconfig --add  krb5kdc
 /sbin/chkconfig krb5kdc on







In client

hostname client1.company.com




yum install krb5-workstation krb5-libs krb5-auth-dialog


2. Change the authentication ,by running setup command

Select Kerberos

























provide server details








3. Now try with user

4.klist will show the ticker details