Tuesday, April 17, 2012

Force Virtualbox Display in Fullscreen

I have a dual display setup with virtualbox.  In fullscreen I found that virtualbox would switched onto my smaller display.

This can be adjusted.

1) Switch to fullscreen with Virtualbox
2) Use the combination of your "host" key + "home" key. (right-ctrl + home) in my case.
3) Go to the "view" menu item -> "virtual screen"
4) Select the appropriate monitor.
5) If the size of your display varies,  you will have to go out of fullscreen and back into fullscreen to re-adjust the workspace to the correct size.


Thursday, April 12, 2012

yum crashed with python import error - fixed corrupted rpm database

I ran into an interesting error while trying to find out, which repository one of my installed packages came from.  Before we proceed, let me explain that I had need to use the "repoquery" utility which is part of the "yum-utils" package.  I proceeded to install this one as I did not yet have it.  The installation worked perfectly well and did not install any dependencies.

# yum install yum-utils -y

Using the repoquery command, I attempted to query which repo my php53 package came from:

$ repoquery -i php53

Instead of getting the information I wanted, the script crashed with the following error:

File "/usr/bin/repoquery", line 38, in
from yum.i18n import to_unicode
cannot import name to_unicode

Googling around, many blog posts and site talked about the yum installation being broken.  That may well be, but I decided to see if maybe there was something a bit simpler at play here.  First I needed to find out which yum packages are already installed on this system:

# rpm -qa | grep -i yum

yum-fastestmirror-1.1.16-16.el5.centos
yum-3.2.22-37.el5.centos
yum-updatesd-0.9-2.el5
yum-utils-1.1.16-16.el5.centos
yum-metadata-parser-1.1.2-2.el5

NOTE: The listed version numbers do not reflect the original numbers I had on my system.  I went ahead and attempted to update all of the above listed packages:

# yum update yum yum-fastestmirror yum-updatesd yum-metadata-parser

Yum only found that yum and yum-fastestmirror needed to be updated.  I proceeded with the update.

After the update, the repoquery command started working perfectly well.  However, a completely unrelated problem occurred which I will discuss very briefly.

# repoquery -i php53

Instead of getting a nice listing of information from the RPM database, I received an error message saying the database was corrupted.  The next step then was to rebuild the dabase.  

The database files are located in "/var/lib/rpm" and are named __db.001 __db.002 etc... etc...

Delete those files:
# rm -f /var/lib/rpm/__db*

Rebuild the database:

# rpm -vv --rebuilddb

Once completed, I tried the repoquery command once again:

# repoquery -i php53

Name        : php53
Version     : 5.3.3
Release     : 1.el5_7.6
Architecture: x86_64
Size        : 3591477
Packager    : None
Group       : Development/Languages
URL         : http://www.php.net/
Repository  : updates
Summary     : PHP scripting language for creating dynamic web sites
Description :
PHP is an HTML-embedded scripting language. PHP attempts to make it
easy for developers to write dynamically generated webpages. PHP also
offers built-in database integration for several commercial and
non-commercial database management systems, so writing a
database-enabled webpage with PHP is fairly simple. The most common
use of PHP coding is probably as a replacement for CGI scripts.

The php package contains the module which adds support for the PHP
language to Apache HTTP Server.


Monday, April 2, 2012

Convert Blocks to Bytes

Very easily 

=========== CONVERT FROM BYTES TO BLOCKS =========== 

For example:

100 Megabytes = 1024 x 1024 x 100
---------------------------------
1 Megabyte = 1024 x 1024 x 1
1 Kilobyte = 1024 x 1
1 Byte = 1

A block is a set quantity of bytes. For example, a mounted partition could have blocks of 4096 bytes or 4k.

Typically however, quotas will have a block size of 1024 bytes ( 1k ).

To calculate the quantity of blocks for quotas you should allocate blocks using the following formula:

Allocate 100Mb of space to a user:

1024 x 1024 x 100 = 104,857,600 (in bytes) = 100Mb

Divide the number of bytes by the block size:

Block size of 4096: 104,857,600 / 4096 = 25,600 blocks

Block size of 1024: 104,857,600 / 1024 = 102,400 blocks

25,600  blocks = 100Mb if your block size is 4096 (unlikely for quotas)
102,400 blocks = 100mb if your block size is 1024

=========== CONVERT FROM BLOCKS TO BYTES ===========

Now determine how many Megabytes a quota of 262144 blocks equals:

1) 262144 multiplied by the size of the blocks:
262144 x 1024 = 268,435,456 (number of total bytes)

2) Since we are dealing with megabytes, divide by 1024 x 1024
( 268,435,456 / 1048576 ) = 256