Archive for the ‘Linux’ Category

how to mount a ram hard disk in Linux

Monday, February 1st, 2010

In this post, i will show you how to create a very fast, 0 latency hard drive from the extra gigabyte or 2 on your system

1- You need to change the boot options to allow this…

Since i use debian lenny, my boot options look like this in /boot/grub/menu.lst

title        Debian GNU/Linux, kernel 2.6.26-2-686
root        (hd0,1)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/sda2 ro quiet
initrd        /boot/initrd.img-2.6.26-2-686

We need to append ramdisk_size=1572864 if we wanted a 1.5GB RAM drive, make sure you have 1.5GB EXTRA on your system, let’s say you must have a minimum of 2GB for the system to run using the 512MB you are leaving the system with

title        Debian 1.5GB Ramdisk, kernel 2.6.26-2-686
root        (hd0,1)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/sda2 ro quiet ramdisk_size=1572864
initrd        /boot/initrd.img-2.6.26-2-686

You are done for now, if you want to format and use it do this

/sbin/mkfs.ext2 /dev/ram0

Remember that you need to format as ext2 and not ext3, i have seen people format the hard drive as EXT3, why would you ever need Journaling on a RAM disk that is already volatile (Deleted when you reboot)

mkdir /ramdisk
mount /dev/ram0 /ramdisk

You can now get creative and format or load a disk image at boot time, in any case, the RAM is only allocated to the disk when you use it, but you really don’t need to know that to use your new RAM hard disk

NOTE: I chose to explain RAM disk because later on i will show you what advantages we can get from having a block level device, you can surely do this without modifying boot options by simply using tempfs or RAMFS that give you an instant ram disk, but it is not a block level device in that case

Testing Speed

So, you want to see how fast it is, but for that we need a data source that can push this thing to the maximum, the answer is /dev/zero that responds with a stream of zeros, so let us write a 1.3GB file to our new volatile hard disk

dd if=/dev/zero of=/ramdisk/pathtoimage.img bs=1M count=1300

On my computer, this took about 4.54006 seconds.

installing Debian Lenny extra steps

Monday, February 1st, 2010

This is how i install Debian lenny at the office on all computers

NOTE: (192.168.2.133) has apt-cacher, my PC 192.168.2.106 has a php script that responds with the caller’s IP

1- Put the Lenny Mini-CD into the computer
2- Follow instructions, when asked about a proxy, the address is http://192.168.2.133:3142/
3-Once done, run

apt-get update

apt-get install ssh openssh-server

4- Finding out our Network IP address, you can simply issue the command

ifconfig

The above will give us the IP address of this pc

5- Now we can go back to the Windows PC and start WinSCP and PUTTY to edit files and do stuff, i use sourceedit as the editor because i want to save any edited file as linux text (Line break is different)

6- connect via putty and WinSCP to the computer so we can edit some files…

7- Fix /etc/apt/sources.list to have the apt-cacher … and comment out the CD

so deb “http://ftp.us.debian.org/debian/ lenny main” becomes “deb http://192.168.2.133:3142/ftp.us.debian.org/debian/ lenny main”

The above lines save internet bandwidth by caching the files on the network

8- Now, we want the PC to request the same IP every time so that we always know how to connect to it.

edit /etc/network/interfaces,

——————————
initially it looks like this
——————————

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

——————————-
But we want it to look like this
——————————–

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.112
netmask 255.255.255.0
gateway 192.168.2.1

auto eth0

———————————–

—-DONE—

And now we are probably set to connect to this PC every time (Static Network IP), and to use aptitude without waiting for ages to download the packages from the internet

MySQL Windows VS MySQL on Linux

Friday, January 29th, 2010

Comming across Robin Schumacher’s “MySQL on Windows? Absolutely!” i have some stuff to say

First, I absolutly LOVE windows on my Desktop, and i LOVE Linux on my servers, and i have nothing against windows servers or Linux Desktops, i like Operating systems that get the Job done faster and with least effort, so what suits a job suits me, having never used a mac, i would jump to a mac if they tell me it can help you develop application X faster, why not, but the article here http://dev.mysql.com/tech-resources/articles/mysql_on_windows.html does not seem to make sense to me. Here is why

In the comparison of number of downloads, it clearly reads that windows has 600K downloads VS linux that has 200K downloads, but are you serious ?

On Linux, MySQL is hardly if ever downloaded from mysql.com , while on Windows it is always downloaded from MySQL.COM and therefore i beg an explanation on why you say this statistic tells anything, Also, most developers are like me, they use the Windows edition for development on there development PCs, and then deploy the actual application on a Linux server.

For example, on a debian system i would simply issue

apt-get install mysql-client mysql-server

this will get MySQL binaries from Debian, not from MySQL, and therefore making the statistic not available to you.

Then the article talks about how insignificant the differences between the Linux and Windows edition is, to tell you the truth, this is not the case at least for me, here are SOME examples

Most of my applications can not make good use of RAID because RAID does not help with disk seek time (And therefore latency), My answer to this is usually separating tables to more than 1 hard disk , and although having databases moved to other hard drives is supported in windows by creating a text file, moving individual tables on windows is not, On linux, i simply create a symbolic link to the MYD file, and one to the MYI file, i can even split a single table to 2 hard drives with the indexes on 1 drive and the actual data on the other.

Clustering anyone ??

For a longer list check out http://dev.mysql.com/doc/refman/5.0/en/windows-vs-unix.html , this is certainly is inferior to the Linux counterpart for something like a shared hosting environment (See number of open files and connection timeouts etc..)

Now to add more to that, Linux is a free OS, you install and upgrade it for free, and MySQL is also free, if your business uses many many MySQL servers, your savings on Windows Server licenses can be significant.

The bottom line is, when a company like Oracle (Since it has acquired SUN) gets hold of an open source database engine, you can rest assured objectivity will still be there only when it supports the paying product.

Thanks for listening.

Multi Disk MySQL

Friday, December 4th, 2009

For performance reasons, separating DBs to Multiple hard disks can be beneficial

In Linux, when you want to include a directory for a database, you add a symbolic link ( Using the ln -s targetdir command), in Windows, there are no symbolic links, and Windows Shortcuts ( Via right click create shortcut ) don’t work

The truth is, MySQL enables Symbolic Links in Windows by default, but you have to do it the MySQL way

MySQL is a file based database engine, you should be able to see a folder for every database run by your database engine, Now to move one of those DBs to a different directory or hard drive, you just copy it to the new destination and create a file db_name.sym then, within that plain text file, you can add D:\data\db_name\ where D:\data\db_name\ is the folder containing the MySQL files.

You should be good to go if you have moved the directory of the database to d:\data, but if you copied it, the copy in the original MySQL data directory will be used

You are done, Now you should experience the extra performance of combining disks, the closest it gets without RAID and a reformat, surely this is assuming the DBs are used evenly

But there are other reasons why you may want to do this, one of which is, when you want to compile all user data in a directory, So DBs that person creates using your server management software puts all that person’s software in one place so that when he or she requests a backup, you know what to send him/her

Enjoy

Linux Debian Lenny and apt-cacher

Friday, March 20th, 2009

Mama i’m comming home

Back to Debian, as when i thought about it, i Don’t really like Ubuntu, what has it added, i still don’t know the difference between UBUNTU and Debian, Debian keeps a legal document that promises to never do what redhat once did, ubuntu does not, Debian has a Blue Background, and ubuntu has a color that i don’t know the name of, Besides, Hardy shipped with XEN not functional on my 64Bit and i had to wait for a long time to have it fixed, Lenny here i am.

To begin with, Why download the DVD or worse the 5 DVDs, i downloaded a CD (Or get the NetInstall CD), then install 1 copy from that CD, now install apt-cacher and the software you use will be cached on your network, My apt-cacher is installed inside a virtual machine, when i want to install another copy of lenny, i simply allow it to download from the internet, and after picking a mirror in the installer, i specify a proxy as http://192.168.0.133:3142/ and i will never have to download that package twice.

Better yet, the CD or DVD get outdated fast, this one keeps refreshing itself with the latest packages, and i can save Debian (The distro i love most) some bandwidth.

After the install, remember to change your repository lines so that a url like http://ftp.us.debian.org becomes http://192.168.0.133:3142/ftp.us.debian.org, Also fix that on the install that hosts the cache.

Great stuff right !

lenny on ubuntu hardy 8.04 with xen paravirtualised

Thursday, February 26th, 2009

While i find out how it can be done paravirtualised, i will be intalling it HVM, then i will keep you posted on how i will convert it to a paravirtualised system as soon as i do, Here i will keep you posted how the HVM virtualised goes

S.M.A.R.T (SMART) data of hard drives under linux

Thursday, February 26th, 2009

The results of the commands on this post are Here

On windows, You can use speedfan, under linux you can read the smart data as follows

Use the smartctl command

1- Checking for smart support, (All recent hard drives have it but you need to enable it in BIOS)

smartctl -i /dev/sdb

2- Enable reading it

smartctl -s on -d ata /dev/sdb

See it

smartctl -d ata -H /dev/sdb

Read more

smartctl -d ata -a /dev/sdb

Now some manufacturer specific smart atributes exist, you need to google them out, Also smart is not definitive, if S.M.A.R.T data says ok but there is a ticking noise in your hard drive, Don’t trust the hardware data, get backup.

Some hard drives like the Samsung Spinpoint come with extensive diagnostics software, My 3 2.5′ disks pass the test, pass the smart test, and tick when warm, i will let you know if it was the tick of death sometime soon

Debian 5 lenny is out and i can’t find Synaptics !

Sunday, February 22nd, 2009

So, ALT+F2 then gksudo synaptics… sometimes i get the message you can run synaptics without a password, but synaptics does not show up, aptitude is there, but where is synaptics ?

Anyway, i am glad lenny is out, i have been waiting for it since last year, and i thought downloading it would be a challenge when the rush comes, The download came in at full speed and the both the text installer and the GUI installer work like a charm.

Did i mention it is not 1 DVD ! the thing is a 5 DVD, But i don’t think it is wise to download them all, Just download the first CD, and when you need a package, let the software get it from the internet for you.

all you need is the first CD or DVD, most packages you will need are there, and whatever is missing the installer can get for you from the internet !

Anyway, i have not yet checked it out fully, when i do, i will update you all.

asterisk 1.6 install and deploy.

Thursday, February 19th, 2009

Asterisk with chan mobile.
So, my lovely TUSI-M does not work, it has legacy USB ports, I want USB 2.0.

Got an old celeron PC I had somewhere, found out it had 1GB of DDR1 ram, a 2.53GHz processor, a P4i65GV Motherboard with Bios 1.80 (Asrock), And an 80GB hard disk, fits the bill perfect.
the good thing about this motherboard is that it has 8 USB ports (2.0), The bad thing, A Celeron processor, An old celeron processor.
I installed an X100P (That I got in the mail today) on the PC.
1- Installed Ubuntu 8.04 32Bit from DVD, a default DVD install, user name (yazeed), Password (ZeDevildetail), and hostname (asterisk).

2- Now i need to enable VNC access, see This post in the ubuntu forums
3- Restarted Ubuntu to make sure the previous step works.
4- Installed Samba by starting Synaptic Package manager, Searching for Samba, and marking samba for install, 2 more packages are requiered, agreed to

install them when prompted after hitting the apply button, Same to install openssh. And miraculesly, when I start ubuntu on the machine, I can poin my VNC

viewer to asterisk:2
5- I installed RealVNC on my windows machine (The viewer only, if you install the server you will need a serial number).
6- logged in via VNC.
7- Downloaded Asterisk 1.6.0.5 along with the addons 1.6, DAHDI linux, Dahdi tools, and libpri 1.4.7 to /usr/src, DAHDI is what used to be ZAPTEL ,

LibPri is for T1, E1, J1 and I don’t need it, Just thought I’d install it anyway , So I unpacked them to that same directory I am in.
8- Before I install anything, I probably need to satisfy some dependancies, and add some tools so I can make managing the system easy later on,
Running aptitude
LAMP task: PHP would help me write stuff I can fix online !
the, MySQL with root password being “whatdevil”

Now from Synaptics package manager
GCC 3+, G++ 4.1, cpp and other compiler stuff ubuntu tells me about
Ncurses devel
Libtermcap-devel
Kernel development headers
Kernel development headers (SMP)
GCC++
Openssl and its dev package
Newt-devel
Zlib-devel
unixOBDC and unixOBDC devel
libtool
gnu make
Bison for CLI (yacc and)
Libnewt for zttool – ztcfg

Now that i have installed everything with synaptics that looks like the above, i will

Start with the Zaptel – Now dahdi driver….

cd /usr/src/DAHDIblahblah

make

makeinstall

cd /usr/src/asterisk-1.6blahblah

make clean

./configure

make menuselect

…Now from Menu select, i am looking for dependencies that i need so that i can compile everything in asterisk 1.6….

up to now, i need

CURL OK
PostgreSQL OK
sqlite
sqlite3

Cryptographic digital signatures

jabber

netsnmp

spandsp

resample

jack ??

osptk

ssl

radius

freetds

asound

portaudio

res_jabber

iksemel

openh323

isdnnet

misdn

suppserv

nbs

usb

vpbapi

speexdsp

verbis

ogg

curl

gtk

lua

ldap

imap_tk

gmime

Asterisk sound packages in multiple formats, both basic and extra