Increase Swap Partition Space in Linux



Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your server from 1GB to 2 GB, but there is only 2GB of swap space. It might be advantageous to increase the amount of swap space to 3GB or 4GB if you perform memory-intense operations or run applications that require a large amount of memory.
We can do it in two ways: 
  1. add a swap partition 
  2. add a swap file.
It is recommended that you add a swap partition, but sometimes that is not easy if you do not have any free space available.
Create a new partition or Logical volume, based on your environment

For example

lvcreate -L 2GB -n swap_lv appvg

Now make that partition or LV as swap space.
mkswap /dev/appvg/swap_lv

Now turn on the swap on that LV or partition.

swapon /dev/appvg/swap_lv

Now this partition is added as swap space.

To check,

free -m
cat /etc/swaps


To enable it at boot time, edit /etc/fstab to include: 


/dev/appvg/swap_lv      swap swap defaults 0 0



For Creating the swap file and add it to swap space, see my earlier post here


Please don't forget to post your comments on this..

TSM Video Tutorials - Tivoli Storage Manager



Hi Friends,

Here is the Excellent video tutorial for Tivoli Storage Manager (TSM). My Friend Ramkumar who is an UNIX Admin, prepared this tutorial. 

This Video Tutorial is in Tamil and the explanation is great.. People can understand very easily about TSM by watching this video..

Excellent work done by Ramkuamr and many thanks to him for his contribution..

Download TSM Video Tutorial 

Post your feedback about this video tutorial.

Redhat Cluster Setup Guide

Here is Redhat Cluster Suite Setup Quick Guide prepared by Ramu Yadav. This nice article is gives a clear idea about cluster setup in Linux



About Redhat Cluster Suite:

For applications that require maximum uptime, a Red Hat Enterprise Linux cluster with Red Hat Cluster Suite is the answer. Specifically designed for Red Hat Enterprise Linux, Red Hat Cluster Suite provides two distinct types of clustering:
  • Application/Service Failover - Create n-node server clusters for failover of key applications and services
  • IP Load Balancing - Load balance incoming IP network requests across a farm of servers
With Red Hat Cluster Suite, applications can be deployed in high availability configurations so that they are always operational-bringing "scale-out" capabilities to Enterprise Linux deployments.

For high-volume open source applications, such as NFS, Samba, and Apache, Red Hat Cluster Suite provides a complete ready-to-use failover solution. For most other applications, customers can create custom failover scripts using provided templates. Red Hat Professional Services can provide custom Red Hat Cluster Suite deployment services where required.

Here is example setup and simple guide to setup a cluster based on redhat cluster suite.

Many Thanks to my friend Ramu Yadav who contributed this Guide.. 


Post your comments on this.

Linux Booting Process Sequence

  1. When the computer is switched on, it automatically invokes BIOS [a ROM chip embedded in the motherboard].
  2. The BIOS will start the processor and perform a POST [power on self test] to check whether the connected device are ready to use and are working properly.
  3. Once the POST is completes BIOS will jump to a specified location in the RAM and check for the booting device. The boot sector is always the first sector of the hard disk and BIOS will load the MBR into the memory.
  4. Here the boot loader takes the control of the booting process.
  5. LILO or GRUB is the boot loaders commonly available. It will help the user to select various boot options.
  6. Depending on the boot option selected the kernel is loaded.
  7. After kernel is loaded the kernel will take the control of the booting process
  8. initrd will be loaded which contains drivers to detect hardware (Initialization of RAM Disk)
  9. Then it will initialize all the hardware including I/O processors etc.
  10. Kernel then mounts the root partition as read-only
  11. INIT is loaded.
  12. INIT will mount the root partition and other partitions as read/write and checks for file system errors.
  13. Sets the System Clock, hostname etc..
  14. Based on the Runlevel, it will load the services and runs the startup scripts (Network, cups, nfs, etc.)
  15. Finally it runs the rc.local script.
  16. Now the login prompt will appear.
Friends,

Let me know if any points missed out... Please post your valuable feedback.. Help me to improve...


Kernel Tuning in Linux

There are two methods to configure/tune the Kernel parameters in RHEL

1. Use the command sysctl -w <parameter_name>= <value> 

The above command will change the kernel parameters on the fly but the changes are not persistent with system reboots. 

2. The second method is,

     a. Edit the file "/etc/sysctl.conf" by adding the parameters along with values
     b. execute "/sbin/sysctl -p" to make sure that the changes are made using the values inside the above mentioned file.

The advantage with the second method is that the changes are persistent with system reboots. 

To View the Kernel Parameters:

#sysctl -a


Hope that the information will be useful for you.

Reinstall Grub in Linux

Boot the server using the Linux CD and Type "linux rescue" on the boot prompt.

Once you get the Shell Prompt, Now follow the steps:

# chroot /mnt/sysimage

Now issue the command "grub-install <your_primary_drive>"
 
For Example:
    
# grub-install /dev/sda

Now the grub will be reinstalled in the primary hard disk.

Please post your comments.

Changing Hostname in Suse Linux

To Set the host name Temporarily:

hostname <SERVER_NAME>

The '-v' in this example means verbose. If the '-v' option is used, the output will look similar to what is below:

server1~# hostname -v computer2
Setting hostname to `computer2'
server1~#

log out of the terminal and login the terminal again. Now you can see the changed hostname

However, with hostname command, it might not be a global change with in your Linux system.

To set the Hostname Permenantly in SuSe Linux Enterprise server: 

Edit /etc/HOSTNAME

# vi /etc/HOSTNAME  

or

# echo server2.mycompany > /etc/HOSTNAME

This will change hostname permenantly. Reboot the server and verify.

CHANGING THE HOST NAME THROUGH YAST Tool

Open the YAST control center.

#yast

Navigate to Network Services --> DNS and Hostname.

The Hostname and Name Server Configuration window appears. 

Under the Hostname field, change the host name to a desired name and click the finish button.
Reboot the computer.

To View/check the server details, use the following commands:

  • hostname - will show or set the computer's host name
  • domainname - shows or sets the computer's NIS/YP domain name
  • dnsdomainname - shows the computer's DNS domain name
Your suggestions/comments are welcome on this.

Important Services & Port Numbers

Service

Port Numbers

 FTP

21

 SSH/SFTP/SCP

22

 Telnet

23

 SMTP Mail Transfer

25

 WHOIS service

43

 Name server (DNS)

53

 HTTP (Web server)

80

 POP Protocol (for email)

110

 POP over SSL

995

 MySQL Server

3306

 rpcbind

111

 rndc

953

 IMAP Protocol (for email)

143

 IMAP Secure

993

 HTTP Secure

443

 Squid Proxy

3128

 MysQL Server

3306

 Webmin

10000

LDAP

389


Delay in SSH Login Prompt


You may came across this situation. At the time of logging in the shell prompt using SSH, 

               - Connection will be taking a fraction of second
               - After/While entering the Password its taking more time to provide the shell prompt.
             
To fix this issue:

This is related to DNS. We have to change dns related entries in ssh config file to reduce this delay.

Note : 
     Be careful when doing this on production servers. 
     This activity may disconnect all the users from the system who are logged in to that machine using SSH. 

By default UseDNS option in this file is disable. We have to uncomment this option and then edit this entry to no. As below.. 

# vi /etc/ssh/sshd_config 

Just search for UseDNS.. 

                     #UseDNS yes  

Change that to, (Simply Uncomment it)

                      UseDNS no 

save and exit the file and then just reload ssh service to take effect what ever changes we did.. 

# service sshd reload
  
Now try to login and observe, delay will be reduced.

Please post your comments on this..

Password-less SSH Login

Here is the procedure to establish trust relationships between Unix boxes for a particular user using SSH. it can be helpful in script file transfers and other admin activities. 

Here i am using the source server as server1 and destination server as server2 as example.

Steps:

1.Login as user whom you want to login without password on server1

2.Type: ssh-keygen -t rsa

      Note: If you do not want to be prompted, leave passphrase blank

            The default directory for SSH keyfiles is <USER_HOME_DIRECTORY>/.ssh/

4.copy the contents of <USER_HOME_DIRECTORY>/.ssh/id_rsa.pub (there should only be one line)

5.Place this line on server2,in <USER_HOME_DIRECTORY>/.ssh/authorized_keys

that's it, you should now be able to ssh/sftp/scp from server1 to server2 without being prompted for a password!


Note: Make sure, "RSAAuthentication yes" in your /etc/ssh/sshd_config file. On many Linux installations this setting is commented out in a default install


Please dont forget to leave your comments.

Disable SSH root login

Providing direct login access to root via SSH is not a good practice. Administrators should use sudo to switch to root after logged in as themselves. this will helpful in auditing in terms of security.

Here is the step by step procedure to disable/deny direct root login via SSH

1. Login to the server as Root

2. Edit /etc/ssh/sshd_config

    Look for the line,

  PermitRootLogin=Yes
 
and then change the value of it to,

  PermitRootLogin=No 

3. Restart the sshd service and make sure its turned on

    service sshd restart        or     /etc/init.d/sshd restart
   
    service sshd status


Please don't forget to post your comments

Delete old log files in Linux



Here is the quick command to delete the log files which are older than specified time in Linux


Be careful as these are powerful commands which blow away files completely.
  

Note: 
To find files modified more than 5 days use -mtime +5 and files modified less than 5 days use -mtime -5

Use -ctime parameter to find out the created time

To List and Delete log files older than 10 days, execute the following commands
 

find /var/log/ -name *.log -mtime +10 -exec ls -tl {} \; 
find /var/log/ -name *.log -mtime +10 -exec rm -f {} \;

Disk Quotas in Linux - Quick HOWTO

Here is the simple quick guide to setup disk quotas in Linux. Please post your comments

 Uses of Disk quotas:

  1. Limits disk usage (blocks or inodes)

  2. Tied to file systems (set on a per file system basis)

  3. Can be configured for users and groups

 

Steps to enable quota support:

 1. Enable quota support per file system in: /etc/fstab

  Add  defaults,usrquota,grpquota in end of the line for the file system you want enable quota

 2. Remount the file system(s)

  a. mount -o remount /

  b. use 'mount' to confirm that 'usrquota,grpquota' support are enabled

 3. Create quota database files and generate disk usage table

  a. quotacheck -mcug / - this creates /aquota.user & /aquota.group

  b. quotacheck -mavug

 4. Assign quota policies

  a. edquota username - set blocks/inodes soft_limits hard_limit

     edquota student1 - sets quotas for user 'student1'

     export EDITOR=nano - to have edquota default to 'nano' editor

5. Check quotas

  a. quota username

     quota student1 

Note: place 'quotacheck -avug' in /etc/cron.*(hourly,daily) 

6. Report on usage

  a. repquota -a - this reports on usage

 Note: The blocks are measured in 1K increments. i.e. 20000 blocks is roughly 20MB

FTP Server (VSFTPD) in Linux - Quick Notes



VSFTPD - Very Secure File Transfer Protocol Daemon

Features:
 1. FTPD
 2. Chroot jail
 3. anonymous and local-user auth
 4. Rate-limiting
To  Install 'vsftpd'
   yum -y install vsftpd or  rpm -ivh <VSFTPD_PACKAGE.rpm>

To Start the server
   service vsftpd start

To verify the status of port and listening
 
netstat -ntlp | grep 21

Configure service to start when system boots into multi-user runlevel
  a. chkconfig vsftpd on
  b. chkconfig --list vsftpd

To Connect to the FTPD service:
  a. Use web browser, which defaults to anonymous
  b. Use standard FTP client, as anonymous
  c. setsebool -P ftp_home_dir=1 - permits users access to their home directory
  d. service vsftpd restart - for changes to take effect

Edit the Configuration file /etc/vsftpd/vsftpd.conf for various options.

To Chroot jail local users & disable 'anonymous' access
  a. chroot_local_user=YES - this jails users
  b. service vsftpd restart - for changes to take effect
  c. test connectivity as 'anonymous' and 'non-anonymous' users

 To Enable IPv6 listener:
  a. listen_ipv6=YES - DO NOT USE WITH 'listen=YES(IPv4)'
 
To Restrict 'non-anonymous' user's transfer rate
   local_max_rate=1000 - restricts connections to 1000/bps (1K/s)

Extend Logical Volume online in Linux


To extend a logical volume, expand the volume group if necessary, and then use following steps:

Either specify the final size of the logical volume:

lvextend --size <size> /dev/<vgname>/<lvname>

or specify how much to expand the logical volume:

lvextend --size +<additional _size> /dev/<vgname>/<lvname>

Instead of specifying the size or amount of space to add in gigabytes, it is also possible to use the -l <num_of_le> to provide the number of logical extents

After extending the logical volume, the filesystem on it must be expanded as well.

If it is an ext3 filesystem (default filesystem for Red Hat Enterprise Linux), it can be expanded while it is still mounted (also known as online).

To do so, execute the following as root:

resize2fs /dev/<vgname>/<lvname>

AIX File Systems - Quick HOWTO


Filesystems

hd1  -------------  /home
hd2  -------------  /usr
hd3  -------------  /tmp
hd4  -------------    /           
hd5  -------------  BLV (Boot Logical Volume)
hd6  ------------   Paging space
hd8  ------------  JFS2 log
hd9var ---------   /var
hd10opt ------    /opt

Remove mount point entry and the LV for /my_mount_point
      rmfs /my_mount_point (Add -r to remove mount point)

Grow the /var lesystem by 1 Gig
       chfs -a size=+1G /var

Grow the /var lesystem to 1 Gig
      chfs -a size=1G /var

Find the le usage on a file system
      du -smx /home

List lesystems in a grep-able format
      lsfs

Get extended information about the /home file system
      lsfs -q /home

Create a log device on datavg VG
      mklv -t jfs2log -y datalog1 datavg 1

Format the log device just created
      logform /dev/datalog1

AIX Crash Recovery Procedure


This is the step by step guide to recover AIX OS from the Tape Backup (MKSYSB Backup)

Ensure the Following:

a. Ensure the mksysb backup which will be used for the crash recovery process.
b. Ensure AIX 5.3 CD set is available. AIX 5.3 CD1 will be used for recovery.

Steps to be followed for recovery are as follows:

1. Place AIX 5.3 VOL 1 CD and  Shutdown the machine

2. Disconnect the FC cables from the HBA on servers (If any) and  mark them properly such that they could be plugged back after restoration.

3. Power on the machine

4. With the first beep enter the SMS menu by pressing F1 or 1

Language selection menu:

Continue to password entry by pressing (3)

Put password

Main menu:

            Select boot option (press 5)

Multi boot menu:

Select install boot device   (press 1)

Select Device type:

Select CD/DVD   (press 3)

Select Media type

Select "list all devices" by pressing 9 and select DVD ROM 

Select Media adapter

                   Select IDE DVD-ROM Drive

# lsdev -Cc cdrom

(cd0 Available 04-08-00 IDE DVD-ROM Drive) 

# lsdev -Cc adapter | grep -i ide0

ide0      Available 04-08  ATA/IDE Controller Device

#

Select Task Menu:

                Select service mode boot

5. Exit SMS menu

                    Press 1 for YES

 6. In Define system console Menu

                 Type F1

                Type 1 for English

 

7. Next, the system will display,

Welcome to BOS Installation and maintenance menu

        Select Start Maintenance Mode for system recovery

Maintenance Menu:

              Install From system Backup

              Choose Mksysb device
             --------------------------------------


Device Name             Path Name

rmt0                            /dev/rmt0



/dev/rmt0   (rmt0 Available 05-08-01-3, 0 Other SCSI Tape Drive)

# lsdev -Cc adapter | grep sisscsia0

sisscsia0 Available 05-08 PCI-X Dual Channel Ultra320 SCSI Adapter

# lsdev -Cc tape

rmt0 Available 05-08-01-3,0 Other SCSI Tape Drive

#

Start Restore


8. After restoration is complete ensure the mount points of rootvg are all mounted.

9. List all LVs & mount points in rootvg

10. Plug the FC cables back into the HBA as before & run the following commands to check the detected disks:


# cfgmgr –v

# lsdev –Cc disk


11. Activate non-root VGs (datavg) to check if they are functioning properly. If yes, mount the LVs in the non-root VGs in their specific mount points & check whether the data is intact. List LVs in non-root VGs & their mount points and check.
   
        If no, import the non-root VGs using importvg command on the relevant disks

# importvg –y datavg hdisk1

       Then, mount the LVs in the non-root VGs in their specific mount points & check whether the data is intact

Configuring NTP on AIX 5L

The following information outlines the steps to configure a basic NTP setup between an NTP client and server on AIX 5L.

On server

Verify that you have a suitable NTP server.

#lssrc –ls xntpd

NOTE: Sys peer should show a valid server or 127.127.1..


Edit /etc/ntp.conf and restart xntpd.


#vi /etc/ntp.conf
Add:
server
127.127.1.0

NTP Uses the configuration that IP 127.127.1.0 means it will verify the Local System Clock as Reference.

Note: Double check that "broadcast client" is commented out.

#stopsrc –s xntpd
#startsrc –s xntpd

NOTE:If the server runs databases, use the –x flag tprevent the clock from changing
 in a negative direction. Enter the followin:

#startsrc –s xntpd –a "-x"

Repeat Step 1 to verify that the server is synched.This process can take up to 12 minutes.


On client:


#ntpdate –d ip.address.of.server

The offset must be less than 1000 seconds for xntpd synch.
If the offset is greater than 1000 seconds, change the time maually on the client and run the ntpdate –d again.


If you get the message, "no server suitable for synchroization found", verify xntpd is running on the server (see above).
Also no firewalls are blocking port 123.


Specify your xntp server in/etc/ntp.conf,


#vi /etc/ntp.conf
(Comment out the "broadcastclient" line and add server ip.address.of.server)

Leave the driftfile and trace file at their defaults.

Start the xntpd daemon:

#startsrc –s xntpd
(Use the –x flag if it is appropriate for your enviroment.)

Uncomment xntpd from /etc/rc.tcpip so it will start on reboot.

#vi /etc/rc.tcpip
Uncomment the following line:

start /usr/sbin/xntpd "$src_running"
If using the –x flag, add "-x" to the end of the line.
You must include the quotes around the -x.

Verify that the client is synch'ed.

#lssrc –ls xntpd

NOTE: Sys peer should display the IP address or name of your xntp server.
This process may take up to 12 minutes.

Differences: VMWARE Player, VMWARE Workstation and ESX Server


I Listed the differences between VMWARE player, VMWARE Workstation/server and VMWARE ESX Server. I have provided the information as well as i know. If anyone having questions, Please comments, Please correct me  if i missed something. 

VMWare Player
VMware Workstation & Server
VMware ESX Server
With VMware Player you can only run pre-created Virtual Machine, either you create it with VMware Workstation/Server or you download it from VMware Virtual Appliance Marketplace 
You can create, Play, Modify Virtual Machines
You can create, Play, Modify Virtual Machines
You cannot create or modify a virtual Machine using VMPlayer. You can run only
You can create, modify any number virtual machines up to your need
You can create, modify monitor virtual machines using VSphere client
Its free of cost
Licensed
Licensed
Need to be installed on OS Desktops like Windows, Linux, MAC
Need to be installed on OS Desktops  like Windows, Linux, MAC
This will be installed as OS. Other Operating systems will be hosted here as virtual machine. VMware ESX server itself is an OS. On top of it, other OS like Windows Server, Linux will be installed
Desktop Use, for development, testing, QA Etc..
Desktop Use, for development, testing, QA Etc..
Used for production servers use
No extra features
Having features snapshots, screen recordings, cloning etc.
Having several features like physical to virtual convertor etc.
NA
CPU and Memory support up to the editions like Workstation or server
CPU and Memory support up to licensing. (Min 2 CPU's and 8GB RAM)