Linux Scroll

Just another WordPress.com site

Category Archives: centos

Rescan new SCSI bus in linux

To detect new SCSI disk/dev in linux:

# echo "- - -" > /sys/class/scsi_host//scan

# fdisk -l

To detect new SCSI fibre channel disk/LUN in linux:

# echo "1" > /sys/class/fc_host/host#/issue_lip

Script similar to hp_rescan:

#!/bin/bash

# $Id: rescan_hba.sh 48 2008-03-11 12:37:48Z ajo $

# This script will rescan all found FC HBAs for (new) LUNs
# Beware that it will generate failover events (in multipathd for
# instance)

if [ -f /usr/sbin/hp_rescan ]
then
echo "hp_rescan found - use that instead"
exit 0
fi


for host in $(ls -d /sys/class/fc_host/host*)
do
echo "Rescanning $host"
echo 1 > /sys/class/fc_host/$host/issue_lip
sleep 5
echo "- - -" > /sys/class/scsi_host/$host/scan
done
Advertisements

Centos add persistence static route

Static route configuration file:

/etc/sysconfig/network-scripts/route-interface file

Static route conf file for eth0:

/etc/sysconfig/network-scripts/route-eth0

IP Command Arguments Format
The following is a sample route-eth0 file using the IP command arguments format. The default gateway is 192.168.1.1, interface eth0. The two static routes are for the 10.10.10.0/24 and 172.16.1.0/24 networks:

default 192.168.1.1 dev eth0

10.10.10.0/24 via 192.168.1.1 dev eth0
172.16.1.0/24 via 192.168.1.1 dev eth0

Network/Netmask Directives Format
The following is a sample route-eth0 file using the network/netmask directives format. The default gateway is 192.168.1.1, interface eth0. The two static routes are for the 10.10.10.0/24 and 172.16.1.0/24 networks:

ADDRESS0=10.10.10.0

NETMASK0=255.255.255.0
GATEWAY0=192.168.1.1
ADDRESS1=172.16.1.0
NETMASK1=255.255.255.0
GATEWAY1=192.168.1.1

The 10.10.10.0/24 and 172.16.1.0/24 networks would use the default gateway anyway.

Fedora install flash player

Install flash player in Fedora:

$ rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm

$ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
$ yum check-update

32-bit:

$ yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl

64-bit:

# yum install flash-plugin nspluginwrapper.x86_64 nspluginwrapper.i686 \

alsa-plugins-pluseaudio.i686 libcurl.i686

Swap

(From Centos Documentation)
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.

Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.

So, if:

M = Amount of RAM in GB, and S = Amount of swap in GB, then

If M < 2

S = M *2
Else
S = M + 2

Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.

For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).

Extract rpm deb packages

Extract rpm package:

$ rpm2cpio installer.rpm | cpio -idv

Extract deb package:

$ dpkg-deb -x installer.deb ~/Desktop/

Show RPM packages architecture

Show RPM packages architecture:

su -c 'echo "%_query_all_fmt %%{name}-%%{version}-%%{release}.%%{arch}" >>  

/etc/rpm/macros'

Show architecture for installed rpm:

# rpm -q --queryformat "%{name}.%{arch}\n" glibc-debuginfo-2.9-13.2

YUM – Yellow Dog Updater

YUM use in Redhat, Fedora, Centos. YUM is powerful software utility used to automatically update and install/remove rpm packages.

Keep the Yum cache for future use:

$ vi /etc/yum.conf

keepcache=1

Yum cache directory:

/var/cache/yum 

Yum install fastest mirror:

$ yum install yum-fastestmirror

Only install security update:

$ yum install yum-security

$ yum --security update

Skip broken dependency:

$ yum install yum-skipbroken

$ yum --skip-broken update

Lists the packages that are not installed but available:

$ yum list php

Lists updates that are available for the installed packages:

$ yum list updates php

Lists all the installed packages:

$ yum list installed php

Install php:

$ yum install php

Remove php:

$ yum remove php

Update php:

$ yum update php

Info php:

$ yum info php

yum whatprovides [file name]:

$ yum whatprovides /usr/bin/php

Group install:

$ yum groupinstall "Development Tools"

$ yum groupinstall "Development Libraries"

Group list:

$ yum grouplist "Development Tools"

Group remove:

$ yum groupremove "Development Tools"

RPM – RPM Package Manager

RPM use in Redhat, Fedora, Suse, Centos.

Using RPM to Install Packages:

$ rpm -ivh package.rpm

* i – install
* v – verbose
* h – hash
–force

Using RPM to Upgrade Packages:

$ rpm -Uvh package.rpm

* U – Upgrade

Using RPM to Erase Packages:

$ rpm -ev package.rpm

* e – erase

Using RPM to Query installed Packages:

$ rpm -qa | grep -i package

* q – query
* a – all

Display all recently installed rpm:

$ rpm -qa --last

Display thunderbird installed info:

$ rpm -qi thunderbird

* i – Display detail

Find out what dependencies a rpm file need:

$ rpm -qpR package.rpm 

* p – Package

Verify all installed package:

$ rpm -Va

RPM Database
/var/lib/rpm