Feb.07

Ubuntu: iscsiadm: initiator reported error (24 – iSCSI login failed due to authorization failure)

i was trying to export one iscsi share from centOS server and my client is Ubuntu server.

well i know this will work on  CentOS/Redhat without any changes and i was under impression that , on ubuntu also will get same behavior.

On CentOS, below are the commands to create Iscsi target

Server

Install and enable services:
yum -y install target*
systemctl start target && systemctl enable target
# targetcli /backstores/block create name=ubuntu-iscsi dev=/dev/cl_centos/lv_scsi
# targetcli /iscsi create iqn.2017-02.com.example.kw:centos
# targetcli /iscsi/iqn.2017-02.com.example.kw:centos/tpg1/acls create iqn.2017-02.com.example.kw:ubuntu-archive
# targetcli /iscsi/iqn.2017-02.com.example.kw:centos/tpg1/luns create /backstores/block/ubuntu-iscsi
# targetcli /iscsi/iqn.2017-02.com.example.kw:centos/tpg1/portals delete 0.0.0.0 3260
# targetcli /iscsi/iqn.2017-02.com.example.kw:centos/tpg1/portals create 192.168.1.66 3260
# targetcli saveconfig

Allow TCP port  if firewalld is enabled.

# firewall-cmd –permanent –add-port=3260/tcp

All set from from target(server) side.

Client

On client side install iscsi packages

# apt-get -y install open-iscsi

edit /etc/iscsi/iscsid.conf and change like below

# To request that the iscsi initd scripts startup a session set to “automatic”.
# node.startup = automatic
 node.startup = automatic

and i manually edited /etc/iscsi/initiatorname.iscsi , added iqn number taken from server.Which is

InitiatorName=iqn.2017-02.com.example.kw:centos

restart service

# service iscsid restart

Do the discovery

# iscsiadm -m  discovery –type sendtargets –portal 192.168.1.66

And finally Login to target

# iscsiadm -m node –targetname iqn.2017-02.com.example.kw:centos –portal 192.168.1.66 –login

 

After this , the newly added disk will be displayed under fdisk. Below is the syslog

Feb 7 14:08:51 ubuntu kernel: [89946.433408] scsi host4: iSCSI Initiator over TCP/IP
Feb 7 14:08:51 ubuntu kernel: [89946.693040] scsi 4:0:0:0: Direct-Access LIO-ORG ubuntu-iscsi 4.0 PQ: 0 ANSI: 5
Feb 7 14:08:51 ubuntu kernel: [89946.745641] sd 4:0:0:0: Attached scsi generic sg4 type 0
Feb 7 14:08:51 ubuntu kernel: [89946.746061] sd 4:0:0:0: [sdb] 993222656 512-byte logical blocks: (509 GB/474 GiB)
Feb 7 14:08:51 ubuntu kernel: [89946.748472] sd 4:0:0:0: [sdb] Write Protect is off
Feb 7 14:08:51 ubuntu kernel: [89946.748475] sd 4:0:0:0: [sdb] Mode Sense: 43 00 00 08
Feb 7 14:08:51 ubuntu kernel: [89946.749300] sd 4:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Feb 7 14:08:51 ubuntu kernel: [89946.771007] sd 4:0:0:0: [sdb] Attached SCSI disk
Feb 7 14:08:52 ubuntu iscsid: Connection9:0 to [target: iqn.2017-02.com.example.kw:centos, portal: 192.168.1.66,3260] through [iface: default] is operational now

 

Aug.30

Transmission settings.json Reverting to Defaults

The transmission-daemon package from EPEL makes it easy to setup a command line bittorrent client on RHEL  or CentOS . However, I have encountered situations where modified settings in/var/lib/transmission/.config/transmission/settings.json revert back to their defaults upon starting the transmission-daemon service.

In particular, the rpc-authentication-required parameter will always revert back to false if set to true when using a default transmission-daemon install. This occurs because of certain switches being passed by the transmission-daemon init script found at /etc/init.d/transmission-daemon.

The particular line in /etc/init.d/transmission-daemon that is overriding certain parameters in /var/lib/transmission/.config/transmission/settings.json is the following:

 

DAEMON_ARGS="-T --blocklist -g $TRANSMISSION_HOME/.config/transmission"

The -T switch causes transmission-daemon to never require authentication, and the –blocklist switch enables peer blocklists. If you would rather your settings only be defined in /var/lib/transmission/.config/transmission/settings.json, remove those switches. I would suggest copying this line, commenting it out, pasting a new line, and removing the switches from the new line in case you ever want to revert to the default settings. The new DAEMON_ARGS line would then look like the following:

 

DAEMON_ARGS="-g $TRANSMISSION_HOME/.config/transmission"

Now, all settings will only be defined in /var/lib/transmission/.config/transmission/settings.json.

Take note, in order to change any settings in /var/lib/transmission/.config/transmission/settings.json, the transmission-daemon service must be stopped. Changes made while the service is running will be ignored and set back to their previous settings upon restart.

Mar.23

Network Issue on VMWare Workstation – CentOS 7 & above

I was facing this issue with centos 7.2 release and device was not showing in my nmcli.

I tried many times adding/removing cards the reason is that the v7 3.10 kernel no longer supports the Ethernet Controller device And the solution is..

I added the following line to your  .vmx file and reboot system.

ethernet0.virtualDev = “e1000”

*replace ethernet0 with your card specific number

One Line Script to list all LUNS on Solaris 10

Hi All,

 

Here is one line script to list all LUN’s(only external Storage) on solaris 10.

 

root@benvin.net# luxadm probe | grep -v “Node WWN:” | awk -F\/ ‘NR>3{print $4}’|sed ‘s/..$//g’
c3t600D0231000BE73D1C9ED0B453F185C2d0
c3t600D0231000BE73D4A2C042D18A2E641d0
c3t600D0231000BE73D6D42C80D77B8DDF0d0
c3t600D0231000BE73D194D85CA4D102795d0
c3t600D0231000BE73D435D27657C919F6Ed0
c3t600D0231000BE73D5482A3BE75F412FCd0
c3t600D0231000BE73D5619FDD6500CF273d0
c3t600D0231000BE73D37672E311947B18Cd0

Good luck

Solaris disk utilization(including zones) script & sending to mysql

HI

I have been writing scripts to automate my solaris admin tasks. currently i am handling more than 250 sun servers and my primary focus area is solaris nowadays. Somehow linux came to 2nd priority

today i am posting some script to monitor disk utilization of solaris server including zones(containers). And this script will send result to mysql database directly .you need to run this script on global zone and you than set the disk check threshold value also.

To connect to mysql, you need to install mysql-client package. ie simple compile & make. you can download mysql-client from http://dev.mysql.com/downloads/mysql/5.1.html. For compiling this package , you need Compilers and other development tools. You can get all this from sun studio. Install sun studio and include studio in your PATH.

 

#!/bin/bash
#Created By – Ben George – ben@benvin.net
IFS=$’\n’ read -d ” -ra filesystem < <(df -h | egrep -e ‘/dev/dsk|pool’)
IFS=$’\n’ read -d ” -ra zonename < <(zoneadm list)
DATE=$(/usr/bin/date |awk ‘{print $3″-“$2”-“$6}’)
ipaddress=$(ifconfig -a | grep inet | grep -v ‘127.0.0.1’ | awk ‘NR>1{ print $2}’| head -1)
for i in “${!zonename[@]}”;do

if [ “${zonename[$i]}” = “global” ];then
for i in “${!filesystem[@]}”;do
percentage=$(echo “${filesystem[$i]}” | awk ‘{print $5}’ | sed ‘s/%/ /g’)
if [ $percentage -gt 50 ];then
mountpoint=$(echo “${filesystem[$i]}” | awk ‘{print $6}’)
echo $HOSTNAME $ipaddress $mountpoint “:” $percentage”%”
/opt/mysql/bin/mysql –host=172.16.99.182 –user=root –password=Redhat server_daily << EOF
insert into filesystem (hostname,ipaddress,time,filesystem_name,percentage) values(‘$HOSTNAME’,’$ipaddress’,’$DATE’,’$mountpoint’,’$percentage’);
EOF
fi
done
else
echo “${zonename[$i]}”
IFS=$’\n’ read -d ” -ra zonefilesystem < <(zonecfg -z “${zonename[$i]}” info | egrep ‘pool|dir:’ | awk ‘{print $2}’)
for j in “${!zonefilesystem[@]}”;do
echo “${zonefilesystem[$j]}” | while read n;do
zonepercentage=$(zlogin “${zonename[$i]}” df -h “${zonefilesystem[$j]}” | awk ‘NR>1{print $5}’ | sed ‘s/%/ /g’)
if [ $zonepercentage -gt 50 ];then
zone_mountpoint=$(zlogin “${zonename[$i]}” df -h “${zonefilesystem[$j]}” | awk ‘NR>1{print $6}’)
zone_hostname=$(zlogin “${zonename[$i]}” hostname)
zone_ip=$(zlogin “${zonename[$i]}” ifconfig -a | grep inet | grep -v ‘127.0.0.1’ | awk ‘{ print $2}’)
echo $zone_hostname $zone_ip $zone_mountpoint “:” $zonepercentage”%”
/opt/mysql/bin/mysql –host=172.16.99.182 –user=root –password=Redhat server_daily << EOF
insert into filesystem (hostname,ipaddress,time,filesystem_name,percentage) values(‘$zone_hostname’,’$zone_ip’,’$DATE’,’$zone_mountpoint’,’$zonepercentage’);
EOF
fi
done
done
fi
done

 

Apr.03

How to install PAC Manager On Fedora

PAC is a Perl/GTK replacement for SecureCRT/Putty/etc (linux ssh/telnet/… gui)… It provides a GUI to configure connections: users, passwords, EXPECT regular expressions, macros, etc.

Features

  • Unique linux app to implement SecureCRT’s functionality (more or less!)
  • Remote and local macros
  • Remotely send commands with EXPECT regexp
  • Cluster connections!! Connections on same cluster share keystrokes!!
  • Scripting support! (vía Perl code)
  • Serial/tty connection via cu/tip/remote-tty connections!!
  • Pre/post connections local executions
  • TABS OR WINDOWS for connections!!
  • Proxy support
  • KeePass integration!
  • Wake On LAN capabilities
  • Possibility to split terminals in the same TAB!
  • Quick acces to configured connections via tray menu icon
  • Best linux GUI for ssh, telnet, sftp, rdesktop, vnc, cu, remote-tty, ftp, etc
  • DEB, RPM & .TAR.GZ packages available!!
  • More to come (ASA I find time!)
  • FREE (GNU GPLv3)

Download package from : http://sourceforge.net/projects/pacmanager/files/pac-4.0/

 

Install Dependency packages by using yum

 

# sudo yum install perl-YAML uuid-perl perl-Gtk2-GladeXML perl-Crypt-CBC perl-Socket6 perl-Net-ARP perl-Gtk2-Ex-Simple-List perl-Crypt-Blowfish perl-Net-SSH-Expect perl-IO-Stty vte tigervnc rdesktop

UPDATE: When you face issue with PAC manager Opening, please follow below steps.

First of all, install (yum or whatever method you prefer) the “Vte development” package (it’s very small, so don’t worry).
In Debian, is called ‘libvte-dev’, but in RedHat (and derivatives) I think it’s named ‘vte-devel’. So, something like:

yum install vte-devel

should work.

Now:

# wget http://search.cpan.org/CPAN/authors/id/X/XA/XAOC/Gnome2-Vte-0.11.tar.gz
# tar xfz Gnome2-Vte-0.11.tar.gz
# cd Gnome2-Vte-0.11/
# perl Makefile.PL make

At this point, please, modify your ‘/opt/pac/lib/ex/vte64/auto/Gnome2/Vte/Vte.so’ with the newly complied one ‘blib/arch/auto/Gnome2/Vte/Vte.so’. So, do:

sudo cp -f blib/arch/auto/Gnome2/Vte/Vte.so /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/

 

 

How to create automatic home directories in Solaris 10

To achieve automatic home-directory creation in solaris is little bit difficult. If it is NFS/NIS, we can achieve this through autofs(auto_mater) method. I saw many other post saying that they have achieved this with LDAP by using scripts. I Tried the same method with scripts and it didn’t worked for me.

 

There is another way we can achieve this by using pluggable authentication modules(PAM).Compared to linux, solaris PAM is very limited and there is not much modules on it.

 

Here is the summery :

 

1. installed sun studio( To get gcc and other development tools)
2. compiled Linux PAM modules on solaris
3. copied the modules to security directory
4. included module in /etc/pam.conf

 

Download and install Solaris Studio : http://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/index-jsp-141149.html

 

Download and extract Linux PAM modules : http://www.linux-pam.org/pre/library/Linux-PAM-0.81.tar.gz

 

export PATH

 

PATH=/usr/sfw/bin:/usr/ccs/bin:/opt/sfw/bin:/opt/solarisstudio12.4/bin:$PATH
cd /var/tmp/Linux-PAM-0.81
./configure
cp _pam_aconf.h libpam/include/security
cd modules/pammodutil
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_cleanup.c
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_ioloop.c
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_getpwnam.c -D_POSIX_PTHREAD_SEMANTICS
cd ../pam_mkhomedir
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -I../pammodutil/include pam_mkhomedir.c
ld -o pam_mkhomedir.so -B dynamic -G -lc pam_mkhomedir.o ../pammodutil/modutil_*.o
cp pam_mkhomedir.so /usr/lib/security/pam_mkhomedir.so.1
cd /usr/lib/security
ln -s pam_mkhomedir.so.1 pam_mkhomedir.so

 

finally comment /home in /etc/auto_master file

 

restart autofs:
svcadm disable autofs
avcadm enable autofs

 

include pam_mkhomedir.so in /etc/pam.conf

 

other session required pam_mkhomedir.so.1 skel=/etc/skel/ umask=0022