Linux ext4 fs tuning

There is only 3 values affecting mostly affecting io perfomance.
noatime – don`t store file access time
Nodiratime – don`t store disk access time

And turn off journal!
tune2fs -O has_journal -o journal_data_writeback /dev/sdaX
or
data=writeback

my fstab

/dev/md/2 / ext4 noatime,nodiratime 0 0

But thereis no magic… if your have serious io problems – this will not help you. Tuning can give up to 10% perfomance.
usually less.

additional info
http://kerneltrap.org/node/14148

Some mysql howto

This topic was done to skip googling in some cases.

How to get mysql database size:

mysql -uroot -pPASSWORD -D DATABASE_NAME -e "show table status\G"| egrep "(Index|Data)_length" | awk 'BEGIN { rsum = 0 } { rsum += $2 } END { print rsum }'

Source: http://eddnet.org/?p=1765

How to set mysql to read only mode:
Attention! root can do r/w regardless of read_only!

mysql> set GLOBAL read_only = true;

edit config

:/etc/mysql/conf.d# cat slave.cnf
[mysqld]

server-id = 18
innodb_buffer_pool_size = 200MB
read_only = true

How to drop user

DROP USER 'USERNAME'@'%';

How to find duplicate rows.

SELECT *,count(id) AS Num FROM clicks_log GROUP BY id HAVING (COUNT(id) > 1 );

How to delete duplicated Rows
I am not SQL guru, maybe there is another perfect way how to do it, but it`s works:

mysql> create table id_tmp AS (SELECT id FROM block_news_views_log GROUP BY id HAVING (COUNT(id) > 1) ) ;
mysql> DELETE  FROM block_news_views_log WHERE ( id IN (SELECT * from id_tmp ) );
mysql> DROP table id_tmp;
mysql> SELECT id FROM block_news_views_log GROUP BY id HAVING (COUNT(id) > 1) ;

Ubuntu 12 USB monitor Display Link

Finally we have
xserver-xorg-video-displaylink I`ll try to run third monitor ๐Ÿ™‚
But it gives Green Screen ๐Ÿ™
Damn, not working.

How to solve long queue qmail.

Damn, I hate mail administration… And I really like google apps (gmail) or appriver mail hosting.

Today we have issue with our corporate qmail server, mail stalled.
To be clear – I change job a week ago and just 5 days as I take care of new infrastructure.
Corporate mail server powered by qmail. Thay have zabbix as monitoring software, but not enough configured, without queue monitorind and SMS escalation. Due to great number of urgent tasks, I really have no enough hands to fix all at once…

So Monday begins with great fuckup… 180 000 messages in queue…
First diagnostic steps:
Read more »

How to verify your domain for GooGle Apps using bind

Damn, dudes from google didnt write howto for verification via bind nameserver.
It`s very very easy, just use @ as record name
Example:

am2# cat randomthemes.com
$ORIGIN .
$TTL 3600       ; 1 hour
randomthemes.com           IN SOA  ns1.randomthemes.com. root.randomthemes.com. (
                                2012052404 ; serial
                                3600       ; refresh (1 hour)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                3600       ; minimum (1 hour)
                                )
                        NS      ns1.randomthemes.com.
                        NS      ns2.randomthemes.com.
                        NS      ns3.randomthemes.com.
                        A       87.242.73.112
                        MX      1 ASPMX.L.GOOGLE.COM.
                        MX      5 ALT1.ASPMX.L.GOOGLE.COM.
                        MX      5 ALT2.ASPMX.L.GOOGLE.COM.
                        MX      10 ASPMX2.GOOGLEMAIL.COM.
                        MX      10 ASPMX3.GOOGLEMAIL.COM.

$ORIGIN randomthemes.com.
*                       CNAME   randomthemes.com.
www                     A       87.242.73.112

@       IN      TXT     "google-site-verification=XXXXXXXXXXXXXX-XXXXXX-XXXXXX-XXXXXXXXXXXXXX"

It`s working o.k.!

FreeBSD how to search and install apps from ports

Of course everyone know, how to do it. ๐Ÿ™‚ except me, old Linux geek. ๐Ÿ™‚
First, search for it, second install

ms2# whereis nmap
nmap: /usr/ports/security/nmap
ms2# cd /usr/ports/security/nmap
ms2# make install

Read more »

Find CPU and memory information FreeBSD and Linux

At Linux I use

#cat /proc/cpuinfo

at FreeBSD

ms3# sysctl -a | egrep -i 'hw.machine|hw.model|hw.ncpu|hw.physmem'
hw.machine: amd64
hw.model: Intel(R) Xeon(R) CPU           E5520  @ 2.27GHz  
hw.ncpu: 16
hw.machine_arch: amd64

Read more »

show open ports FreeBSD

In Linux I usually use

#netstat -4nlp

In FreeBSD syntax is different, your should use something like this:

#netstat -atn | grep LISTEN
or
#sockstat -l

df reports negative (minus) value FreeBSD

It was really surprise for me, Today is my first day working with FreeBSD after 11 years linux administration ๐Ÿ™‚

ms3# df -h
Filesystem       Size    Used   Avail Capacity  Mounted on
/dev/mfid0s1a     29G    5.9G     21G    22%    /
devfs            1.0K    1.0K      0B   100%    /dev
/dev/mfid0s1f    213G    9.9G    186G     5%    /hast
/dev/mfid0s1d    2.9G    2.7M    2.7G     0%    /tmp
/dev/mfid0s1g     97G     77G     12G    86%    /usr/local
/dev/mfid0s1e     29G    1.1G     26G     4%    /var
/dev/mfid1s1d    451G    421G   -6.8G   102%    /opt1
linprocfs        4.0K    4.0K      0B   100%    /usr/compat/linux/proc
ms3#

It`s o.k. it means, that I just using reserved space. (available for root, n/a for users.)
Read more »

Lenovo UEFI dual boot Windows7 Ubuntu

Today I had a real brainfuck, how to make Ubuntu and Windows 7 to coexist on my Lenovo Z570.
First I try grub-efi

 convert EFI partition to Fat32
 mount /dev/sda1 /boot/efi
 grub install /dev/sda
 
 mkdir /boot/efi/efi/boot/
 cp /boot/efi/efi/debian/grubx64.efi /boot/efi/efi/boot/bootx64.efi

Gentoo booting O.k., but I cannot make Windows 7 boot.
I copy windows loader efi from Windows/Boot/EFI And BCD (data for loader) at the same folder, and try custom menuitem at grub
It looks like this

menuentry "Win7" --class windows --class os {
  insmod part_msdos
  insmod fat
  set root '(hd0,msdos1)'
  search --no-floppy --fs-uuid --set root MY_UUID_FS
  chainloader $({root})/EFI/Microsoft/BOOT/bootmgfw.efi
}

Damn it`s not working. I`m talking about this wrong ways for you not to try this.

The only way how i make dual boot working.

1. Replace grub-efi with grub-pc (non efi grub build)
aptitude update && aptitude install grub-pc
2. install grub to linux partition my – /dev/sda6
3. Make it boot from Windows loader.

There is 2 way how to make it boot from Windows loader.
1. Use easybcd. (this will install grub4dos fork or other grub fork to load ubuntu from /dev/sda6)
2. Use windows native loader. Here are instructions for Windows 7 (there is no boot.ini at windows7 BCD used instead)

dd if=/dev/sda6 of=/mnt/share/linux.bin bs=512 count=1
bcdedit /create /d โ€œUbuntuโ€ /application BOOTSECTOR
BCDEdit will return an alphanumeric identifier for this entry that I will refer to as {ID} in the remaining steps. Youโ€™ll need to replace {ID} by the actual returned identifier. An example of {ID} is {d7294d4e-9837-11de-99ac-f3f3a79e3e93}. Next, letโ€™s specify which partition hosts a copy of the linux.bin file:
bcdedit /set {ID} device partition=c:
The path to our linux.bin file:
bcdedit /set {ID}  path \linux.bin
An entry to the displayed menu at boot time:
bcdedit /displayorder {ID} /addlast
and finally, letโ€™s specify how long the menu choices will be displayed:
bcdedit /timeout 30

It`s working! Now I have dual boot at this UEFI damned notebook!