Admins eHow SysAdmin Tips & Tricks

October 24, 2012

The proper way to benchmark disk write performance in Linux

Filed under: CentOS,Debian,linux — Tags: , , , , — admin @ 7:46 am
dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync

The result is something like this :
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 1.43334 s, 375 MB/s

October 14, 2012

How to enable AHCI support for Windows on an iMac, MacBook or etc

Filed under: Apple — Tags: , , , , , , — admin @ 9:18 am

Apple does all the dirty tricks to show the iSheeps that Apple is a superior brand and provides superior performance compared to competition, the last one I found is that it disables AHCI support for Windows on its hardware. By disabling AHCI (which you have already paid for it and Apple hardware has this feature) it forces Windows to use ATA controller disk drivers which is considerably slower than AHCI and has less features. for example you wont have TRIM support on your SSD disk on your Windows.
By doing so, Apple gives you this feeling that Windows is slower than Mac OSX on the same hardware.
Hopefully there is a workaround for this fraud of Apple. You will need to modify the Master Boot Record of your Windows drive.
This workaround only works for Macs with Intel disk controllers. If you have Nvidia chipset, it will not work for you. You may confirm it in device manager of Windows.
First step is to make sure windows tries to load AHCI drivers after AHCI is enabled in boot loader. if you miss this step you will get a BSOD on booting windows and you will need to restore old MBR for windows too boot up.
Open your Windows registry editor and make sure “Start” Value in the following keys are set to 0.

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Msahci
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\IastorV
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Iastor

Also we need the modified MBR which you can download from here : patchedcode.bin
Put the patchedcode.bin on a USB stick which we can use later.
OK, We are done in Windows. Now we need to boot using a Linux Live CD or MacOSX Install Disk. both will work.
Put the bootable CD or USB stick into your computer and reboot.
When you hear the boot sound (the white screen appears) hold down the option (alt) key. you should get the option to boot from CD or USB stick.
Boot from CD or USB stick and Open a Terminal Window.
First lets get a backup from current MBR so in case of any problems we can roll back to it.
Also please note I am assuming your windows disk is /dev/disk0. if yours is different you may need to change it.
Put in your USB stick, change directory to it and run the following command :

dd if=/dev/disk0 of=backup.bin bs=512 count=1

it will make a backup from your MBR to backup.bin
now it is time to write the new MBR to disk :

diskutil umountdisk /dev/disk0
dd if=patchedcode.bin of=/dev/disk0 bs=440 count=1

All done ! now reboot into windows :

shutdown -r now

In Windows you should see windows installs the new AHCI drivers. also you may check that by looking into device manager.
Also I recommend you to download and install “Intel Matrix Storage Manager” to update your AHCI drivers to intel’s ones.
If anything goes wrong, you can revert back to old MBR by following commands in Terminal :

diskutil umountdisk /dev/disk0
dd if=backup.bin of=/dev/disk0 bs=440 count=1

October 12, 2012

How to install transmission 2.71 on Debian 6.0 Squeeze

Filed under: General — admin @ 6:41 am

Installing transmission 2.71 on Debian 6 is a little tricky and is not as straight forward as installing by apt-get.
Here is how you can do it.

First you need to manually install libevent 2.0 :

apt-get install make gcc
wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz 
tar zxvf libevent-2.0.20-stable.tar.gz 
cd libevent-2.0.20-stable
./configure
make
make install

then some prerequisite packages for later installation :

apt-get install libssl-dev pkg-config libcurl4-openssl-dev intltool tar bzip2

now it is time to download and configure transmission :

wget http://download.transmissionbt.com/files/transmission-2.71.tar.bz2
tar jxvf transmission-2.71.tar.bz2
cd transmission-2.71
./configure --enable-lightweight --enable-daemon

now if you try to compile (make) the package you will get the following error :

tr-utp.c:65: error: conflicting types for ‘UTP_Write’
../third-party/libutp/utp.h:116: note: previous declaration of ‘UTP_Write’ was here
make[1]: *** [tr-utp.o] Error 1
make[1]: Leaving directory `/root/transmission-2.71/libtransmission’
make: *** [all-recursive] Error 1

in order to fix this error open this file in transmission directory :

nano ./third-party/libutp/utypes.h

and comment following lines :

// #ifndef __cplusplus
// typedef uint8 bool;
// #endif

and add following line just after above lines :

 
#ifndef __cplusplus
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else
typedef uint8 bool;
#endif
#endif

save file and exit. return to transmission root directory and make and install.

make
make install

September 5, 2012

How to verify mod_deflate, gzip working ?

Filed under: Apache — Tags: , , , — admin @ 12:42 pm

Lets say you have enabled compression in your web server by mod_deflate, gzip and now want to verify if the content is really compressed, here is how to do it :

1.Easy way :
Go to this link : http://www.gidnetwork.com/tools/gzip-test.php
Enter your website URL inside “Web Page URL” and click on “Check”

2.Technical way :
Make sure curl is installed on your server. then run following command (change yoursite.com to your own domain) :

curl -I -H 'Accept-Encoding: gzip,deflate' http://yoursite.com

what you should look for in output is this line :

Content-Encoding: gzip

if it is not there, the content is not compressed.
here is the output for AdminseHow :

root@x~# curl -I -H 'Accept-Encoding: gzip,deflate' http://www.adminsehow.com

HTTP/1.1 406 Not Acceptable
Server: ApacheBooster/1.3
Date: Wed, 05 Sep 2012 12:39:22 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 8740
Connection: keep-alive
X-Pingback: http://www.adminsehow.com/xmlrpc.php
Vary: Accept-Encoding,Cookie,User-Agent
X-Powered-By: W3 Total Cache/0.9.2.4
Content-Encoding: gzip
Last-Modified: Wed, 05 Sep 2012 12:39:22 GMT
X-Cacheable: YES
Accept-Ranges: bytes
X-Varnish: 1984902025
Via: 1.1 varnish
age: 0
X-Cache: MISS

The content is compressed. YAY 😀
PS : I know the response is “HTTP/1.1 406 Not Acceptable”, it is because of mod_security installed on server which prevents such simple automated requests to be served. but it doesn’t matter for our test.

September 3, 2012

Install SNMP on Debian

Filed under: Debian — Tags: , , , — admin @ 10:15 am

The following easy steps will install snmp daemon on your Debian server :

apt-get install snmpd snmp

now snmpd simple configuration ( change SECRET_NAME to a complex string ) :

echo rocommunity SECRET_NAME > /etc/snmp/snmpd.conf

restart snmpd :

/etc/init.d/snmpd restart

last step to check snmpd is working ( change SECRET_NAME to the string you have chose before ) :

snmpwalk -v 1 -c SECRET_NAME -O e 127.0.0.1

you should get an output like below :

iso.3.6.1.2.1.1.1.0 = STRING: "Linux debian 2.6.32-5-686 #1 SMP Sun May 6 04:01:19 UTC 2012 i686"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10
iso.3.6.1.2.1.1.3.0 = Timeticks: (7026) 0:01:10.26
iso.3.6.1.2.1.1.4.0 = STRING: "root"
iso.3.6.1.2.1.1.5.0 = STRING: "debian"
iso.3.6.1.2.1.1.6.0 = STRING: "Unknown"
iso.3.6.1.2.1.1.8.0 = Timeticks: (0) 0:00:00.00
iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.10.3.1.1
iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.11.3.1.1
iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.15.2.1.1
iso.3.6.1.2.1.1.9.1.2.4 = OID: iso.3.6.1.6.3.1
iso.3.6.1.2.1.1.9.1.2.5 = OID: iso.3.6.1.2.1.49
iso.3.6.1.2.1.1.9.1.2.6 = OID: iso.3.6.1.2.1.4
iso.3.6.1.2.1.1.9.1.2.7 = OID: iso.3.6.1.2.1.50
iso.3.6.1.2.1.1.9.1.2.8 = OID: iso.3.6.1.6.3.16.2.2.1
iso.3.6.1.2.1.1.9.1.3.1 = STRING: "The SNMP Management Architecture MIB."
iso.3.6.1.2.1.1.9.1.3.2 = STRING: "The MIB for Message Processing and Dispatching."
iso.3.6.1.2.1.1.9.1.3.3 = STRING: "The management information definitions for the SNMP User-based Security Model."
iso.3.6.1.2.1.1.9.1.3.4 = STRING: "The MIB module for SNMPv2 entities"
iso.3.6.1.2.1.1.9.1.3.5 = STRING: "The MIB module for managing TCP implementations"
iso.3.6.1.2.1.1.9.1.3.6 = STRING: "The MIB module for managing IP and ICMP implementations"
iso.3.6.1.2.1.1.9.1.3.7 = STRING: "The MIB module for managing UDP implementations"
iso.3.6.1.2.1.1.9.1.3.8 = STRING: "View-based Access Control Model for SNMP."

July 16, 2012

How to auth Squid by Radius through PAM in Debian

Filed under: Debian — Tags: , , , , , — admin @ 9:20 am

install libpam-radius-auth

apt-get install libpam-radius-auth

open /etc/pam_radius_auth.conf

nano /etc/pam_radius_auth.conf

and add the following lines into it. Your_IP and PORT are the IP address and Port of Radius sever. SecretKey is the Secret of radius server. 3 is the timeout in seconds.

# server[:port] shared_secret      timeout (s)
YOUR_IP:PORT SecretKey 3

Change the permissions :

chown root /etc/pam_radius_auth.conf
chmod +r /etc/pam_radius_auth.conf

create /etc/pam.d/squid :

nano /etc/pam.d/squid

and add the following lines :

auth sufficient pam_radius_auth.so
account sufficient pam_radius_auth.so

Now install Squid if you have not installed it yet :

apt-get install squid

Lets try and see if Squid PAM works successfully through Radius auth, run the following command and enter username and password with a space between them :

/usr/lib/squid/pam_auth
username password
OK

OK means radius server has accepted the authentication details. ERR means there is a problem.
Now configure Squid to use pam_ath, open /etc/squid/squid.conf :

nano /etc/squid/squid.conf

Add the following lines to the begging of the file :

auth_param basic program /usr/lib/squid/pam_auth
auth_param basic children 5
auth_param basic realm REALM
auth_param basic credentialsttl 2 hours

Add following line in acl section :

acl password proxy_auth REQUIRED

Add following line before http_access deny all :

http_access allow password

April 17, 2012

How to create a mirror of a site using wget

Filed under: General,linux — Tags: , , , — admin @ 7:33 am

First you need to make sure you have the latest version of wget, some distros are still being released with older versions of wget which has some bugs regarding mirroring functionality. currently the latest version is 1.13.4, so if you don’t have the latest version, you can download and build it from following link :

ftp://ftp.gnu.org/gnu/wget/

after building the wget, make sure the latest version is being used :

wget -V

output :

GNU Wget 1.13.4 built on linux-gnu.

+digest +https +ipv6 -iri +large-file +nls -ntlm +opie +ssl/gnutls 

Wgetrc: 
    /usr/local/etc/wgetrc (system)
Locale: /usr/local/share/locale 
Compile: gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc" 
    -DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib -O2 
    -Wall 
Link: gcc -O2 -Wall -lgnutls -lgcrypt -lgpg-error -lz -lrt ftp-opie.o 
    gnutls.o ../lib/libgnu.a 

Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.

OK, you are good to go now, just execute the following command and relax 🙂

wget -mkp -e robots=off http://site

April 11, 2012

My favorite smartphone wallpapers

Filed under: Android,General — Tags: , , , , , — admin @ 6:36 pm

These are my favorite wallpapers on my SGSII, I hope you enjoy them 🙂

You can download them here : SGSII-Wallpapers

April 7, 2012

How to make (remount) system partition writable in android

Filed under: Android — Tags: , , , , , — admin @ 7:51 am

Very useful command which should work on all versions of android :

grep " /system " /proc/mounts | awk '{system("mount -o rw,remount -t "$3" "$1" "$2)}'

March 19, 2012

Simple Timer Utility

Filed under: General — Tags: , , , , — admin @ 6:15 pm

This is another utility which I wrote for myself use, it is a simple countdown timer which beeps when it reaches zero.
You can download it here : Timer

« Newer PostsOlder Posts »

Powered by WordPress