How-To: Setup a Pre-Built VirtualBox Guest Image [Tutorial/Guide]

2010 February 6

Table of Contents

Introduction

This guide will assist in loading a pre-built VirtualBox image. The example used is a pre-built Ubuntu 9.10 “Karmic Koala” guest image. Any VirtualBox image can be used however.

read more…

Shrinking a Dynamic VirtualBox Disk Image

2010 February 4
by SendDerek

I hadn’t realized this before, but you can shrink a dynamic VirtualBox disk image. This is incredibly helpful if you’ve uninstalled programs or freed up a bunch of space and you want the .vdi image size to reflect that. Otherwise, the dynamic disk image will stay the same size it was before. The process is simple, but can be a bit involved so I’ll just touch on the basics and then refer you to a few guides that were really helpful when I did this for my Ubuntu 9.10 VirtualBox image. These guides can be applied to other guest images as well.

1.) Install “zerofree” on your virtualbox guest machine.
2.) Boot to safe mode (recovery mode) where you can access your root partition (/dev/sda1).
3.) Mount the root partition as read-only (mount -o ro /dev/sda1 /mnt/tmp)
4.) Run “zerofree /dev/sda1″
5.) Shutdown the virtual machine and run “VBoxManage modifyhd –compact /path/to/virtualboximage.vdi”

In-Depth Guides:
http://maketecheasier.com/shrink-your-virtualbox-vm/2009/04/06 — Keep in mind that zerofree does in fact support ext4 (I think this article is a tiny bit dated, but it’s a great one).

http://www.virtualbox.org/manual/UserManual.html — The all important VirtualBox Users Guide.

http://forums.virtualbox.org/viewtopic.php?p=29272#29272 — Another good reference for VirtualBox

Count in Sequence from X to Y in Terminal with seq Command

2010 February 2
by SendDerek

You can count up or down easily in the terminal using the command seq.  Combine this with a for loop and you have a really quick and easy way to count from x to y for the variable i.  For example, if I wanted to download all images that have been numbered step1.png, step2.png, step3.png, …, step20.png I could use the following command to download them:

for i in $(seq 1 20); do wget http://website.com/images/step$i.png; done

Mac OS Users:
Unfortunately, ’seq’ isn’t included on Mac OS, so you’ll need to use the ‘jot’ program or cleverly use the ‘jot’ program in a script to mimic the ’seq’ command and syntax like so (thanks to Fredrick Rodland for this one):

#!/bin/sh
# Fredrik Rodland
# dev_____AT____rodland.no
# http://rodland.no
# 20081004

MIN=$1
MAX=$2
PAD=$3
LENGTH=${#MAX}

if [ $PAD ]; then
     W="-w %0$LENGTH""d"
fi

let NMB_STEP=$MAX-$MIN+1
jot $W $NMB_STEP $MIN

If you’re a Mac user, I would recommend that you copy and save this to a file, save it as seq, make it executable with ‘chmod +x seq’, and finally copy it to your /usr/local/bin directory with ‘cp seq /usr/local/bin’.

Family Trip to Tonto Natural Bridge [Photo Album]

2010 February 1

Hello Family and Friends!

Last Sunday, we decided to take a well-deserved family trip to somewhere random and different.  Heather suggested Payson, AZ, so that’s where we went!  Turns out, it was a really great idea.  We all had a ton of fun and saw some different sights (like snow and pine trees and plant life other than saguaro cacti).  It was really amazing the change of scenery after traveling north for only an hour.  The Tonto Natural Bridge was just awesome; it had really nice trails, facilities, picnic tables with BBQs, and roads.  It’s a shame that they’ll be closing it down June 3rd.

I have been getting in the habit of commenting on the photos themselves, so I hope you have a chance to read them.  Enjoy!

IMG_1255IMG_1315IMG_1319IMG_1343

Example of Search and Replace New Line/Special Characters in vi

2010 February 1
by SendDerek

Today I learned a few more things about vi while working on an HTML page like how to replace with \n (newline). Basically, you need to escape special characters with a backslash “\” but the < and > characters don’t need to be escaped. To give a newline, you simply hit which will give you “^M”. So, my full search and replace command looked like this:

:%s/<\/td>/<\/td>^M/g

Breaking it down… The “%” tells vi to apply the following command to the entire document. The search and replace command is s/search/replace/g where the “g” means global (replace all instances of the search term with the replacement term, not just the first instance).  In the </td> HTML tag, the forward slash must be escaped with the backslash character and the newline character ^M is created using <ctrl+v><ctrl+m>.