Archive for the ‘Gentoo’ 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.

Recovering iTunes Music

Thursday, January 31st, 2008

Occasionally I will get a customer in my store whose library has been corrupt or lost but their music is still on their iPod. The way that apple designed iTunes is that if the library gets messed up, you run a high risk of losing your music. Fortunately there is a way around that. What I do to save the customer’s music is take their iPod, connect it to my Linux computer. In order to see the files on the iPod, you’re going to need a few drivers either compiled as modules or into the kernel:

  • Device Drivers
    • USB Support
      • <*> Support for Host-side USB
      • [*] USB device filesystem
      • <*> EHCI HCD (USB 2.0) support
      • <*> OHCI HCD support
      • <*> UHCI HCD (most Intel and VIA) support
      • <*> USB Mass Storage support
      • [*] USB Mass Storage verbose debug
      • [*] Datafab Compact Flash Reader support (EXPERIMENTAL)
      • [*] Freecom USB/ATAPI Bridge support
      • [*] ISD-200 USB/ATA Bridge support
      • [*] Microtech/ZiO! CompactFlash/SmartMedia support
      • [*] USBAT/USBAT02-based storage support (EXPERIMENTAL)
      • [*] SanDisk SDDR-09 (and other SmartMedia) support (EXPERIMENTAL)
      • [*] SanDisk SDDR-55 SmartMedia support (EXPERIMENTAL)
      • [*] Lexar Jumpshot Compact Flash Reader (EXPERIMENTAL)
  • File systems
    • DOS/FAT/NT Filesystems
      • <*> MSDOS fs support
      • <*> VFAT (Windows-95) fs support
    • Miscellaneous filesystems
      • <*> Apple Macintosh file system support (EXPERIMENTAL)
      • <*> Apple Extended HFS file system support.

I compiled in all the things under USB support for various other things. If you don’t need them then you don’t have to compile them into the kernel.

Once you recompile the kernel or compile the modules and load them, you can connect the iPod to the computer and then mount it. When you try mounting it, it’s going to be a SCSI device. After you have mounted the iPod, Copy all the m4a files from the ipod_control folder, then re-import them into iTunes.

PHP, Zend Debugger, Eclipse

Sunday, November 25th, 2007

A while ago I wrote how you can configure Eclipse, PHP on a Linux machine to debug PHP pages using phpdbg. At first this worked very well but after a while break point wouldn’t work and I would have to restart the session. Another problem that I was having was that the session information was saved. I got around this by clearing out the session information in Firefox. This continued until one day when I tried to start a new debug session and all I got was this:

At that point I decided to dump phpdbg and start using the Zend Debugger. Getting the extension to work properly took some time. After many hours of searching the Internet I managed to find a decent site to work off of. Unfortunately, it was aimed at the Windows platform. Getting PHP and eclipse configured was half the battle that I faced.

(more…)

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…)

Gentoo on an HP Pavilion dv5000 (dv5139)

Friday, October 5th, 2007

When my Compaq Presario X1000 (X1010US) died I was sad. It took me some time to get gentoo to work correctly with the hardware. The biggest hurdle that I faced was getting the wireless to work. At the time ndiswrapper wasn’t working very well and would often either lock up my system or cause a kernel panic. The second hurdle that I faced was getting 3d acceleration to work. When I was forced to give up the ghost on my beloved Compaq Presario X1000 I ended up purcharsing a HP Pavilion dv5000 (dv5139).AMD Turion 64 ML-37 (2.0Ghz)
2×1GB DDR333
120GB 5400 RPM Seagate HD
15.4″ Wide 1280×800
ATI XPRESS 200M
8x DVD-RW DL with lightscribe
54a/b/g wireless
Bluetooth
Windows XP MCE 2005 ( which was wiped out right after removing it from the box )

Again, I was having problems with the wireless and video. The laptop has a bcm4319 chip and from what I’ve read, the native Linux kernel only has drivers that support the bcm4318 and earlier. However, I was able to get the ndiswrapper to work with the Windows drivers. The video card took a lot of monkeying around with but after many many hours I was able to get it to work. Unforunately there are some strange bugs in the driver such as once X starts you can’t switch back to the VT without seeing some tripy colours.
(more…)

Tri-Monitors

Sunday, September 30th, 2007

I’ve acquired another 19″ LCD monitor from a customer who said that he no longer needed it as the DVI IN no longer functions. Setting up Dual monitors is pretty easy. Unfortunately, there’s a problem when using Linux and multiple monitors. The problem is that the window manager does not handle them correctly (or like Windows does.)

If you’ve ever set up dual monitors on a Windows machine you can ‘Attach’ the second output via the Display Properties. There is also an option that allows you to extend the desktop to the second monitor. When you extend the desktop to the second monitor and you maximize a window, the window will take up both screens. If you simply ‘Attach’ the monitor then when you maximize the window, it will fill up the screen that it is on. There’s also a bonus here, you can drag the window to the other screen with out any problems.

In Linux you can do one of two things:

  1. You can extend the display to all the monitors, which will make all connected monitors one massive screen.
  2. Setup individual screens. The draw backs to this is that each screen will have a separate instance of the Windows Manager of your choice, you can not run multiple instances of some programs such as Fire Fox, and finally you can not drag windows from one screen to the other.

(more…)

VMWare and Gentoo Problems

Friday, September 28th, 2007

After installing vmware-server and vmware-modules I was not able to get vmware to start properly. When trying to start the vmware service:

# /etc/init.d/vmware start

I would get this:

* Vmware Server is installed, but it has not been (correctly) configured
* for the running kernel.
* Please ensure that the modules have been compiled for this kernel:
* emerge –oneshot vmware-modules
* Also ensure Vmware Server has been configured:
* /opt/vmware/server/bin/vmware-config.pl
* VMware is not properly configured! See above.

Reading through the Gentoo forums I tried removing the /etc/vmware/not_configured file and got:

* Starting VMware services:                                            [ ok ]
*   Virtual machine monitor                                            [ !! ]
*   Virtual ethernet                                                        [ !! ]
*   Bridged networking on /dev/vmnet0                           [ !! ]
*   Host-only networking on /dev/vmnet1 (background)    [ ok ]
*   Host-only networking on /dev/vmnet8 (background)    [ ok ]
*   NAT service on /dev/vmnet8                                      [ !! ]

I then tried:

# emerge -1 vmware-modules

unfortunately that did not work

I looked at what modules were loaded and saw that the vmmon and the vmnet modules were not loaded.

# depmod
# modprobe vmmod
# modprobe vmnet
Finally I added the following lines to the /etc/modules.autoload.d/kernel-2.6

vmmod
vmnet