Categories
Linux

VirtualBox, Windows and Linux: Getting the best out of both worlds!

Windows and Linux are two entirely different OS. They have their own strengths and weaknesses. Many software and solutions are unique to either of the platform. If you’re an intelligent person, you’d love to get the best out of the both platforms.

If I talk about myself, I need Windows for many reasons. For academic purposes and as because of some minor but critical compatibility issues. My Notebook PC has issues with WiFi connectivity on Linux. Same goes for my Nokia X2 which can not talk to my PC via bluetooth if I am on Linux. On the other hand, I am a LAMP engineer. Linux is a must for my day to day works. In the past I used to run a Windows XP inside virtualbox. That used to solve some of my problems but not all. To be honest, till today, Windows has the best hardware compatibility no matter how their other features suck. We can argue whether it’s the fault of the hardware manufacturers or not but that won’t change the fact at all.

Finally, I have decided that I shall keep Windows 7 as my default OS and install Ubuntu inside virtualbox. In this way, I can access the required features of the Linux platform (LAMP, Postfix, nGinx and all others) and at the same time enjoy the benefits of Windows.

Even more interesting, I can share directories between the OS, so I can easily share my www on Windows and make the same stuff available on Linux. I planned to make the shared www the doc root of the apache in Linux so I can test the same application on Linux without hassles. This will give me the ability to try those PECL extensions, PEAR packages and other contents which are generally not available for Windows. So what did I do?

1) I installed VirtualBox (http://virtualbox.org)

2) I inserted my Ubuntu 10.10 disc. I proceeded with creating a virtual machine. On the way, I created a virtual hard disk in VirtualBox for the installation. The wizard is pretty simple. Anyone would be able to install Ubuntu on VirtualBox with ease.

3) After the Ubuntu installation was complete, I logged into the system. From the VirtualBox Window, I went to “Devices” menu, then clicked “Install Guest Additions”. This command added a CD to the virtual machine (Ubuntu). I went to “Places” > < Virtualbox Guest Addition CD name >. I double clicked the “autorun.sh” file and ran it on terminal. After a few moments, it was installed. The Guest Additions enable file sharing between the guest and host OS.

4) In the VirtualBox window, I clicked on “Devices” menu and then “Shared Folders”. I added a shared folder named “www” with full access. This was in fact the www root of my WAMP server.

5) Then I logged into Ubuntu and installed LAMP. After that, I opened up the “/etc/rc.local” file and typed in the following command:

What did it do? It actually mounted the shared www in /var/www when the machine (Ubuntu) started up. Making my WAMP server www available on LAMP. Since I have given the folder full access while sharing, I can use the terminal to do some dark magic on the files as well 😉

So, from now on, I no longer need to struggle while creating a “.htaccess” file or “index.php” file on Windows. Terminal will do that. 🙂

If you want to access the LAMP localhost from your Windows, go to “Devices” > “Network Adapters”. Add a “Host only adapter” to access it from the host OS. If you have a router and want to forward your port to the virtual machine, add a “Bridged Adapter” and select your WiFi or LAN driver.

After setting up the adapters, restart your machine and open terminal. Type in:

You can see the IP addresses attached to the virtual machine. Apparently you can access the LAMP www both via eth0 and eth1 IP address.

I have an exam tomorrow but couldn’t resist to share the little experiment and the awesome outcome! I was on a haste and everything might not be clear. Feel free to ask any questions. I shall respond when I can manage some time 🙂

Have fun!

Update: Backup the virtual HDD. In case something happens, you will be able to reuse it and skip all the installation hassles.

Categories
Linux

Ubuntu 10.10 Performance Issues and how to fix them :)

Okay, so if you have started using Ubuntu 10.10 lately, you might have noticed that the system is buggy. In my case – Terminal I/O was slow, scrolling was miserable, video was not running smooth and sometimes the permission dialog box jammed on screen. I was looking for a solution. I ended up browsing a hell lot of threads on the Ubuntu forums with similar problems but no solutions. I was getting frustrated.

Then somewhere I read that Ubuntu 10.10 Kernel might be the culprit behind the issues. I decided to give it a try. I downloaded the following files from the Ubuntu Kernel 2.6.36 rc7 (Maverick uses 2.6.35, 2.6.26 rc8 doesn’t have 32bit kernels yet) and put them in the same directory. Then I ran this command to install them:

Files:
http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.36-rc7-maverick/linux-headers-2.6.36-020636rc7_2.6.36-020636rc7.201010070908_all.deb

http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.36-rc7-maverick/linux-headers-2.6.36-020636rc7-generic_2.6.36-020636rc7.201010070908_i386.deb

http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.36-rc7-maverick/linux-image-2.6.36-020636rc7-generic_2.6.36-020636rc7.201010070908_i386.deb

The above commands installed the Kernel. I restarted my machine and everything was smooth 🙂

Categories
Linux Python

Python Script to Monitor Laptop Battery Charge (Ubuntu/Linux Mint)

I got my laptop two days ago. It’s a Compaq Presario CQ42-220TU. Battery backup is around 3 hours. I am using Linux Mint which is a variation of Ubuntu. Just a few minutes ago I wrote a Python script that monitors the battery charge and if it’s discharging, it gives a notification with remaining percentage of charge every 5 minutes.

Here’s the source codes for the curious minds 😉

Download:http://code.google.com/p/masnun/downloads/detail?name=battery.py

For convenience, I added the script to my start up applications. So whenever I log in to my lappy, it gets auto started. If you want to use this script as well, save the above source code in a file. Let’s assume you saved it in a file named “battery.py” in your home folder. Now give it execution permission. Right click on the file. Go to properties. In the “Permissions” tab, tick the option saying “Allow executing file as program”. Close the dialog box.

Now go to “Preferences” menu from Sytem menu (Ubuntu) or Mint Menu (Linux Mint). Go to Startup Applications. Click Add. Type in a name and comment. In the command field, type the full path of the file. Eg. /home/<_username_>/battery.py.

Restart your PC. 🙂

If you can’t get it working, please provide feedback here or catch me on IM. My contact details are available on https://masnun.com.