Sunday, March 23, 2008

Installing VirtualBox Guest Additions for CentOS 5.1

VirtualBox, a virtual machine product from Innotek (recently acquired by Sun Microsystems), is a great development resource when you need to have access to different environments and platforms close at hand and under your full control. I have been using it for the past few months, hacking up Ruby on Rails applications while on Windows XP but targeting deployment for Linux (CentOS 5.x). I can easily set up and run multiple environments, all from my company-issued Dell laptop with the stock Windows XP operating system. For example, I've got virtual machines for CentOS 5.1 and FreeBSD 6.2. VirtualBox claims support for other guest operating systems, including Windows (NT, 2000, Server 2003, XP, Vista), many flavors of Linux distros (Ubuntu, Debian, SUSE, Fedora, Red Hat, et al.), Solaris 10, BSD-based OpenBSD and FreeBSD, and more.

It can be particularly useful if, like me, you are forced to develop on a Windows box but often deploy to *NIX environments. I have found it to be a drag, for example, when trying to build Ruby gems for mysql and postgresql on Windows, even with the aid of Cygwin, a Linux emulation layer for Windows. I highly recommend getting VirtualBox, and setting up a virtual environment over which you can exercise complete control.

However, for a virtual machine, there are certain things that are not simple and straightforward to do, like sharing folders between the host and guest operating systems. Thankfully, VirtualBox comes with the resources to install drivers and system applications into your guest operating system that make integration with your host, and your life, much easier. These resources are called VirtualBox Guest Additions. There are guest addition resources for Windows and Linux guest operating systems.

While the product documentation and user's forum for VirtualBox is quite good, I found precious little on how to install the guest additions for Linux correctly. Let me share with you how I quickly installed the guest additions on Linux for my CentOS 5.1 guest. My CentOS 5.1 guest is a server installation, so we are going to use the command line to do this.

1. Install the necessary packages and source so that you can compile the guest additions for Linux. Of course, you need to be root to do this:


# yum install gcc -y
# yum install kernel sources -y
# yum install kernel-devel -y


2. Mount the VBoxGuestAddtions.iso file as your Linux guest's virtual CD/DVD-ROM drive. There are a couple of ways to do this:
  • If your guest's virtual machine is not started, then in the VirtualBox main window, click on the your target guest Linux operating system to bring up the details and settings tabs. In the Details tab, click on CD/DVD-ROM to bring up Settings panel. Select "Mount CD/DVD Drive", and click the radio-button to select ISO Image File, making sure that the VBoxGuestAdditions.iso file is selected. Click the OK button, and start up your virtual machine.
  • Conversely, if your guest's virtual machine is already running, select Devices from the virtual machine console window's top menu. Select "Mount CD/DVD-ROM", and further select "CD/DVD-ROM image" in the sub-menu. The Virtual Disk Manager window for your guest operating system will appear on-screen. Make sure that the VBoxGuestAdditions.iso file is selected. Click the Select button.


3. As root, execute the following commands to mount the Guest Additions iso file as a directory in your guest operating system.

# mkdir /tmp/cd
# mount /dev/cdrom /tmp/cd


4. Navigate to the newly-mounted directory, and after confirming that the the guest addition files are there, compile and install the guest additions.

# cd /tmp/cd
# sh ./VBoxLinuxAdditions.run


You will need to restart your guest operating system now. Upon doing so, you will then be able to enjoy closer integration between your host and guest operating systems, letting you enjoy features like:
  • mouse pointer integration
  • improved video support
  • time synchronization
  • shared folders
  • shared clipboard
  • automated Windows logons for Windows guests


Personally, I make great use of the shared folders feature so that I can write code in my IDE on Windows, but immediately execute that code on Linux.

Sunday, March 16, 2008

森林公園温泉が閉館する! Shinrin Kouen Onsen is closing?


Ah, man... not only did I just remember that I completely forgot about Pi Day, I just found out that my favorite neighborhood onsen bath is closing down. Yeah, 森林公園温泉 (Shin'rin-kouen onsen) is closing its doors in April. It is small, but the facilities are clean and the hot spring water a great way to relax after a hard day of squinting at my screen and typing.

My family really like going there to soak, and we've been going there almost every weekend. It is one of the nicest things about living out here in this corner of Sapporo. It's been just about one year since we moved here, and it is kind of sad to think about life without 森林公園温泉 . I hope that maybe only the management will change hands, and the bath water will continue to flow.