Linux.com

Home Linux Community Community Blogs

Community Blogs



Is Linus’ Law still valid?

"given enough eyes, all bugs are shallow". Is this still true, at least on Gnome, KDE and other Free Software desktops? A few weeks ago my Fedora Linux computer became so damn slow that I had to urgently ask for help. Things are better now, but I do wonder: is Linus' Law is always so valid as it was ten years ago?

 

MCG, the eMail Configuration Generator for procmail and mutt

Procmail and Mutt are so flexible and powerful to allow a total customization of email management. In spite of all this, I grew sick of setting options about the same thing, but with two different names in two different files, and in trying to keep those two files in sync. It’s always the same thing, email management, why should I configure things twice? So I put together a little script to solve this problem.

 

OpenStreetMaps to relax, study and get faster where you want to go

"Orienteering is a great sport that can’t be practiced without maps, but finding free maps is hard, not to mention that, in some orienteering contests require customized maps", says M. Napolitano at the Stop.

 

Flash/nVidia horrors, Gnome/KDE fights in Fedora

Just a few days after I had brought back my Fedora computer to life, the last updates in kernel, nVidia driver from RPMfusion and what not made working impossible again. Here's how I (kinda) fixed it, and some kde/gnome cohabitation problems I noticed along the way.

 

 

The Slacker Dreads MS Windows Service Packs

Back in the dark ages of my computering life. I used an operating system known as Microsoft Windows®. I still occasionally play around in Windows these days.

I have (had, the drive failed on me recently) an XP Pro installation on my desktop system for playing games only. It’s crippled… no networking installed at all. I also have an installation of Win 7 on my laptop. It’s just for fun and education. I’m the family computer nerd, so everyone comes to me for help. They don’t run Linux… yet. MUAHAHAHA! Anyway, I have to stay comfortable with how MS products work so I can still be helpful to the unfortunate souls still using that OS.

As some of you who know me may remember, the camel that broke the straw’s back for me with MS Windows was the fact that I had numerous catastrophic system failures due to corrupted installations of various Service Packs on XP back in ‘06. The last one may have actually been a faulty Seagate hard drive, to be fair to MS. However, the last one was the last one for me. I went to Linux full time within a few days of that event.

Now, here comes a new Service Pack (#1) for my Win 7 installation. UH-OH! I’m very gun shy about Service Packs, folks. This time, though, the OS is not my primary computer tool, so what’s the worry. If it boogers up, I can just reinstall. No great loss… just more minutes of my life sucked out of existence by Microsoft. Anyway, I decided to go for it yesterday. The install was fast and painless. And best of all… the system rebooted into a working Win 7 OS. Cool, huh?

Kudos to MS. They may have finally gotten something right with this new Win 7. So, just what was Vista? XP’s Millennium Edition? Oh, wait… Vista was the beta, of course. I wonder how many folks actually paid $300 to beta test for MS on that one. All that testing paid off. Thanks beta folks! :)

OK, I’m outta’ here…

~Eric

NOTE: All derogatory comments regarding Microsoft and the Windows® operating system are absolutely true… er, I mean are absolutely in jest. jk, as Generation Text likes to say. Can you imagine what Evolution is going to make their childrens’ childrens’ childrens’ thumbs look like? Heh!

*The above is reprinted with permission from me from my Nocturnal Slacker blog at Lockergnome.com

 

 

 

Know your home folder

Just added a small note related to user's home folder in linux. click here

 

 

Daemon tool to run PHP script in Linux.

Daemon tool to run PHP script in Linux.

Put this in a file (called, say, runphp.sh):      (create this file wherever you want and run it)

vim runphp.sh    (insert following code)

#!/bin/bash
while [ 1 ]; do
sleep 10
php5 ~/script.php
done

save and exit file

OR If you are using thrid party apache server like Xampp…  then

Code:

#!/bin/bash
while [ 1 ]; do
sleep 10
/opt/lampp/bin/php /opt/lampp/htdocs/script.php
done

save and exit
—————————————————————

Then run: Code:
# nohup bash runphp.sh& echo $! >phpid.txt

—————————————————————-

Check error :- cat nohup.out

—————————————————————-

That will just run in the background (even if you close the terminal window), and when you want to close it, just run:

Code:
kill $(<~/phpid.txt)

Explanation of above command : If you want to stop the script then open phpid.txt file find out the Process ID and execute below command

Kill -9 Process ID

 

Installing KVM

SETTING UP KVM ON LINUX

Intro:

VMs have made working with multiple OSs a lot easier. And if you are a tinkerer like me, you can’t wait to get your hands on the latest system, and find that you nothing to install it on. Thank goodness for virtual processing. I’ve used serverel VM emulators such as Vmware and Virtualbox and both offer great advantages. Yet there are others, and not all VMs run good on every system. After doing some exploring and getting help some very good linux gurus, I came across KVM.

KVM

KVM (kernel-based virtual machine) is a virtual machine program that runs within the linux kernel. When it runs inside the kernel, it is treated like a normal linux process. This setup gives kvm priority when it requests services and execution from the cpu allowing better runtime performance.  KVM would be like any kernel module loaded within the kernel when the a linux system boots.

KVM does not have a gui interface nor does it provide machine emulation. Instead it responds to calls from a VM manager, like qemu/aqemu for resources in order for a VM guest to be created. KVM manages low-level resources like memory, diskspace, cpus etc. The VM manager (qemu/aqemu) takes those resources and creates the guest OS.  

KVM can run on a number of linux operating systems including Mac OSX, open solaris and others. For KVM to run on linux, the kernel must be of version 2.6.20 or later.  If running kvm on Intel or AMD hardware archs, both cpus must support VM extensions. For Intel, the cpu must have the Intel VT extension and for AMD, AMD-V extension. To see if your architecture supports KVM, run this command in your terminal.

grep -E 'vmx|svm' /proc/cpuinfo

If you get any type of output, then your system has support. Look closely at the output at the bottom image. If you see svm, then your AMD has support. Likewise, if you see vmx, then your Intel has support. 



You must also make sure that virtualization is enabled within your system BIOS. In IBM systems, this is enabled by default, for others you have to enable it manually. KVM consists of a loadable kernel module, the kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko.
I’m using opensuse 11.3 with  LXDE to demonstrate the installation of kvm. Particularly, opensuse has a huge selection of system management and configuratioin options and can be very intimidating to normal users. The system opensuse runs on has the support for KVM. And after some tinkering, is wasn’t hard to install.
Again, to use kvm you must use a kernel version of 2.6.20 or later. latest kernels have kvm install already. If not you will have to install it manually through your systems repositories or download the source files. In opensuse, I used used YaST2 to download kvm from the repositories and install it. YaST2 works like a charm when it comes to package management. Arguably, it may perhaps be better then ubuntu’s synaptic package manager.  Go to the start menu, select systems, click administratioin, and select YaST. The YaST2 control center pops up. 



In the software section, search for and click “software management”. Once the software manager pops up, in the search tab, type kvm in the search box and click search. In the right window, you should see the options to install kvm select it.



Next you need to install qemu. Type qemu in the search box. Once you see qemu, select it. One you have both packages selected, click “accept”. A dialog box will pop-up showing the packages you installed and any dependencies that must be installed as well as packages that will be changed. One very important dependency is virt-utils. This needs to be install. Go ahead and click continue to install all packages.

Restart your machine to appy all changes. To confirm kvm is loaded within the kernel, open a terminal and type “lsmod”. Look at the list of modules. If you see kvm, then kvm has been loaded. You should also see the kvm module loaded for your cpu arch. In my case I have the kvm-amd module designed for amd arch.



Remember, to setup a virtual machine using kvm, you have to use qemu which is ran in the terminal. If you don’t want to use qemu, you can use aqemu which provides a gui interface to setup guest OSs using utilities provided from qemu.. Aqemu is not included in the opensuse repos, you will have to download the rpm manually.

To download aqemu, link to this site, http://rpm.pbone.net/index.php3/stat/4/idpl/11188025/dir/opensuse/com/aqemu-0.6-34.1.i386.rpm.html, and download the rpm package designed for your arch. Go to the folder containing the rpm and click to install. The YaST package manager will open showing all the libraries that will be install along with aqemu. All you need to do is click accept, and the 
installation will execute.

When aqemu is ran for the first time, it must be adjusted for first time use. The aqem settings dialog box will open for you to ajust the program. Select the default settings to continue. You can always go back to the settings if you need to change anything in the future. 



Once the settings have been accepted, the aqemu window will open and you are ready to create your first guest OS. 




Now we need to pick an OS we want to install. You can pick any OS you like, for this tutorial, we will use a particular linux OS that I have found to be very useful on low-end machines, Xubuntu, http://distrowatch.com/table.php?distribution=xubuntu. I am using xubuntu for the reason of it being light weight. I have notice the stronger an operating system is, the longer it will take for it to install under aqemu if it will install at all. If you plan to use KVM as your default VM machine, I recommend using a dual core 64bit system with at least 2GB of ram.  

Insert your Linux OS cd/dvd into the cd/dvd rom. Wait for the media to mount. Then in the aqemu window, scroll to the menu bar, select file and click create a new HDD image. 




This will be a new image drive file, so leave “use base HDD image” unselected. In the “New Image File Name” section box, click the “browse button” and navigate to a place where you want to store the image file. I’ve chosen the aqemu folder and create a subfolder named VMs which is where I will store all my VM images. Name your hdd image file anything you want. I previously named mine zorin OS. Yet since zorin crashed kvm, I decided to delete the VM files pertaining to zorin and re-used the hdd image file I created previously.
When you are done click save which will return you back to the previous aqemu hdd image window. Click create and you now have a 10Gb hdd image file. You can leave the default settings or change them, the choice its yours.. Next, click the VM menu, go to “New VM” and select  “add new VM” and name your VM. 



Once you’ve named your VM, aqemu will show you the system resources that will be used with your VM.


Make sure the “boot priority” is set to CD-ROM and under the “Storage devices” section, CD/DVD-ROM is set to use cdrom, which is the host’s CD-ROM device and “HDA” is set to use the HDD image file that we created. You can change these settings using the above tabs. Click apply to accept the changes. Then on the action menu, click the blue arrow button which will began the guest OS installation.
Here is the xubuntu setup screen running in aqemu as you would see if booting a physical system from the CD-ROM. We will began the installation by selecting “install Xubuntu”. Again this process may take a while depending on the strength of your system. 




We are now preparing the installation of xubuntu. If you have installed linux before, this should be self explanatory. Go ahead and install the system they way you normally would. Keep in mind to be patient. KVM is a new development and is a little rough behind the edges. Plus, we are using the gui form of qemu which could prove to be unstable, so take your time with. 



Here is the fully installed xubuntu system running on kvm. Important note, once the installation completes, you have to change the boot order back to HDD, which will be the HDD image file we created. Admittedly, there is no big performance improvement from the more popular VM emulators like VMware or virtualbox. However it is another way to setup virtual processing. Although it ranks low on the performance scale on this system, I do like the fact of KVM running directly within the kernel which gives the VMs better processing scheduling. I only wished to have an available dual core system to really see the benefits of KVM.  

 

 

 

Uninstalling a Linux OS from your Hard Drive

We have been getting questions from users about how to delete a linux OS from their hard drive. Well, lets oblige them. Uninstalling an OS is not like uninstalling a program with the simple "click to uninstall". It's a little trickier than that, however not that difficult. I will show a comprehensive method of removing a Linux OS, which is the correct term than uninstalling. These procedures will work on dual boot or single OS systems.

First you can not delete any partition on a drive if it is mounted. You will have to unmount the drive first to proceed. To umount a drive that has the linuxOS on it:

  1. insert a liveCD, and boot to the desktop. I recommend using the live ubuntu CD

You are now using your system via the liveCD, no drive on your system is mounted. From the live desktop, you  have two options to delete the partition. You can either use a gui tool like gparted, which is located in systems>administration or fdisk from the command line. From the gparted window, there is a drop-down menu arrow that allows you to select any drive that is located on the system.

In you the drop-down menu, select your require drive. You will get a listing of all the partitions on your hard drive. Select the required partition, and in the action menu, select delete. Then select aply changes. That's all it is too it. This works if you have only one OS on the hard drive.

Another method, which I like, is to use the fdisk command. To access the fdisk command:

  1. open a terminal
  2. type fdisk /dev/<drive>

The fdisk program has a lot of advanced features that come in handy when you need to make special changes to your hard drive. When you type the fdisk command you must specify the drive you want  it to access.  The drive specified by the drive files located in the folder /dev/. If your drive is a sata drive, you will specify /dev/sdax, or if it is an ide drive, you specify it with /dev/hdax. The variable x represents ths partition number.

Once you are in fdisk, you are given the option to list all the commands used with fdisk which is accessed by pressing the m key. Press the p key, and you will get the information pertaining to your hard drive.

Reading the information from your hard drive, you will notice a partition table. If you have only linux installed, you will see two partitions, a swap partition and an ext partition. If you have two OSs, windows and linux, you will in addition see an ntfs partition. Each partition will have a number after the sdax syntax telling you what number partition it is.What you are going to do is delete the ext partition by pressing the d key and selecting the partition's number. The fdisk program will help in the operations, all you have to do is follow what is says.

Keep in mind, nothing is changed unless you press the w key that force fdisk to write the changes to the drive. This is very useful if you accidentally select the wrong changes.

Notice, while reading the partition table, their is a boot column. The row of the ext partition has a "*" under the boot column heading. This means that this partition is the partition your system will boot from. You want to move the "*" to the ntfs partition, so your system will boot from that partition. You first remove the "*" from the ext partition by pressing the a key and select the partition number that you want to remove the "*" from. Then you must add the boot flag "*" to the ntfs partition. Press the a key and select the ntfs partition. Confirm you have made the right changes by pressing the p key to view the partition table. Once confirmed, press the w key to apply the changes.

Remove the liveCD once you reboot the system. You should see your windows OS loading, or start a fresh OS installation. Happy operating.

 

 

Simple Kexec example

Some time ago I was helping a friend with some kexec problems and written some notes on how to use it - here a CentOS based server was used, but the process should be pretty similiar also for other distributions. The main advantage is in skipping the BIOS init part which on servers takes quite some time. I personally use it for the gateway server (it has also other functions, like dns, dhcp, openvpn server) and testing servers reboots with minimal downtime. A nice kexec description is on its man page:

kexec is a system call that enables you to load and boot into another kernel from the currently running kernel. kexec performs the function of the boot loader from within the kernel. The primary difference between a standard system boot and a kexec boot is that the hardware initialization normally performed by the BIOS or firmware (depending on architecture) is not performed during a kexec boot. This has the effect of reducing the time required for a reboot.

CentOS, Fedora users can install it using yum:

[root@cent:~]# yum install kexec-tools

To switch between kernels you have to install a new one, here for example after running a ''yum update'' also a new kernel was installed - the 2.6.18-194.11.4.el5 version.

[root@cent:~]# yum update
[...]
Installed:
  kernel.x86_64 0:2.6.18-194.11.4.el5  kernel-devel.x86_64 0:2.6.18-194.11.4.el5
[...]

Current kernel is 2.6.18-194.11.3.el5

[root@cent:~]# uname -r
2.6.18-194.11.3.el5

For kexec, kernel and initrd path will be specified; paths (not full) can be found for example in the grub.conf file which was already updated.

[root@cent:~]# cat /etc/grub.conf
[...]
title CentOS (2.6.18-194.11.4.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.11.4.el5 ro root=LABEL=/
        initrd /initrd-2.6.18-194.11.4.el5.img
title CentOS (2.6.18-194.11.3.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.11.3.el5 ro root=LABEL=/
        initrd /initrd-2.6.18-194.11.3.el5.img
[...]

Also the arguments passed to the kernel at boot time are needed, you can look at your current arguments in the /proc/cmdline file. Later these same arguments will be given for the new kernel.

[root@cent:~]# cat /proc/cmdline
ro root=LABEL=/

Now to load the new kernel:

[root@cent:~]# kexec -l /boot/vmlinuz-2.6.18-194.11.4.el5 
--initrd=/boot/initrd-2.6.18-194.11.4.el5.img 
--command-line="$( cat /proc/cmdline )"

Start the magic and boot to the new loaded kernel:

[root@cent:~]# kexec -e

Hope this post will be helpful and inspire others to some kexec experiments :)

 

OpenStreetMap: open data that create services and jobs for everybody

The most important characteristic of OpenStretMap, however, is another one: everybody can freely, legally reuse them for any purpose, including (unlike Google Maps) for commercial activities. This is why, especially when paired to Free Software, maps like those of OSM can help people (even if they are NOT software programmers!) to find a job or start their own business!

 
Page 13 of 122

Upcoming Training Courses

  1. LF331 Developing Linux Device Drivers
    03 Jun » 07 Jun - Virtual
    Details
  2. LF411 Embedded Linux Development
    24 Jun » 28 Jun - Silicon Valley
    Details
  3. LF422 High Availability Linux Architecture
    15 Jul » 18 Jul - New York
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board