Thursday, May 9, 2013

RHEL 6 iSCSI setup

Here is a mini howto for setting up RHEL 6 to share iSCSI storage.


A note of advice:
Whatever device you setup to be shared out as an iSCSI device, must not be mounted on the server. If it is mounted, you will not see it when you run the command tgt-admin –show!

Server steps used:
  1. yum install scsi-target-utils perl-Config-General
  1. service tgtd start
  2. chkconfig tgtd on
  3. add the following lines to /etc/tgt/targets.conf

<target iqn.2012-05.com.example.server1:data>
backing-store /dev/sdb1   #LUN1
write-cache off
</target>

  1. service tgtd restart
  2. tgt-admin –show
you should see output similar to the following
 
Target 1: iqn.2011-07.com.example.server1:trial
  System information:
  Driver: iscsi
  State: ready
  I_T nexus information:
  LUN information:
  LUN: 0
      Type: controller
      SCSI ID: IET     00010000
      SCSI SN: beaf10
      Size: 0 MB
      Online: Yes
      Removable media: No
      Backing store type: rdwr
      Backing store path: None
  LUN: 1
      Type: disk
      SCSI ID: IET     00010001
      SCSI SN: beaf11
      Size: 20000 MB
      Online: Yes
      Removable media: No
      Backing store type: rdwr
      Backing store path: /dev/sdb1

To mount the newly create iSCSI luns on the client follow these steps on the client:
  1. yum install iscsi-initiator-utils
  2. service iscsid start
  1. chkconfig iscsid on
  1. run the following commands to discover and connect to the lun on the server
    1. iscsiadm –mode discovery –type sendtargets –portal 192.168.1.10
      1. you will see output similar to the following:
      1. 192.168.1.10:3260,1 iqn.2012-05.com.example.server1:data
    1. iscsiadm –m node –T iqn.2012-05.com.example.server1:data –p 192.168.1.10 –l
      1. Logging in to [iface: default, target: iqn.2012-05.com.example.server1:data, portal: 192.168.1.10,3260]
  1. You should now see a new device listed in fdisk. Something along the lines of /dev/sdb1 if you only have 1 hdd in the server
  1. You are now ready to mount /dev/sdb1
  1. To mount the filesystem run the following commands:
    1. mkdir /data
    1. mount /dev/sdb1 /data
  1. If you want to make the mount point persistant, add the following line to /etc/fstab:
    1. /dev/sdb1           /data     ext4       defaults               0 0

How to create a local RHEL/CentOS repo


Here are the steps you need to create a local repo using the installation media for RHEL/CentOS.

insert cd in to optical drive
mount /dev/cdrom /media
cp -uRav /media/* /repo
once complete modify /etc/yum.repos.d/rhel.repo
vi /etc/yum.repos.d/rhel.repo
insert the following text into the file
[rhel]
name=rhel repo
baseurl=file:///repo
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

save changes and exit
run the following commands
yum clean all
yum list available

Change SSH Welcome Banner on Ubuntu


Change SSH Welcome Banner on Ubuntu


Every time I connect to my Ubuntu development server through my ssh client, I receive the same message and I’m getting tired of seeing it, so I decided to change the message to something else.
Here’s the message that I get every time:
Welcome to Ubuntu 13.04 (GNU/Linux 3.8.0-19-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu May  9 07:37:21 CDT 2013

  System load:  0.01               Processes:           88
  Usage of /:   17.4% of 14.64GB   Users logged in:     0
  Memory usage: 34%                IP address for eth0: 10.14.186.85
  Swap usage:   0%

  Graph this data and manage this system at https://landscape.canonical.com/

0 packages can be updated.
0 updates are security updates.

New release '13.04' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Aug 13 01:05:46 2007 from ipaddress removed
root@test:~$
Changing this message requires editing two different files. The first three sections can be modified by editing the following file:
/etc/motd
This file contains the linux build number as well as the Ubuntu warranty message. I don’t find this particularly useful, so I removed all of it and replaced it with my own message.
To disable the last login message (which I don’t recommend doing), you will need to edit the following file in sudo mode:
/etc/ssh/sshd_config
Find this line in the file and change the yes to no as shown:
PrintLastLog no
Now when you login, you’ll get a blank prompt, although I wouldn’t necessarily recommend it because it’s useful to see the last login to the system for security reasons. This is my prompt now:
Welcome to Ubuntu 13.04 (GNU/Linux 3.8.0-19-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu May  9 07:37:21 CDT 2013

  System load:  0.01               Processes:           88
  Usage of /:   17.4% of 14.64GB   Users logged in:     0
  Memory usage: 34%                IP address for eth0: 10.14.186.85
  Swap usage:   0%

  Graph this data and manage this system at https://landscape.canonical.com/


root@test:~$
Linux is really great.