Archive for the ‘Fedora’ Category

Virtualbox Virtual Bridging

Saturday, November 22nd, 2008

I’ve been using VMWare for the last couple of years. What I really liked about it was that when you ran the vmware-config.pl script, it would automatically set up interfaces for the virtual machine to interact with the host OS. What I didn’t like was that the guest OS was so slow. I heard about Parallels, and from what I’ve seen, it’s a very slick and had a great feature that allowed you to switch to seamless mode. In this mode, you could run applications with the illusion that you were running the application within the guest OS, in my case Linux.

Since I was running Linux, Parallels was not an option for me. Instead I dug in and found a Virtualbox. This VM also had the seamless mode feature which I’ve grown to really love and has become a key feature that I look for. Another great advantage of the VM is that it’s fast, really fast! It seems so fast, that it’s almost like running Windows XP (for example) right on my hardware. Plus, booting Windows XP is so much faster than if I were to install it and load it right from disk.

Enough about Virtualboxes feature. What I’m really doing is describing how to get the guest OS to access the host OS file system through samba.  By default, Virtualbox uses the IP of the host OS to get online. This is fine and dandy, but what if you wanted to access shares on the host from within the guest OS? This is how you do it:

  1.  Make sure that the kernel has 802.1d Ethernet bridging and that Universal TUN/TAP device driver support is either compiled into the kernel or as a module.
  2. Login as root
  3. create the device. The output will tell you that the device has been created and the ID of the person who owns it:
    # tunctl -t tap0 -u username
    Set tap0 persistent and owned by uid 500
  4. Change the permissions of /dev/tun to 666 (tun may be in /dev/net)
    # chmod 0666 /dev/tun
  5. Create the bridge
    # brctl addbr br0
  6. Add the real interface to the bridge
    # brctl addif br0 eth0
  7. Add the tunnel interfaces to the bridge
    # brctl addif br0 tap0
  8. Bring up the bridge
    # dhcpcd br0

The last part is modifying some of the guest OS’ settings. Start VirtualBox, select an OS, click on Network, make sure that the network adapter (or at least one of them) is enabled.  Change Attached to so it says Host Interface then type in tap0. Finally click OK and start the virtual machine.

If you need to add more than one interface for running multiple Virtual Machines at once,

SimpleTest

Thursday, April 10th, 2008

A while back I was working on a site, and as I was writing the back end and making sure that it works properly I thought to myself “If .NET has nunit, and Java has junit, does PHP have phpunit, or something similar?” After some digging I found the answer. The answer I found was yes! In addition to finding unit frame works for PHP I also found some for other languages like ada, haskell and so on:aunit - for Ada
hunit - for Haskell
ant-junit - Apache Ant’s optional tasks depending on junit
dbunit - DBUnit is a JUnit extension targeted for database-driven pr
ojects.
tagunit - for testing custom JSP tags
xmlunit - for XML
and so on. If you want a complete list, on the command prompt, if you’re using Gentoo, just type:

(more…)

Eclipse, PHP, and XDebug

Thursday, April 10th, 2008

In the past I’ve written how to use Eclipse with phpdbg and ZendDebugger. The phpdbg was short lived as it was replaced with xdebug. According to Zend’s website, they say that there are no serious limitations of xdebug. However, there may be some limitations when working with other Zend modules.

This is not going to be a problem seeing as all I want to do use it to debug web pages. This will work on either Windows, Linux, and possibly MacOS X.

Since posting about Eclipse and Zend, it has gotten much easier to get Eclipse and configure it for PHP. Go to Eclipse’s homepage. On the front page there is a link to download the IDE for other languages; click on that and get the one for PHP.

(more…)

Creating Commands with xargs

Saturday, February 23rd, 2008

I have a couple of folders with a ton of compressed files in them. I’m not talking about 10 or 20. No I’m talking about a couple thousand. Instead of spending all eternity uncompressing the files, I did some research into how one would go about having the command line do all the glorious work for him.

One of the requirements was that I didn’t want to decompress any Japanese files, which were indicated by ‘(J)’. However, if the file was American, European, and Japanese, then I did want the file decompressed. Another problem I had was that the indication of the type of file was clear. It could have either been UE, EU, JUE, UJE, or UEJ.

I wanted to keep the files separated, so I created another directory called dir2, which is the directory I’m in when I run the following command:

$ ls -1 /home/paulus/dir1 | grep -E ‘.*\((E|U|EU|UE|JUE|UJE|UEJ|JU|UJ)\).*\.zip’ | xargs -d’\n’ -L 1 -I ‘{}’ unzip ‘../dir1/{}’

The first command is a very well known command to anyone who has used a *nix distribution. This is listing the files in /home/paulus/dir1. The -1 is printing a list of files with one item on each line. The output is piped to the grep command.

The grep command gets a little messy with the regular expression. The . (period) is the beginning, the * (Asterisk) is saying “anything from the beginning to the first parentheses.” We have to use the back slash to escape it, otherwise it will be interpreted as a condition.

Notice how the second parentheses is not escape, that’s because we’re using it like we were if we were doing an if statement. From ‘\(’ to ‘\)’, we are using an if statement. So, return true if E or U or EU or UE or JUE or UJE or UEJ or UJ or JU are found. The ‘.*’ is saying anything after the ‘()’, then we have the extension, so we’re only looking at zip files.

Now that the regular expression is out of the way, we can move on to the xargs command. The xargs is used to build and execute command lines from input. Some programs don’t like to get data piped into it, such as the case of unzip. With the -d‘\n’ parameter, we are saying that each line is a separate argument and we are limiting one argument per command by the use of -L 1 parameter. -I ‘{}’ is saying that we are going to replace {} with an argument, such as one of the file names received from stdin. We finally get to the point where we can use the unzip command as if it were on the command line. xargs will execute ‘unzip ../dir1/{}’, but the actual command that gets sent is unzip ../dir/file.zip, where file.zip is one of the arguments that it was passed.

Software RAID, Hardware RAID, and Woes Oh My!

Wednesday, November 7th, 2007

I woke up on Halloween to the sound of my music playing. Then all of a sudden it stopped. I got up not thinking much of it. The first thing I do when I get up in the morning is check my email. When Thunderbird didn’t open and programs stopped responding I got suspicious. I dropped in to VT12 to see what was going on. What was being reported was: (more…)

Remounting Root FS in RW

Wednesday, September 12th, 2007

After finishing up an installation of Gentoo, I reboot into the new system only to find that it needs maintenance. The probably usually is that the hard drive is assigned a different device file during the LiveCD than when the actual system is booting up.

After providing the root password I need to edit the /etc/fstab file. Problem is that the file system is mounted in read only. So we must remount the root partition in read write.

mount -no remount,rw /

Now we can make the changes we need and reboot the system.