Category Archives: Linux

How to reduce your virtualbox linux virtual machine size

After using a linux virtual machine that has been configured with dynamically expanding drive, the size gets larger even if you remove files from it.

Here is the steps to shrink your linux virtual machine size :

1- Remove any unnecessary files you don’t need from the virtual machine.

2- Fill the unused spaces on it with zeros.

  • Open the virtual machine.
  • Install zero free
sudo apt-get install zerofree
  • Reboot the machine in repair mode, and login to root shell
  • Kill any processes using the hard disk.
service rsyslog stop
service network-manager stop
killall dhclient
  • list your virtual machine harddisks
df
  • Unmount and Fill all the unused spaces for each physical drive on the machine with zeros.
mount -n -o remount,ro -t ext3 /dev/sda1 /
zerofree /dev/sda1
  • Shutdown the machine.

3- Clone the old HD file into a new shrinked one

VBoxManage clonehd oldHd.vdi newHd.vdi

4- Now add the new cloned HD file as the new HD for the machine and test it.

5- Remove your old HD file.

 

Using Juniper Network on Ubuntu 32 and 64 bit without Firefox

Lately i have moved from Ubuntu 32bit to 64bit to make use of the 8G memory, and since I have been struggling to get our juniper vpn connection working, turned out it is not compatible with 64bit binaries of java and firefox.

I found this great tutorial here to have the juniper network VPN working from command line http://mad-scientist.us/juniper.html

the only disadvantage of this is you won’t have a status window to monitor the connection activity.

This has been tested on Ubuntu 10.10 maverick.

Backup or Export, Compress and upload mysql database to remote host

This is a handy command that i use to backup or export, compress and upload a mysql database to my remote host, very handy when you wanna upload your development database to the remote host after some changes.

/usr/mysql/bin/mysqldump --opt -uUsername -pPassword Databasename  | gzip -c | ssh -q user@remote-host.com 'cat > ~/Databasename.sql.gz'

Replace the following :

  • /usr/mysql/bin/mysqldump : The path for mysqldump on your localmachine
  • Username : Username for local mysql database.
  • Password : Password for local mysql database.
  • Databasename : Name of the database to export.
  • user@remote-host.com : the user and the IP or the address of the remote host.

the above command will upload the compressed database to your home directory on the remote host, to change the directoy, replace ~/ with the path you want.

Virtualbox hidden gems, VBoxManage

Virtual box has this little secret, the Command Line interface (CLI), this is very useful for users who wants to manage their virtual boxes on headless servers.

Question is why using command line while you have a nice easy to use GUI, the answer is POWER. you can do anything with the virtual box command line, you can create virtual machines, modify their settings, take snapshots, start and shutdown them.

VBoxManage supports everything the graphical user interface does, and much more.

VBoxManage has its share of Virtual Box documentation, you can find it here http://www.virtualbox.org/manual/ch08.html

Where I am ?

Looks like i have stopped blogging for a while. except from some trips and tricks I am keeping for my reference and public users.

well that’s not the case but since the team I am working with grew to around 22 developer, which i believe considered the biggest php team in one company in Egypt, things were going so crazy, lots of projects going, lots of new approaches, new integrations, and i have to be on top of it all the time.

meanwhile i am driven by four ideas for projects that i believe is gonna make a little difference in their business areas, I am prototyping each one of them, jumping from one to other, I launched one of them already which is www.lamptag.com, which is simply a crawler for LAMP resources and related technologies, after less than a month from launching he prototype, the feedback is good, the twitter page reached 100 follower. and the number of clicks on the links is good too.

Soon i will blog about the recent challenged i have encountered in the field, weather they are technically or management related.

Installing Java plugin for Firefox on Ubuntu 10.10 (Maverick)

Again after upgrading from Ubuntu 9.10 to 10.4, I had some issues getting Java to work with Firefox, after checking the software center, I found that the Java plugin for firefox is not working properly which broke my vpn connection.

To get this fixed, I simply followed the steps :

1- Backup your repositories files.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

2- Open your repositories file:

sudo gedit /etc/apt/sources.list

3- Add the following line then close the sources.list file

deb http://archive.canonical.com/ubuntu maverick partner

4- Uninstall both icedtea6-plugin and openjdk-6-jre.

sudo apt-get remove icedtea6-plugin openjdk-6-jre

5- Install sun-java6-plugin

sudo apt-get update
sudo apt-get install sun-java6-plugin
sudo update-alternatives --install /usr/lib/mozilla/plugins/mozilla-javaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-6-sun/jre/lib/i386/libnpjp2.so 1

6- Close your firefox and reopen it again, it should be working smoothly.

Backup / Increase the Guest OS Drive on VirtualBox

Tried to search online for a way to increase the size of a vdi image, and there was no solution available online to do so.
I had windows XP installed on a virtual machine for mail, and testing purposes on the most hated IE6, and the drive ran out of a space, no solution or work around helped me increase it, all the solutions to modify the partition table, etc didn’t work for me.
Here is the simple steps i followed :

  • Add Another Disk Drive to the Guest OS
  • Backup the Guest Operating system drive using Norton Ghost to the newly added drive.
  • Copy the backup to a DVD image (I had to move it to the host drive first)
  • Make a new Virtual Machine with the new size you want.
  • Boot the new machine using Norton Ghost drive, and attach the DVD image with the created backup.
  • Restore the backup from the DVD created using Norton Ghost.
  • Restart the machine and you should have a working.
  • Delete the created DVD image, the extra hard disk, and the old machine.

If you have a shorter solution, please share 🙂

Installing Zend Server on Ubuntu 10.04

I have been having issues trying to install Zend Server on Ubuntu 10.04 following the steps here http://files.zend.com/help/Zend-Server-5-Community-Edition/zend-server.htm#deb_installation.htm
the problem was because there is a missing dependency for the “libmysqlclient15off” MySQL client library

to solve this, I had to install “libmysqlclient15off” from here (select the one that matches your architecture)

http://archive.ubuntu.com/ubuntu/pool/universe/m/mysql-dfsg-5.0/

Then install it using the command line :

dpkg -i libmysqlclient15off_5.1.30really5.0.83-0ubuntu3_i386.deb

after that running the installation for Zend server from through repositories, will work with no interruptions.

Compress and Split large files under Linux

One of the common problems i used to face is transferring large files from Linux through mediums that doesn’t support large files, especially when it comes to more than 100 GB files, usually that is a virtual machine hard disk, or backup file.

To compress and split files under linux, this command can be used:

tar -cvj large-file.dvi | split -b 1000m -d - "small-files.tar.bz."

This command will compress and split the “large-file.dvi” to many files with size 1000mb for each, giving it the name “small-files.tar.bz.0, small-files.tar.bz.1, etc….”

To join the files together again, this command can be used:

cat small-files.tar.bz.* > large-file.tar.bz

and to extract the output file :

tar -xvj large-file.tar.bz

Recruitment System – One of my projects

I wanted to post this since a while.

The recruitment system is one of the applications I built for cha-international while working there beside developing the Middle East & North Africa travel awards system, mail marketing system, and converting all their servers from windows to Linux.

In brief the system has the following features :

  • Backend :
  1. Managing countries, Nationalities, Languages, World Areas, System Announcements.
  2. Managing Education Levels, Industries, Titles, Departments, System Reply Messages, Candidate Status, Candidates Classifications, and Quotes.
  3. Testimonials section where the company can post its clients testimonials to be displayed in the frontend.
  4. Managing 2 types of resumes : Uploaded Attachments, and Detailed filled forms Resumes.
  5. Easy form for the data entry team to add the resumes from the backend.
  6. Searching for candidates, using simple forms like name, email or advanced one which contains name, different nationalities, different languages, age, sex, industry, title, keyword in resume, etc.
  7. Consultants area where they can post / close job posting, search  for candidates, export word version of resumes, add to their favorite list, recommend them to another consultant.
  8. Consultants also can comment on the resumes, change their availability status to be seen by other consultants, and communicate with the candidate through the reply messages and keep track of those sent messages.
  9. The system has a approval workflow engine, the admins have to check the resume to approve it first.
  10. The system has a privileges section where the administrator can create a new role, assign access to certain areas in the backend to certain role, and assign the roles to system users.
  11. Feedback system where the backend users can communicate with the administrator for support tickets, etc.
  12. Auditrail system where every action in the system is logged.
  • Frontend:
  1. Simple upload form where users can just upload their resume and simple details.
  2. Advanced profile form where users can fill in all the details, and add many attachments to their profiles.
  3. Listing, Simple search, advanced search for jobs, and applying to them.
  4. Clients area where they can request certain services.
  5. Featured profiles, where a certain profiles selected by the admins showed in frontend.

The project was completely built from scratch using Zend Framework, and right now it has more than 70,000 applicant in its database, and the system is as fast as you see in the videos, these demos were taken with 50,000 record in the database.

Please don’t give me any feedback on the design ;), I am just a developer.

Here is some videos describing the different features of the system, I will try to post a better quality ones later.

 

Change your Signature

[youtube=http://www.youtube.com/watch?v=KXMg4q43Vf0]

 


Search Resumes

[youtube=http://www.youtube.com/watch?v=UUCuQ3XZmHg]

 


Apply as New Candidate

[youtube=http://www.youtube.com/watch?v=UNMVIahQAeU]

 


Send Feedback to support

[youtube=http://www.youtube.com/watch?v=-QiwYphCi2k]

 


Consultant Functionality walk through

[youtube=http://www.youtube.com/watch?v=wU6MDYO-xsw]

 


Check who applied for your job

[youtube=http://www.youtube.com/watch?v=X7_ZNVjksKg]

 


Apply for Posted Job

[youtube=http://www.youtube.com/watch?v=B06xlZr8A-w]