Thursday, June 04, 2009
Linux hard drive benchmark & bottleneck testing software suite for performance
Download from official web site or use apt-get to install bonnie++:
# apt-get install bonnie++
Source code installation
Download source code and compile as follows:
$ cd /tmp
$ wget http://www.coker.com.au/bonnie++/bonnie++-1.03a.tgz
$ tar -zxvf bonnie++-1.03a.tgz
$ cd bonnie++-1.03a
$ ./configure
$ make
# make install
How do I use bonnie++?
Simply type bonnie++ or bonnie:
$ bonnie++
OR
$ bonnie"
All about Linux: Boost your hard drive performance in Linux using hdparm
All about Linux: Boost your hard drive performance in Linux using hdparm: "The hdparm program provides two performance testing features that are crucial in letting you know whether or not you are improving performance or not as you tweak along.
# hdparm -Tt /dev/hda1
will show results such as the following before enhancing the performance.
/dev/hda1:
Timing buffer-cache reads: 340 MB in 2.01 seconds = 169.43 MB/sec
Timing buffered disk reads: 30 MB in 3.08 seconds = 9.73 MB/sec
and the results like these after enhancing the performance.
/dev/hda1:
Timing buffer-cache reads: 340 MB in 0.91 seconds = 200.00 MB/sec
Timing buffered disk reads: 30 MB in 1.05 seconds = 19.73 MB/sec
The goal is to see the time in seconds decrease and the MB/sec to increase in the above output.You can do that by using a variety of parameters, invoked one at a time, then rerunning the performance tests to see if things are improving or not.
For example: Begin by setting the operating mode of the interface between the system and the disk drive using one of the following parameters:
* -c0 - Sets operating mode to 16-bits
* -c1 - Sets operating mode to 32-bits
* -c3 - Sets operating mode to 32-bits synchronized
Mode -c1 is usually used for best performance. Mode -c3 is required only for certain chipsets.
# hdparm -c1 /dev"
All about Linux: Boost your hard drive performance in Linux using hdparm
this is a bookmark of hard driver performance testing
Monday, May 04, 2009
useful commands for linux RAID
/dev/sda1 /dev/sdb1 /dev/sdc1
( /dev/md0 raid device name, level=5 raid5, raid-devices=3 three hdd,
/dev/sda1… the hdd)
Then mke2fs it
mke2fs -b 4096 -R stride=8 /dev/md0
Mount it
how to break raid
Fail all the devices, then remove them, then stop the raid. eg
mdadm --stop /dev/md1
mdadm --manage /dev/mdfoo --fail /dev/sdfoo
mdadm --manage /dev/mdfoo --remove /dev/sdfoo
mdadm --manage --stop /dev/mdfoo
mdadm --query --detail /dev/md0 //query detail
mdadm --manage --set-faulty /dev/md1 /dev/sdc2 // force fail to test
mdadm /dev/md1 -r /dev/sdc2 // remove the failed disk
mdadm /dev/md1 -a /dev/sdc2 // set back when recoverred
mdadm --add /dev/md1 /dev/sdb3 // add a partition
mdadm --grow --raid-devices=4 /dev/md1
here is the setting made to NAS
-------------------------------------------------------
root@data df -h
Filesystem Size Used Available Use% Mounted on
rootfs 125.0M 65.3M 59.7M 52% /
/dev/root 125.0M 65.3M 59.7M 52% /
/dev/root 125.0M 65.3M 59.7M 52% /dev/.static/dev
udev 2.0M 76.0k 1.9M 4% /dev
/dev/md0 458.5G 1001.0M 434.2G 0% /home/public
/dev/sde2 229.2G 128.2M 217.4G 0% /media/sde2
tmpfs 251.8M 452.0k 251.3M 0% /var/volatile
tmpfs 251.8M 0 251.8M 0% /dev/shm
tmpfs 251.8M 0 251.8M 0% /media/ram
partition information:
================
root@data:/# fdisk -l
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 30401 244196001 fd Linux raid autodetect
Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 30401 244196001 fd Linux raid autodetect
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 30401 244196001 fd Linux raid autodetect
/dev/sdc2 30402 60801 244188000 83 Linux
Disk /dev/sdd: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 30401 244196001 fd Linux raid autodetect
Disk /dev/sde: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 30401 244196001 fd Linux raid autodetect
/dev/sde2 30402 60801 244188000 83 Linux
RAID detail:
========
root@data:/# mdadm --query --detail /dev/md0
/dev/md0:
Version : 00.91.03
Creation Time : Tue Jan 24 09:15:56 2034
Raid Level : raid5
Array Size : 488391808 (465.77 GiB 500.11 GB)
Device Size : 244195904 (232.88 GiB 250.06 GB)
Raid Devices : 5
Total Devices : 5
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Tue Jan 24 13:31:34 2034
State : clean, recovering
Active Devices : 5
Working Devices : 5
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 64K
Reshape Status : 2% complete
Delta Devices : 2, (3->5)
UUID : bcf1613f:5de00cfa:8880d4eb:30bb47b4
Events : 0.4058
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
2 8 65 2 active sync /dev/sde1
3 8 33 3 active sync /dev/sdc1
4 8 49 4 active sync /dev/sdd1
RAID status:
=========
root@data:/#cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
md0 : active raid5 sdc1[3] sde1[2] sdd1[4] sdb1[1] sda1[0]
488391808 blocks super 0.91 level 5, 64k chunk, algorithm 2 [5/5] [UUUUU]
[>....................] reshape = 2.8% (6997760/244195904)
finish=428.4min speed=9224K/sec
unused devices: <none>
Create linux based wireless AP
Wi-Fi Protected Access version 2 (WPA2) is becoming the de facto standard for securing wireless networks, and a mandatory feature for all new Wi-Fi products certified by the Wi-Fi Alliance. We all know the security weaknesses of its predecessor, WEP; this time they got it right. Here's how to implement the WPA2 protocol on a Linux host and create a secure wireless access point (WAP) for your network.
Most consumer-grade commercial WAPs operate in the same simple manner: they create a bridge between a wired (Ethernet) network interface and a wireless one. That's exactly what we'll do too. The WAP part will be handled by the hostapd daemon, so you must pick a wireless interface it supports. Among the supported NICs are those with Prism 2/2.5/3, Atheros ar521x, and Prism GT/Duette/Indigo chipsets; a list is available on the hostapd homepage, along with links for Linux drivers for each chipset. I have an Atheros AR5212-based PCI card installed on my WAP, which works great with the latest stable version of MADWifi drivers and is supported by hostapd. Although any Pentium (or newer) system will work, some PCI wireless cards require PCI 2.2 to operate, so make sure to check your system's motherboard specifications before buying. You will also need an Ethernet interface that's supported by Linux for connecting your WAP to the LAN; most on-board interfaces will work just fine.
My setup is based on Debian Testing (Etch), but any GNU/Linux distribution with a recent 2.6 kernel will work. The kernel must support 802.1d Ethernet Bridging (CONFIG_BRIDGE) and Wireless LAN (CONFIG_NET_RADIO). Most default stock kernels have these features enabled, but if you prefer to build your own kernel, make sure to include these options. The only other packages you need to install, besides hostapd, are bridge-utils and wireless-tools. Major GNU/Linux distributions offer binary packages for all these programs, but if you prefer to build them from source, you can find more information on their homepages.
Before bridging together the two interfaces we must put the wireless interface (in my case ath0; adjust it to match your setup) in hostap or Master mode. Usually this is as simple as running iwconfig ath0 mode Master, but since wlan support in Linux is not yet standardized, some drivers may need additional configuration. If you have an Atheros-based interface you also need to run the following: wlanconfig ath0 destroy; wlanconfig ath0 create wlandev wifi0 wlanmode ap before the iwconfig command. After that, running iwconfig ath0 will return mode:Master, among others.
Now let's create the bridge. We'll assume that the Ethernet interface is eth0:
ifconfig eth0 0.0.0.0 up ifconfig ath0 0.0.0.0 up brctl addbr br0 brctl addif br0 eth0 brctl addif br0 ath0 And for stopping the bridge, you should run:
ifconfig br0 down ifconfig eth0 0.0.0.0 down ifconfig ath0 0.0.0.0 down brctl delif br0 eth0 brctl delif br0 ath0 brctl delbr br0 You can optionally give an IP address to the br0 interface if you want to access the WAP host from the network, using for instance SSH. Each distribution offers its own way to configure the network; if you use Debian (or any Debian-based distribution, such as Ubuntu) you can wrap up all the previous commands by simply adding the following to your /etc/network/interfaces file:
auto ath0 br0 iface ath0 inet manual pre-up wlanconfig ath0 destroy pre-up wlanconfig ath0 create wlandev wifi0 wlanmode ap post-down wlanconfig ath0 destroy wireless-mode master iface br0 inet manual bridge_ports eth0 ath0 Note that ifupdown handles eth0 automatically, so you don't need a separate stanza for it in /etc/network/interfaces. To verify that the bridge is configured correctly, run brctl show. You should get something like this in return:
bridge name bridge id STP enabled interfaces br0 8000.00032f2481f0 no ath0 eth0 Before starting to mess with hostapd we need a pass phrase for WPA2. As with all passwords, it should be random and thus hard to guess. A nice way to get a random pass phrase is to visit Gibson Research Corp.'s Ultra High Security Password Generator and use the third password it creates -- the one titled 63 random alpha-numeric characters (a-z, A-Z, 0-9). Having a passphrase that includes non-alpha-numeric ASCII characters (e.g. !, @, etc.) might be tempting, but some clients -- namely Windows XP -- don't seem to like them.
Now create a new text file named /etc/hostapd/wpa_psk and paste your pass phrase as:
00:00:00:00:00:00 PASSPHRASE The first part with the zeros means 'match all MAC addresses,' and does exactly that. You can also use different passphrases for each client by appending a new line to the file with each client's MAC address and its passphrase. Make sure that only root has access to that file by running chmod 600 /etc/hostapd/wpa_psk.
Now create a backup of hostapd's main configuration file, /etc/hostapd/hostapd.conf, and keep it as a reference by running mv /etc/hostapd/hostapd.conf /etc/hostapd/hostapd.conf.orig. Create a new hostapd.conf file and paste the following lines into it:
interface=ath0 bridge=br0 driver=madwifi logger_syslog=-1 logger_syslog_level=2 logger_stdout=-1 logger_stdout_level=2 debug=0 dump_file=/tmp/hostapd.dump ctrl_interface=/var/run/hostapd ctrl_interface_group=0 ssid=My_Secure_WLAN #macaddr_acl=1 #accept_mac_file=/etc/hostapd/accept auth_algs=3 eapol_key_index_workaround=0 eap_server=0 wpa=3 wpa_psk_file=/etc/hostapd/wpa_psk wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP stakey=0 Replace the parts in italics with information that matches your setup. If you want to allow only specific clients to connect, remove the # character from the two lines above and copy the MAC addresses of those clients to /etc/hostapd/accept, and make this file accessible only by root (chmod 600). For more information about the options used, read the comments in the backup file you created previously (hostapd.conf.orig).
Start the hostapd daemon (/etc/init.d/hostapd start) and check /var/log/daemon.log to verify that it works. If the daemon does not come up, increase the debug level (option debug= in hostapd.conf) to 4 and try again.
Now if you scan for available wireless networks from a client, you should see your ESSID. To connect to the WAP from a Windows XP SP2 client, you need to install Microsoft's KB893357 patch first, which adds WPA2 support. On a Linux client, install wpa_supplicant and create a configuration file, wpa_supplicant.conf (in Debian, installed in /etc/wpa_supplicant/) like the following:
update_config=1 ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 eapol_version=1 ap_scan=1 fast_reauth=1 network={ ssid="My_Secure_WLAN" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP group=CCMP psk="PASSPHRASE" priority=5 } Again replace the parts in italics to match your setup and run wpa_supplicant -i eth1 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf (replacing eth1 with your wlan interface name and wext with the appropriate driver for your card; run wpa_supplicant without any options for more information). This command starts wpa_supplicant in the foreground and tries to connect to the WAP. If the output looks like the following, you're all set:
Trying to associate with 00:11:22:33:44:55 (SSID='My_Secure_WLAN' freq=0 MHz) Associated with 00:11:22:33:44:55 WPA: Key negotiation completed with 00:11:22:33:44:55 [PTK=CCMP GTK=CCMP] CTRL-EVENT-CONNECTED - Connection to 00:11:22:33:44:55 completed (auth) [id=0 id_str=] Give a static IP address to your wireless interface (or run a DHCP client) and try to ping a host inside your LAN to verify that the connection works.
Congratulations, you've just built yourself a highly customizable wireless access point. Although this setup is ideal for home or small office usage, you need something more robust in the enterprise, with authentication with a RADIUS server, or even better, a VPN. Check out my previous article on how to create such a setup with OpenBSD and OpenVPN.
Saturday, May 02, 2009
Comparison of Cooperate Bank Account for SMEs in Singapore
http://www.uberstudio.com.sg/bank_account
Corporate Bank Account Guide
OCBC entreprenuer corporate account has the lowest initial deposit of S$500 but you need to sign up with them within 6 months of business registration. If you have been incorporate for more than 6 months, then UOB has the lowest initial deposit of S$1,000.
Generally, banks will charge a service fee of S$15 per month if your average monthly balance falls below S$10,000.
1) UOB Bank (UOB Website)
a) UOB Corporate Current Account
Benefits
- A monthly statement of account for easy reference.
- A free Corporate UniCard (UOB Corporate ATM card) with NETS facility.
- Free cheque books that are automatically replenished.
- Easy access to your Current Account through UOB Group's PhoneBanking service.
- You'll also have the option of enjoying the benefits of Business Internet Bankingรข€" UOB Group's premier web-based banking solution for businesses.
Requirements
- Initial Deposit of S$1000
- Minimum fee of S$15 if average daily balance fall below S$10,000 during the month
2) DBS Bank (DBS Website)
a) DBS Corporate Current Account
Benefits
- 1st 30 cheques per month free. Subsequent cheque at $0.40.
- Earn daily interest on your balances at competitive rates.Interest is paid only on qualifying tiered balances.
- Receive a monthly statement with transaction details of your Current Account.
- Apply for your BankCard at any of our DBS/POSB branch.
- Get access to a wide range of self-service banking facilities at our ATMs, Phone Banking, IDEALTM Internet Banking and Quick Cheque Deposit Box.
- Receive new cheque book automatically when you are down to your last few cheques. No reminders, requests or trips to the bank are needed.
- Apply for overdraft facilities at competitive rates.
Requirements
Initial Deposit of S$3000
Minimum fee of S$15 if average daily balance fall below S$10,000 during the month
3) OCBC Bank (OCBC Website)
a) Entrepreneur Corporate Account (Automatically converted to SGD chequing account after 6 months)
Benefits
- Unlimited free cheques
- 50% off Giro transaction at Vivocity OCBC
- 6 months waiver of minimum balance fee (subsequently S$15 per month if average monthly balance is below S$10,000)
- 1 free Digipass for Velocity@ocbc
Requirements
- Initial Deposit of S$500
- All new businesses within 6 months of date of incorporation
b) Business Privilege Account
Benefits
- Unlimited free cheques
- GIRO transaction fees at S$0.10 via Velocity@ocbc
- Up to 3 free Digipasses for Velocity@ocbc
- eAlerts@ocbc an alert notification service at S$15 per month. First three months free.
Requirements
- Minimum deposit of S$5,000
- S$20 per month of monthly average balance falls below S$10,000
- If eAlerts@ocbc service be terminated, the Business Privilege Account will be automatically converted to an ordinary current account.
c) Singapore Dollar Chequing Account
Benefits
- S$ 0.50 per cheque from the 31st cheque onwards per month
Requirements
- Minimum initial deposit of S$ 5,000
- Minimum credit balance of S$ 10,000
- S$15 per month if monthly average balance falls below S$ 10,000
Wednesday, April 22, 2009
pgp public key
Version: GnuPG v1.4.6 (GNU/Linux)
mQGiBEntvoMRBAC5DoR7QBxe7zeKvyaDBGSybUHoEAv9zZ3aeOi2DpIr4jgHrLwu
4Bd/CHyDBmQm5zg5lISXIEY2UV9cn0igqkFYi4iIekfZwZtb2D5ExQ7EZY3JBgOG
mA38kkqTwEKoN4UThf4aW38EOlHr33HRMs4SuSO8pfg0zOeHCqasbO9RZwCg7r+U
J7iHncFzJ9km8lBMcB3c7sUD/jBjoMHiGbANAqnyKuLc84+uQoLgvNbivoF9cbhZ
vj+g49ho+7YWxwlJLaVnPtmvnRP+6WN05PviVbvkr+fkUUpMBe+bPnXAx/JcPjxS
hMIMiQ44h+zJFvc/bJltC0O4aVrE7MQgSi6AAAjVxCIeHcy7y9AW2vXhp5yI0M3k
BVVWA/wLICDDGYEEfgqnXTsoxLl9qdrnxyIfu50oiyTttA5ZhkNB+pny+BRPuIJN
+cAqHPg9V+PNVitI8OVqIffqwKeMf073hIXP2If5RRMWtVSQLef3nOxur039iCnp
460ygJZLzXDArXHjDFp+KlTE4XlbCGIWi04lHiFZTCbJaCqTv7QsTGl1IEh1YWNo
dW4gKEhhcnJ5IExpdSkgPGhhcnJ5aGl0QGdtYWlsLmNvbT6IYAQTEQIAIAUCSe2+
gwIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJELY8A7D98XSTf5IAniFwJdN5
+c9ncIekVsc5ZYGLGYkcAJ9fNmJlKOsIHWoc2ZVEOmlsH0b3j7kCDQRJ7b6GEAgA
gIM2kD+taqmbPN23uTPlwosEaUM+DvIsO0jf47JkHAC8m8AX9v6/EAqB1XPNOk6l
HMffVZVQcCLdWpDMI3iFbkfm2eVgixpmho2h6jQ3d9niLIjPJRrfOTxNNxVlxG5h
+4tDkzaxGdupCKUWVi8bmC4AhuDnI6e5am7pbt0mUy0EDh0+MiD2SnZ2vSy0Z06M
dwpvft9oQ48/JhYb/8Bj/1mMWh39NMKpYr9VN37RiCzAyShfDPiF6L7LMkOSN5Ks
Hq6kfmHZFR1LIBfP8p1WSm6QPDRYyFVuGiG0YxlMpMcRoTMWWayREaR/Y7olVp9o
faYbSqwrD6DJHSLC7DI4xwADBQf7BSzdqriS3rmntwlQcP9tCNtSOjeMuE4QK8IK
6DZ+Z5DjjOgUjGb5FUlmJhrPIqjbYe7xxcOuA1GdxAU3gJ8q9FQqssdk3edVK2qr
6MMq9YW1bGyUjUSA1FfqFzzzHMa3B7DCkgu+4DG7HYMvD707rPQ5TpH1nf8Wukfm
aUaPiwn+912uHekEArSTxI0IVOyvkkVMX2Q8fX6FlRVRBB0/o0We1eqRw2If0PM1
adfGnmBvFYR9B1jFSGDYfmYRb5KF2huZkvJkmguxm0dyZBNiNjA/ndF/YOXstR/G
gCbeX2hFdMx1D4wEPSJvVqB8+H3rhpzHuj5mvwKUgk4hK02uvYhJBBgRAgAJBQJJ
7b6GAhsMAAoJELY8A7D98XSTLS4An2AhkKX2NDdzYuwtK54DpmdHzE5uAJ9GIsER
GzVmoRTky1axSTPUJloZCQ==
=R/Ug
-----END PGP PUBLIC KEY BLOCK-----
Tuesday, April 14, 2009
linux screen command
Common screen commands
| screen command | Task |
| Ctrl+a c | Create new window |
| Ctrl+a k | Kill the current window / session |
| Ctrl+a w | List all windows |
| Ctrl+a 0-9 | Go to a window numbered 0 9, use Ctrl+a w to see number |
| Ctrl+a Ctrl+a | Toggle / switch between the current and previous window |
| Ctrl+a S | Split terminal horizontally into regions and press Ctrl+a c to create new window there |
| Ctrl+a :resize | Resize region |
| Ctrl+a :fit | Fit screen size to new terminal size. You can also hit Ctrl+a F for the the same task |
| Ctrl+a :remove | Remove / delete region. You can also hit Ctrl+a X for the same taks |
| Ctrl+a tab | Move to next region |
| Ctrl+a D (Shift-d) | Power detach and logout |
| Ctrl+a d | Detach but keep shell window open |
| Ctrl-a Ctrl-\ | Quit screen |
| Ctrl-a ? | Display help screen i.e. display a list of commands |
configure:
harry@ubuntu:~$ cat .screenrc
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
# Default screens
screen -t root 0
# screen -t minicom 1 minicom
screen -t src1 1
screen -t src2 2
screen -t src3 3
screen -t shell1 4
screen -t shell2 5
screen -t telnet 6
Saturday, April 04, 2009
Wednesday, April 01, 2009
Linux inotify example
2. inotify_add_watch() - need to specify the directory and event(s) want to monitor
3. read() - to check if there is any changes
need to verify: is it possible to get the event when a input device is active by monitoring /dev/input/eventX
The Darke Side: Linux inotify example: "void get_event (int fd, const char * target)
{
ssize_t len, i = 0;
char action[81+FILENAME_MAX] = {0};
char buff[BUFF_SIZE] = {0};
len = read (fd, buff, BUFF_SIZE);
while (i < len) {
struct inotify_event *pevent = (struct inotify_event *)&buff[i];
char action[81+FILENAME_MAX] = {0};
if (pevent->len)
strcpy (action, pevent->name);
else
strcpy (action, target);
if (pevent->mask & IN_ACCESS)
strcat(action, ' was read');
if (pevent->mask & IN_ATTRIB)
strcat(action, ' Metadata changed');
if (pevent->mask & IN_CLOSE_WRITE)"