2013-07-06

virtual box

Virtual Box
Ah, another dependency picture. Graph.

But first,what's that mean?

Take a glance at the code, note the lines adding  nodes to the graph, placing a few attributes on the nodes.

URLs, like the  one on "Virtual Box", takes the visitor to the Downloads web page for the Virtual Box software.

Similarly, the "boot .iso" URL leads to the Fedora Project download page where one may grab a (roughly) CD sized .iso image to use for booting a desktop to install Fedora.

Well, not exactly. The image is just an image, but the php code should render, for instance, with a tool tip on the "dkms" node showing some of the packages needed to get all this working. Or, for that particular node, a mouse over should reveal some of the pieces to get the Virtual Box guest additions working in the guest system.

And the "Download" tab at fedoraproject.org presents the default Fedora install, with the Gnome desktop. Which is fine, but if one uses a Windows desktop, a lot, as I must do, the K desktop, or KDE, will be somewhat more familiar territory. Gnome is alright, but my preference is KDE for a few reasons, will go into those soon. But first ... the code ...


<?php

require_once 'Image/GraphViz.php';

$gv = new Image_GraphViz();
$gv->addEdge(array('virtual box' => 'startup, install'));
$gv->addEdge(array('boot .iso' => 'startup, install'));
$gv->addEdge(array('boot .iso' => 'burn CD'));
$gv->addEdge(array('burn CD' => 'startup, install'));
$gv->addEdge(array('startup, install' => 'update'));
$gv->addEdge(array('update' => 'dkms' ));
$gv->addEdge(array('dkms' => 'vbox GA' ));
$gv->addEdge(array('startup, install' => 'httpd' ));
$gv->addEdge(array('httpd' => 'virtbox.php'));
$gv->addEdge(array( 'virtbox.php' =>'pretty picture' ));
$gv->addNode('virtbox.php',
        array( 'URL'      => 'virtbox.php.html' ));
$gv->addNode('virtual box',
        array( 'URL'      => 'http://virtualbox.org/wiki/Downloads' ));
$gv->addNode('boot .iso',
        array( 'URL'      => 'http://fedoraproject.org/en/get-fedora-options' ));
$gv->addNode('vbox GA',
        array( 'URL'      => 'https://forums.virtualbox.org/viewtopic.php?f=29&t=15679' ));
$gv->addNode('httpd',
        array( 'label'    => 'httpd php graphviz' ));
$gv->addNode('dkms',
        array( 'tooltip'    => 'gcc devel dkms' ));

// draw it
$gv->image();

// *or* dump the gv object. cant do both, rats.
//print '<h4>$gv object</h4><p style="white-space:pre;">';
//print_r ( $gv );
//print "</p>\n";

?>


Note the comments, either let the .php page render the image, or one may turn on the commented code lines to see a dump of the $gv object, with an inline css style attribute so that the text for the object is a bit more legible.

As mentioned in the comment, can't do both the image and other stuff. Oh well, there's always a trade off. Maybe will figure out a way to get the graphviz image into a .php page along with other content, but there is always other important things to see, do, and learn. But first ... 

One could take the boot image .iso file, fire up a CD/DVD burn program and create a boot CD or DVD, go into the BIOS settings and put the optical drive above the hard drive in the boot order list. A totally optional step.

But in the amount of time it takes to burn a DVD, one could just about have Fedora, or Ubuntu, or Mint, or SUSE, or any distribution of linux installed, booted, and a running a new desktop. Perhaps it was Steven Wright who said "Any place is walking distance, if you have the time." Way, way back in 1984 or sometime around then. Maybe we'll go look that up for a proper credit. Soon. But first ...

Skip the waste of making another coaster, and the time. Avoiding a CD or DVD burn step completely by setting up a virtual machine in Virtual Box, point the drive to the  boot image file, and in a moment or three the install is underway.

No hassles with trying to set up a dual boot scheme on your desktop, no mucking about with making a dual boot system work, and keeping it healthy. Updates to your desktop OS may very well break a dual boot setup.

The Fedora Live boot file is easier. Fewer choices, less complicated. Following the KISS principle (Keep It Simple, Silly!) is one way to get a linux host up and running, quickly, without too much fuss. A full DVD boot .iso presents many more install options, perhaps selecting a web server if that is the desired direction one wants to go, and/or a workstation with a few (or several) developer platforms.

All at just the right price. Your time is the price, be careful how its spent. Its one of the things that does not have a "do over" option. Time is a precious resource, and once its used, its gone, there are no take backs.

Now for the downside. The Live boot file is the quick path, and choosing KDE also has drawbacks. KDE does include a web browser, Konqueror, while Gnome has Firefox "out of the box". Overall, firefox is the better browser, but KDE includes a few GUI admin tools, like a runlevel editor, an item not easily added in Gnome.

The Service Management program


For a nice tutorial showing a Virtual Box install see the SysAdmGirl Fedora 17 video, at under ten minutes, it will be time well spent.

SysAdmGirl shows Fedora 17, while 18, and (really soon now) Fedora 19 will be the primary offering at the fedoraproject download page. Oh well, there is usually a downside to everything. Fedora 18 does fit into an 8GB disk, barely, although going for a 10GB partition won't hurt. Its always good to have a bit of spare disk space in the back pocket for any system admin.

For the system memory, a one GB virtual machine is plenty of room for linux. If memory is tight on the host machine, smaller is OK but when it comes to memory, more is generally better. Especially when using a 64 bit operating system.

There are reasons for going the x64 route, but saving memory is not one of them. If the hardware does not support x64, oh well, x86 works fine. Giving the virtual guest host a full 1GB of memory is not required, and do not give it that much unless at least 4GB of RAM is available on the host machine.

One thing I do like to do on a virtual machine setup for linux, shave a bit of space from the main partition and give the space over to the swap partition, bring it up to a full 2GB. That is 2GiB, as in 2048MiB. And one could spend an hour, even more, setting up additional partitions and mount points for guest OS. But first ... more on that later.

And do not expect a particular Fedora flavour to have a particularly long life span, a new version comes out every few months, a downside of choosing Fedora. But when creating a virtual machine, for Linux, do take a moment and glance at the System properties.

One thing to point out, on the Motherboard tab note the section "Extended Features", there is a check box "Hardware clock in UTC Time". Be sure to leave that checked, its quite important. Most any unix server will have its clock on Universal Coordinated Time, a critical point with operating systems, and one of the (many) reasons unix can be a better OS than ... the competition.

Be sure to stay tuned, more on that, and lots of other things too. But first ...

2013-07-05

php graphviz

But First ...
There are always lots of things on the to-do list.

Like learn a new language ... maybe even a spoken one, not just a slightly different way to talk to the machine, in pretty much the same old (or new(ish)) way.

Or try out something new. But first ... there's always a catch.

Its time to paint the garage floor. But first, the car has to be moved. Oh, the couch is in the way as well, will have to take care of that first. But the vinyl collection has to go somewhere, the couch moves much more easily (well, that's relative, can "easy" be mentioned in the same sentence with "moving" ... ) without two hundred pounds of not yet recycled plastic ... and the floor has to be really clean so the epoxy paint can stick, for a period of at least a fortnight ...

The But First dependency diagram, or graph, was drawn with just a few lines of php code. Really. And a couple of php packages too, but first ...

 
<?php

require_once 'Image/GraphViz.php';
$gv = new Image_GraphViz();
$gv->addEdge(array('Paint garage floor' => 'but first ...'));
$gv->addEdge(array('move car' => 'sweep floor'));
$gv->addEdge(array('store LPs' => 'move couch'));
$gv->addEdge(array('move couch' => 'sweep floor'));
$gv->addEdge(array('sweep floor' => 'mop floor'));
$gv->addEdge(array('mop floor' =>'paint floor'));
$gv->image();

?>


Got the first ink-ling for that diagram in an O'Reilly book, one that has been sitting on the shelf for ... a really long time, Mastering Algorithms with Perl. Its probably out in at least a second, if not third, edition. See Chapter 8, Graphs. Maybe its time to go see if those later editions do exist, or not, but first ...

The graphviz package has lots of other stuff. With an addNode(... call attributes can be set, i.e. 'URL' => '...' turns the node into a clickable link. Different shapes to represent the node, the font, font size, fill color, quite a few more items are in there. See graphviz shape docs for the details.

With php, just the graphviz-php package is not quite enough, there is a php-pear-Image-GraphViz "Interface to AT&Ts GraphViz Tools" package which includes the Image/GraphViz.php file. And not to mention setting up httpd for php, but will leave that one for another day.