Monday, October 1, 2012

df –h mismatch size in linux


df –h mismatch size in linux


while I was running df to check the disk space I found that there is huge different in free size.
# df -h /dev/sda2
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              90G   79G  7.3G  92% /

I noticed that there was a huge gap between the total space (79 used + 7.3 available = 88.3) and the actual size of the file system. According to me this was due to the reserved block count, which is set to five percent by default in ext2 and ext3 file systems—clearly a legacy from a time where disks were smaller.

# dumpe2fs /dev/sda2|grep -i 'reserved block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Reserved block count:     1196559

# dumpe2fs /dev/sda2|grep 'Block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Block count:              23931180

# echo 'scale = 2; 1196559 / 23931180'|bc
.05

I changed the reserved block count with tune2fs:
# tune2fs -m 1 /dev/sda2
tune2fs 1.40.8 (13-Mar-2008)
Setting reserved blocks percentage to 1% (239311 blocks)
# dumpe2fs /dev/sda2|grep -i 'reserved block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Reserved block count:     239311

# df -h /dev/sda2
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              90G   79G   11G  88% /

Now, the reserved blocks take up roughly 934 MiB; I’ve freed 3.7 GiB with this little file system tweak. 

 use at your own risk :)

Friday, September 14, 2012

Solaris: Check hme ethernet link speed, duplex, and status


When troubleshooting networking issues, it is often helpful to determine the state of an ethernet interface. Solaris offers access to many configurable networking parameters through ndd.

To determine the ethernet interface link status, duplex, and speed on hme0, run the following commands as superuser:
ndd -set /dev/hme instance 0 ndd -get /dev/hme link_status
ndd -get /dev/hme link_mode
ndd -get /dev/hme link_speed

If you have only one ethernet interface, you can leave out the instance command. Otherwise, you can specify the hme instance number there. The results of the next three commands are either 1 or 0. In each case, the value means:
link_status: 0=down 1=up
link_mode: 0=half duplex 1=full duplex
link_speed: 0=10Mbps 1=100Mbps

Monday, September 3, 2012

Sudo/setfacl/getfacl –Info examples


How to assign rights to start/stop/reload  Application services like httpd,mysql/sendmail via sudo and using assigning rights via getfacl/setfacl

1.    Log on to server XXX server
2.    Assign  rights to normal Account user in linux: baskar + JJ:
* Rights for Fetchmail & Procmail to change/stop/start the application/
*  Rights to stop/start httpd  and  mysqld

  1. Edit sudo file using visudo and append the line  below end of the file and save the file and close it.
baskar   ALL=NOPASSWD:/etc/init.d/fetchmail stop,/etc/init.d/fetchmail start, /etc/init.d/sendmail stop,/etc/init.d/sendmail start,/etc/init.d/httpd stop, /etc/init.d/httpd start,/etc/init.d/mysqld stop,/etc/init.d/mysqld start
jj   ALL=NOPASSWD:/etc/init.d/fetchmail stop ,/etc/init.d/fetchmail start, /etc/init.d/sendmail stop,/etc/init.d/sendmail start,/etc/init.d/httpd start,/etc/init.d/httpd stop, /etc/init.d/mysqld stop,/etc/init.d/mysqld start

4.Using getfacl/setfacl we can assign the rights to individual user

 Rights to change files in /backup/baskar  and  /backup/jj
#setfacl -m user: baskar:rwx /opt/RT, /opt/RT
#setfacl -m user: jj:rwx /backup/baskar, /backup/jj

* Rights to change files in  /var/www/html/*
#setfacl -m user: baskar:rwx  /var/www/html/
#setfacl -m user: jj:rwx  /var/www/html/


* Rights to read files in /var/log/
#setfacl -m user: baskar:r /var/log
#setfacl -m user: jj:r /var/log

  1. Create separate group like baskarjjrwx and baskarjjr and assign the rights accordingly
setfacl -m group: baskarjjrwx:rwx /var/www/html/  /backup/baskar /backup/jj
setfacl -m group: baskarjjr:r /var/log

Wednesday, July 25, 2012

Unmount filesystem when device is busy


When you unmount a filesystem, you may get "device is busy error" sometimes.  Using the following steps, you can unmount safely.


# umount  /testsrv1/rman
umount: /testsrv1/rman: device is busy
umount: /testsrv1/rman: device is busy


# fuser -m /testsrv1/rman
/testsrv1/rman:         31477c


# ps -eaf | grep 31477
oracle  31477 31448  0 09:52 pts/0    00:00:00 /bin/ksh



# df -h /testsrv1/rman
Filesystem            Size  Used Avail Use% Mounted on
testsrv1:/miszpool/mis
                      2.5T  1.9T  560G  78% /testsrv1/rman


# ps -eaf | grep 31477
oracle  31477 31448  0 09:52 pts/0    00:00:00 /bin/ksh


# ps -eaf | grep 31448
dbauser1 31448 31447  0 09:51 pts/0    00:00:00 -ksh
oracle  31477 31448  0 09:52 pts/0    00:00:00 /bin/ksh


# kill -9 31477
# ps -eaf | grep 31448
dbauser1 31448 31447  0 09:51 pts/0    00:00:00 -ksh


# umount -f /testsrv1/rman


# mount /testsrv1/rman


# df -h /testsrv1/rman
Filesystem            Size  Used Avail Use% Mounted on
testsrv1:/miszpool/mis
                      2.5T  1.9T  560G  78% /testsrv1/rman

Thursday, June 14, 2012

How to generate HP Array Diagnostic Report (ADU Report) in Linux



We need to understand what is an Array, RAID and Array Configuration Utility (ACU). In the case of hardware RAID, multiple hard disk drives are combined to one logical drive and data is distributed across multiple hard drives. You can have RAID levels like RAID 0, RAID 1, RAID 5 etc.

I hope you are familiar with Array Configuration Utility. Using Array Configuration Utility, we can generate Array Diagnostics report (ADU).  ADU report is used for troubleshooting issues related to Hard drives, Smart Array Controller, Array Accelerator and Cache battery etc.
Please be informed that ADU report will not collect data content of logical/Physical drives. It only captures hardware information hence all of your data information is secured. ADU report could not capture File system types, contents, Software RAID information, Partition types, sizes etc.
ADU report can give consolidated view of any error or warning conditions encountered across the Array/RAID. ADU report also provides extensive information about all the storage devices.Information such as Device status, Firmware version number, RAID Configuration, Physical drive errorflags are available in ADU report.

In this article, we will learn how to generate ADU report using Array Configuration Utility (ACU). If you are not sure how to open ACU on your Server, then please read our article Guide: Configure RAID using HP ACU on your HP Server” before you proceed. ACU can be launched within OS or from HP SmartStart CD. More information is available in above said guide.




Well, generating HP ADU report is quite simple and easy in Windows Operating System. However, when it comes to linux, everything is based on the CLI version, so here’s how to generate HP Array Diagnostic Report in Linux.
The name of the application is HP Array Configuration Utility CLI and executable name is hpacucli, so if not installed, this needs to be downloaded from hp.com download page and installed. (Refer my Note at the bottom on how to download the program). Also note that older versions of HP ACU (Versions older than 8.3) may not have the diagnostic features in it, in this case, you will have to update the utility to a newer version OR use the hpaducli  (HP Array Diagnostic Utility CLI) and NOT hpacucli (HP Array Configuration Utility CLI) which would have already been installed in the system.
Here’s the commands:
Generating Array Diagnostic report using the HPADUCLI:
Type: hpaducli -f OutputFileName.zip in the Linux prompt




Fig: hpaducli command



The “OutputFileName” could be any name you wanted to specify. In the picture above, i used adutestfile as the filename. The output would generally be saved in the /tmp folder. To get the generated txt file, type cd /tmp in the root and type ls to browse the folder.

Generating Array Diagnostic Report using the HPACUCLI
Type: hpacucli ENTER
If the hpacucli program is installed, it will take you inside the hpacucli program
Type: ctrl all diag file=/tmp/ADUReport.zip ENTER
Fig: hpacucli
The above command generate the HP Array Diagnostic report in a .zip format. The contents of the zip file depends on the version of HP ACU version used.You may also use the one line command to generate the report as under:
hpacucli ctrl all diag file=/tmp/ADUReport.zip




That is it, now you have generated the Array Diagnostic report, how do you extract it?
If unzip is installed you can simply type unzip filename.zip which should unzip the file for you.

Note: How to download the HP Array Configuration Utility CLI for Linux
1. Go to hp.com, click support & drivers at the top.
2. On the (green) box where it says Drivers & Software type the name of the Proliant server, eg.DL380 G7.
3. You will get many results out of which select the “HP Prolaint DL380 G7 Server
4. Choose the Operating System.
5. Next, you are at the actual download page, search for HP Array Configuration Utility CLI
6. Download and install that file

Friday, April 20, 2012

RHEL-to-Solaris compare

Shutdown
RHEL
Solaris
shutdown -h now (or) poweroff
shutdown -y -g0 -i5
reboot
reboot (or) shutdown -y -g0 -i6
halt
halt
Kernel
RHEL
Solaris
/sbin/lsmod
modinfo
/sbin/insmod
modload
/sbin/rmmod
modunload
scanpci
/usr/X11/bin/scanpci (or) prtconf -v
Printing
RHEL
Solaris
lp (or) lpr
lp (or /usr/ucb/lpr)
lpstat (or) lpq
lpstat (or /usr/ucb/lpq)
Services
RHEL
Solaris
/sbin/service --status-all
svcs -a
/sbin/service sendmail stop
svcadm disable sendmail
/sbin/service sendmail start
svcadm enable sendmail
/sbin/service sendmail status
svcs sendmail
/sbin/chkconfig --list
svcs -a
/sbin/chkconfig --add /etc/rc3.d/f00
svccfg import f00.xml
/sbin/chkconfig sendmail on
svcadm enable sendmail
Monitoring
RHEL
Solaris
top
prstat
cat /proc/cpuinfo
psrinfo -v
cat /proc/meminfo
prtconf
NFS
RHEL
Solaris
exportfs
exportfs (or) share
(edit /etc/exports)
share /home
(edit /etc/exports)
unshare /home
Networking
RHEL
Solaris
/sbin/mii-tool
ndd (or) /sbin/dladm show-dev
ifconfig
ifconfig
/sbin/ethtool
ndd
/sbin/dhclient
dhcpagent
iptables
ipfilter
Storage
RHEL
Solaris
fdisk
fdisk (and) format
parted
format
mkfs -t ext3 /dev/hda1
mkfs -F ufs /dev/rdsk/c0t0d0s0
cdrecord dev=2,0 f00.iso
cdrw -i f00.iso
tar xfvj f00.tar.bz2
/usr/sfw/bin/gtar xfvj f00.tar.bz2
lvm/pv*/lv*/vg*
meta*
Dev
RHEL
Solaris
(edit /etc/ld.so.conf)
crle
gcc
/usr/sfw/bin/gcc
ld
/usr/ccs/bin/ld