Virtual Machines in Linux

Posted by John
on Sunday, 20 July 2008
Download VirtualBox

Download VirtualBox, binary link will redirect you to Sun's site.

Installing

For me, I needed to install libqt3-mt before I could successfully install the 64bit package,

sudo aptitude install libqt3-mt

Now Install your download with...

sudo dpkg -i virtualbox_1.6.2-31466_Ubuntu_hardy_amd64.deb

Further note, you may need to recompile the VirtualBox kernel module if a previous install failed or you didn't have the necessary dependencies first time; this is done by:

sudo /etc/init.d/vboxdrv setup
Permissions
  • Goto System / Administration / Users and Groups
  • Click 'Unlock'
  • Enter your password and click to 'Authenticate'
  • Click 'Manage Groups'
  • Find the 'vboxusers' group and click properties for it
  • Make sure there's a checkbox next to your name within that group, so you are part of the 'vboxusers' group

You will have to reboot your machine for the change to take effect.

USB Support

By default USB support is disabled, to enable it;

sudo nano /etc/init.d/mountdevsubfs.sh

Inside you'll find a block looking like;

# Magic to make /proc/bus/usb work
#
#mkdir -p /dev/bus/usb/.usbfs
#domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
#ln -s .usbfs/devices /dev/bus/usb/devices
#mount --rbind /dev/bus/usb /proc/bus/usb

Edit it to look like;

# Magic to make /proc/bus/usb work
#
mkdir -p /dev/bus/usb/.usbfs
domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

(basically uncomment the last four lines)

Save changes and close the file (CTRL+X and Y)

Create a VM

Applications / System Tools / Sun xVM VirtualBox

Scroll down and click 'I Agree' on the licence agreement, then fill in the registration information to use VirtualBox, first time.

The rest is pretty self-explanatory if you've used other VM packages like OSX Parallels or Microsoft Virtual Machine.

  • Click 'New'
  • Enter a name for your VM, choose the target platform you're going to use it for
  • Choose Base Memory
  • Create a new Virtual Disk Image, click 'New'
  • Click 'Fixed Size' (for simplicity), 8GB should be enough for starters, you can choose 'Dynamic' which will grow or shrink the disk image based on usage
  • Click 'OK' then 'Finish' to build the Virtual Disk Image
  • Once the image has been created (may take 5+ minutes) it will show the new disk image in a listbox for selection, make sure it's selected and click 'Next' then 'Finish'

You now have a virtual machine ready for whichever ISO or CD-ROM install you wish to place on it. You can hit Machine / Settings / CD-ROM to select an ISO image to boot from so you can install from a disk image.

Note: Even if you're running on a 64bit machine, the virtual machines will still operate under a 686 (32bit) platform.

All the best,

(originally based on a guide from Ubuntu Geek)

Using ZFS with Leopard

Posted by John
on Monday, 21 January 2008

With the inception of Sun OS 11 has come the much hoped 'dream' file system, the Zettabyte File System.

This wonder offers the ability to self-heal files, repair file corruption transparently, resize partitions on-the-fly, hot-swappable, RAID built-in and dynamic encryption. A real swiss army knife for file storage.

It also protected the files of billions when the Joyent service StrongSpace went down (now back up), thankfully data was kept under ZFS so it was all safely protected and restored without loss.

Apple are saying they'll have the ZFS file-system available with a future update (maybe 10.5.2) but if you're not scared of delving into the terminal then try installing it for yourself.

Remember this is all Alpha so not fully finalized but workable to use.

Installing the Binaries

first off, get these from...

once downloaded, go into the Terminal and navigate to the unzipped directory, you should see a 'build' directory in there.

Now to add them to your O/S, run...

sudo cp build/Release/zfs /usr/sbin/zfs
sudo cp build/Release/zpool /usr/sbin/zpool
sudo cp build/Release/libzfs.dylib /usr/lib/libzfs.dylib

Now we need to destroy any existing builds of ZFS on your machine, if existing...

sudo /bin/rm -rf /System/Library/Filesystems/zfs.fs /System/Library/Extensions/zfs.kext
sudo cp -R build/Release/zfs.fs /System/Library/Filesystems/zfs.fs
sudo cp -R build/Release/zfs.kext /System/Library/Extensions/zfs.kext

Great, now navigate to the copied files locations and make sure they have ROOT WHEEL access via...

ls -la [dir / filename]
ls -la zpool

You should see in there a column for 'ROOT WHEEL', if it's the case with all six areas your set.

Reboot and you'll be ready to start.

Building a ZFS Memory Stick

Now for this experiment I'll convert my memory stick over to using the ZFS file system.

So first off, fire up Terminal again and type...

diskutil list

This will list all disks available to the system, so in this case my 8gb stick has it's disk called : /dev/disk1

So I partition it with ZFS doing...

diskutil partitiondisk /dev/disk1 GPTFormat ZFS %noformat% 100%

Then create a simple spool for it..

zpool create stick /dev/disk1s2

...note the previous command will list the disks within this ZFS drive, one of them will be our 8GB partition, hence /dev/disk1s2.

...and stick will be the name of our new ZFS disk drive.

Next up we'll need to upgrade the ZFS spool, as by default the current build will create using version 6 for backwards compatibility of the ZFS structure so we'll upgrade it to 8 doing...

zpool upgrade

Excellent, now before you start dragging and dropping into the new stick drive on your desktop let's set some permissions so you don't have to authorise every file action.

So in the desktop, select the stick drive and press Option+J to see it's disk options.

On the bottom of the popup you'll see 'Permissions', click the padlock icon to unlock these, type in your system password and set the System and Wheel to both have R/W access.

Excellent, now you can drag & drop, delete files from the ZFS disk as if it was a normal disk drive.

Ejecting the ZFS Stick

Before you pull your USB stick out of your computer and cause a panic error, make sure to run this command to eject the drive.

sudo zpool export -f stick

Replace 'stick' with the name of your ZTS spool drive.

Deleting Trash from my Stick

There's bug in the current build so clearing your trash on a ZFS drive isn't exactly easy, so back in Terminal...

cd /volumes/stick

And now find the .Trashes directory with..

ls -la

Now delete the .Trashes directory to clear your trash,

rm -rf .Trashes

Bingo, job done.

Closing Points

Because of how the way our simple ZFS drive is structured, it performs lazy writes much like a usb drive in Windows; the user gets told the file has been commited but really it's waiting around to action.

By forcing a zpool export you are essentially telling the ZFS spool to finish any pending operations and eject the drive safely.

Some time in the future this'll be a much simpler process but for now it's pretty decent having this file system available to keep your files safe.

Looking forward to the final release.