Saturday, April 28, 2012

Mounting iSCSI Luns on Linux Hosts

Adding iSCSI Storage to a Linux Computer
 
This article describes mounting iSCSI luns from SAN iSCSI targets to Linux hosts. Please make sure that an iSCSI Target has been created and ready for use in theSAN / NAS targets. 


Step 1: Install the iSCSI Initiator Software

[root@test.com /]# yum install iscsi-initiator-utils
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
Running transaction check
Package iscsi-initiator-utils.i686 0:6.2.0.872-7.fc13 set to be installed
Finished Dependency Resolution
...
Installed:
  iscsi-initiator-utils.i686 0:6.2.0.872-7.fc13                                

Complete!

Things you need to have before setting up the iSCSI mounts.
  1. iSCSI startup using the init script or manual startup. You need to edit and configure iSCSI via /etc/iscsi/iscsid.conf file
  2. Discover targets.
  3. Automate target logins for future system reboots.
  4. You also need to obtain iSCSI username, password and storage server IP address (target host)
 Step 2: Edit the iscsi.conf file

Setup username and password:
node.session.auth.username = My_ISCSI_USR_NAME
node.session.auth.password = MyPassword
discovery.sendtargets.auth.username = My_ISCSI_USR_NAME
discovery.sendtargets.auth.password = MyPassword


Where,
  • node.session.* is used to set a CHAP username and password for initiator authentication by the target(s).
  • discovery.sendtargets.* is used to set a discovery session CHAP username and password for the initiator authentication by the target(s)
Make sure iscsi.conf 'node' parameter is set for Automatic
[root@test.com /]# vi /etc/iscsi/iscsid.conf
node.startup = automatic

Now start the iscsi service:
# /etc/init.d/iscsi start

Friday, March 30, 2012

The Find command cheat sheet


The Find Command Cheat Sheet


1. Basic find command
# find -name "TestFile"

2. Find Files Using Name and Ignoring Case
# find -iname "TestFile"

3. Limit Search To Specific Directory Level Using mindepth and maxdepth
# find / -maxdepth 3 -name passwd
-maxdepth --> will go 3 directories below -- / 1st; /etc 2nd; /usr/bin 3rd

# find / -mindepth 3 -maxdepth 5 -name passwd
will go 3 depths first and upto 5 -- so will not disply under /; /usr; /usr/bin

4. Executing Commands on the Files Found by the Find Command.
user -exec {} /;
# find -iname "TestFile" -exec md5sum {} \;

5. Inverting the match.
To inver the match use the "-not" switch
# find / -not -iname "TestFile"

6. List inodes of the files
# ls -i1 test*
16187429 test-file-name
16187430 test-file-name

# find -inum 16187430 -exec mv {} new-test-file-name \;
# ls -i1 *test*
16187430 new-test-file-name
16187429 test-file-name

7. Find file based on the File-Permissions
You can :
    * Find files that match exact permission
    * Check whether the given permission matches, irrespective of other permission bits
    * Search by giving octal / symbolic representation

# find . -perm -g=r -type f -exec ls -l {} \;
Will display all files with group permission read. Not files with readonly group permission

# find . -perm g=r -type f -exec ls -l {} \;
Will dispay files with 040 permission. i.e files with group read only permisison

# find . -perm 040 -type f -exec ls -l {} \;
Will dispay files with 040 permission. i.e files with group read only permisison

Tuesday, March 29, 2011

Download RPM packages from a YUM repo without installing in RHEL

Download RPM packages using YUM


This how-to will explain how to download rpm packages from a yum repository without installing them. This will work on Redhat Enterprise Linux 5.x, Fedora and CentOS 5.x.

You need to install yum plugin called yum-downloadonly. This plugin adds a --downloadonly flag to yum so that yum can download the packages without installing/updating them. Following options supported by this plugin:

  • --downloadonly : don't update, just download a rpm file to default yum cache directory /var/cache/yum/.
  • --downloaddir=/path/to/dir : specifies an alternate directory to store packages such as /tmp
Install the yum-downloadonly plugin:

Type the following command to install plugin, enter:

        # yum install yum-downloadonly

Now for downloading rpm packages from an already configured yum repository use the following command:

      # yum update httpd -y --downloadonly

Friday, February 4, 2011

TCP Wrappers: Securing Linux


This how-to describes configuring TCP Wrappers for providing Access Control for the supported services in a Linux box.TCP wrappers are supported by most of the Linux distributions such as Redhat Enterprise Linux, Ubuntu, SUSE, Debian, BSD and UNIX. TCP Wrappers work in the manner of a host-based Access Control List. They will allow host or network addresses to be used as indicators to filter and implement a layer of access control. They additionally extend the capabilities of xinetd-controlled daemons. By using this technique, connection attempts can be logged, restricted, and messages returned. This can add an extra layer of security in your environment. TCP Wrappers also allow run-time reconfiguration without restarting or reloading the services they protect.

Mount NTFS partition in Linux

Mount NTFS partition in Redhat Enterpris Linux / Ubuntu Linux


Enterprise Linux distributions like Redhat Enterprise Linux ( RHEL ) does not provide native support to Windows NTFS partitions. However you may wand to mount a NTFS formated partiiton in your RHEL box. Here is a simple howto to mount NTFS partitions in your RHEL box.

First of all you need to install a couple of packages. You can use YUM for installing the packages. The rpmforge yum repo contains required rpm packages for mounting NTFS partitions on Linux server. The packages are fuse and fuse-ntfs-3g.

              # yum install fuse fuse-ntfs-3g
Yes, you are done now you can mount ntfs partitions on your rhel server using the mount commandas follows.

             # mount -t ntfs-3g /dev/device-name /mount-point

For example:
           # mount -t ntfs-3g /dev/sdb1 /media

This one also works!!!!!

          # mount.ntfs-3g /dev/sdb1 /media
Newer Ubuntu distributions like Ubuntu 10.04 LTS natively supports NTFS partiitons, so in a Ubuntu server you can mount NTFS partition by just using the above mount commnad.



Saturday, December 4, 2010

Install linux in a pendrive.

Install Linux in pen drive
Yea guys, this time I will show you how to install a Linux distribution in your pen drive. You can use this how-to install almost all the Linux distributions including Ubuntu, fedora, CentOS, Debian, KNOPPIX and much more.


What you need:
  • Universal USB Installer tool.
  • Windows XP/Vista/7 to create the USB (Win 98/2K WILL NOT Work! 
  • Fat32 Formatted Flash Drive, 
  • Your Favourite Linux ISO
And of course a PC supporting USB booting to boot from your pen drive.

You can download the Universal USB Installer tool from this link:
 
The Universal USB Installer is a Live Linux USB creator which allows you to choose from a list of Linux distributions and install it in your pen drive. It also allows you to download the required Linux distribution.
The process is just a piece of cake, just run the tool, select your distribution, browse to the distribution, select the flash drive and click install.

Thursday, November 11, 2010

How to reset root password in Ubuntu 10.04 LTS


In this how to we shall discuss how to reset root password in Ubuntu 10.04 LTS. I guess this howto will be of highly useful if you forgot your root password in Linux servers particularly in debian based systems like Ubuntu.

Single User Mode in Ubuntu 
To reset the root password you have to boot to single user mode. Follow to steps below to boot to the single user mode in Ubuntu 10.04 LTS.

Please note that Ubuntu 10.04 LTS use the GRUB 2 as bootloader. The first boot option will be used by GRUB 2 by default and it will be used for booting without waiting for user input. So you need to interrupt the boot process for getting boot menu.