VirtualBox VDI to Physical Machine

9 12 2009

Thanks to klaus-vb of #vbox channel in freenode.org, this guy gives me a huge help accomplishing this task.

Now back to the topic, I’ve seen several howtos for converting VMDK to VDI and from Physical Drive to Virtual, but after almost a day of research, I can’t find any way to convert an existing virtual VMDK, VDI to physical drive as fast as it can be made. After hanging-out in the #vbox channel in irc.freenode.org,  klaus-vb gave me a hint how to accomplish this without a fuss. Here it is:

1. Make sure that the VDI has no current snapshot or whatsoever and it’s currently inactive.

2. In my current example, I’m planning to transfer my Ubuntu 8.04 Server from VDI to Physical Hard Drive.

3. If your currently in the target machine and using recovery liveCD such as systemrescueCD you can execute the following:

VBoxManage -q internalcommands converttoraw /home/username/.VirtualBox/HardDisks/Test.vdi Test.raw
dd if=Test.raw of=/dev/sdc bs=64k

Please note of the exact name and target drive.

4. After that modify the physical drive and make the  root ( / ) partition bootable and reinstall grub MBR on that drive.

5. You also need to reconfigure  the /etc/fstab of the target drive if it doesn’t boot on your initial test.

6. Done.





ZTE MF627 on Ubuntu 9.10

3 12 2009

I don’t know if its just me or what, but I got hard time fixing my ZTE MF627 mobile modem to be able to work on my newly installed Ubuntu 9.10. Just like before using the usb_modeswitch. Although I already configured it as i did before  in Ubuntu 9.10 and openSuSE 11.1. But now, I’m encountering this problem that the modem is properly configured but not detected by the NetworkManager. Problem was the /usr/share/hal/fdi/information/10freedesktop file does not properly declare the MF627 modem, so I just modify  the following code:

<match key="@info.parent:usb.vendor_id" int="0x19d2">

 .......

 <!-- ZTE MF628 HSDPA USB dongle -->
 <match key="@info.parent:usb.product_id" int="0x0015">
         <match key="@info.parent:usb.interface.number" int="3">
                <append key="modem.command_sets" type="strlist">GSM-07.07</append>
               <append key="modem.command_sets" type="strlist">GSM-07.05</append>
         </match>
 </match>

Currently, I don’t need the MF628 config, so I think  I just modify it from product id 0×0015 to 0×0031.

In addition, I found a quick way to configure my ZTE MF627 modem using the  zte-mf627-switch package by  Liam Green-Hughes  (http://www.greenhughes.com/content/zte-mf627-easy-way)

To add the personal package archive, do the following:

1. Add the repos via console

sudo echo "deb http://ppa.launchpad.net/liamgh/ppa/ubuntu jaunty main" >> /etc/apt/sources.list
sudo echo "deb-src http://ppa.launchpad.net/liamgh/ppa/ubuntu jaunty main" >> /etc/apt/sources.list
 

2.  Then import the public key

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 187f34b24a23a1ac

3.  then update the current repo configurations and install the package

sudo apt-get update && sudo apt-get install zte-mf627-switch

4. Restart the system to properly check if automatically detects the modem, even in NetworkManager.

5. Done.





Recover data from a RAID partition

26 10 2009

Raids and LVM  are very vital to a Linux server, but then again it’s one hell of a complex step recovering data from a crashed linux system. In this tutorial, I’ll try to help you recover your data on a RAID partition.

But first, let me discuss the tool I’ll be using, for this tutorial, I will use SystemRescueCD, a gentoo-based system recovery distro which for me is the far easiest tool in recovering crashed system. So back to our topic, here’s how:

1. After a clean boot on your SystemRescueCD liveCD, create your /etc/mdadm.conf

mdadm --examine --scan /dev/sda1 >> /etc/mdadm/mdadm.conf

2. Check your /etc/mdadm/mdadm.conf , it must contains something like this:

ARRAY /dev/md0 level=raid1 num-devices=2 UUID=a28090aa:6893be8b:c4024dfc:29cdb07a

3. On the last part of that line, add the following:

ARRAY /dev/md0 level=raid1 num-devices=2 UUID=a28090aa:6893be8b:c4024dfc:29cdb07a devices=/dev/sda1,missing

The string /dev/sda1 is the hardware device and missing means that the second disk in this RAID array is not present at the moment.

4. Now, start your raid setup

/etc/init.d/mdadm start
/etc/init.d/mdadm-raid start
 

5. Check if the device is properly configured.

cat /proc/mdstat

It should contain something like this:

md0 : active raid1 sda1[1]

6. If from the raid setup, then the inner filesystem is ext3, then you just need to mount it to a temporary directory

mount /dev/md0 /mnt/recover

7. Done.


smb://rnartos@server/scan/uicscn4182.pdf mdadm –examine –scan /dev/hda1 >> /etc/mdadm/mdadm.conf




Autorefresh CUPS printers

5 10 2009

This cron script will automatically reactive all disabled CUPS printers. In our office it’s a daily problem when a faulty start or  a minor operational problem might deactivate the  said printer/s. This scripts will help you automatically enable all disabled printer Hope this work 100% for your CUPS configuration.

#!/bin/bash

CHECK_CUPS=`lpstat -r | grep running`
if [ "x$CHECK_CUPS" = "x"  ]; then
  echo "CUPS is currently not active...exiting"
  exit
fi
echo "Activating known printers..."
LIST_PRINTERS=`lpstat -p | grep since | awk '{print $2}'`
for printername in $LIST_PRINTERS; do
   echo "Activating $printername ..."
   cupsenable $printername > /dev/null
done




Thunderbird Reply and Forward Messages Header

18 09 2009

Although in our office, I’ve already implemented a webmail  using AfterLogic’s WebMail PRO, there’s still few managers who still prefer Thunderbird as their e-mail client. Few months or years ago I’ve already encountered this optional things that  REPLIED or FORWARDED messages should also include:  Date and Time info. Not a big deal but might be a helpful tool to track down messages.

Here’s what I’ve discovered to have it included in your REPLY or FORWARDED messages:

1. Click  EDIT –> Preferences
2. Then of the listed tabs, select ADVANCED, then on General tab, click CONFIG EDITOR
3.  A new dialog box will appear, on the FILTER section type:

reply_header_type

4. Click the listed configuration shown below.
5. On the VALUE of the configuration, the default is  1
6. Double-click the shown configuration and replace the value to 2
7. Much similar to step 3 – 6, but now search for:

forward_message_mode

8. Done.





Default Papersize in Ubuntu and OpenOffice 3.x

10 09 2009

It is indeed very frustrating to know that you have to manually configure the default papersize both for Ubuntu and OpenOffice to have it what you want it to. As for me I need to set the default papersize to letter (8.5″ x 11.0″), which is widely used here in the Philippines (I know in some country it’s A4 nowadays.. in that case, don’t be bothered with this problem).

Oh well… here’s the tricky way to fix this problem:

  1. On console, execute the command:
     $> sudo paperconfig -p letter

    that will set the current system-wide papersize to letter(8.5″ x 11.0″).

  2. But still, even after you configure the default papersize to LETTER, openOffice.org doesn’t seems to care, so we need to configure them manually (again). First, open a blank document on OpenOffice.org Writer.
  3. Then setup the margin and pagesize as you prefer.
  4. Afterwards, when everything you wanted are configured, save it in a template (not the simple document template, but OpenOffice wide template), Goto FILE → TEMPLATES → SAVE

    File-Template-Save

    File-Template-Save

  5. Enter the name of your template, for now let’s call it “papersize-writer”
  6. To set it as the default format/setup, Goto FILE → TEMPLATES → ORGANIZE
  7. Select the name of your template “papersize-writer” , then right-click on it and select
    “SET AS DEFAULT TEMPLATE”
  8. Your done, after a full restart of OpenOffice.org, it should be defaulted to what you’ve previously set.
  9. You can also set the papersize defaults for OpenOffice Calc
  10. Done.




Disable IPV6 on Ubuntu 9.04

26 08 2009

I’ve been looking for ways to disable IPV6 without installing unofficial kernel in Ubuntu 9.04 (I think IPV6 embedded itself in kernel and not as a module). All those /etc/sysctl.conf modification up to the additional option in grub’s menu.lst are not working either.  So I come up with this idea using the stardard ip command.

The script should be runned as root to make it work without interaction (Adding it to root’s cron job) or you must specify sudoers to skip password asking for this running ip (which is a bad idea by the way).

Here’s my script:

#!/bin/sh
# Manually disables IPV6 in Ubuntu 9.04 without  unofficial Kernel update
#====================
# Hardc0l2e (c) 2009
# ronartos@gmail.com

ADDR_LIST=`ip -oneline -6 a | awk '{print $4 " dev " $2}'`
echo "$ADDR_LIST" | while read line
do
 sudo ip addr del $line
done

Done.





700Mb Xvid on mencoder

19 08 2009

Tried many linux tools to create at least 700 – 800 Mb xvid/divx  video from DVD or MPEG source, although I am successful in conversion process, but the problem is the quality. I tried FFMPEG, AVIDEMUX and then lastly MENCODER, and got this conclusion that MENCODER is the perfect tool for me.

Converted a movie into three (3) version of XVID using the three said tools and compare its quality, and on my test, I found out that MENCODER do it best. Here’s my setup:

mencoder <source file/device> -ovc xvid -oac mp3lame -xvidencopts pass=1 -o /dev/null
mencoder <source file/device> -ovc xvid -oac mp3lame -xvidencopts pass=2:bitrate=-700000 -o <file.avi>

Still I can’t make a perfect 700MB sized xvid file but the 800MB is not bad either.

Done.





Vmware to Virtualbox Migration

11 07 2009

Most of us already know the power of Virtualbox and with the release of 3.0.2 (July 10, 2009). The new version are now more stable than before. With all the fuzz in VMware Server 2.x etc. I think for me it’s now time to migrate from VMware to Virtualbox, but the question is, How can we move out from VMware and migrate to Virtualbox together with our current VMs?

Here’s how:

1. Please note this! Remove the VMware toolbox from guest OS /VM first before doing the next step. Leaving VMware toolbox installed might fail this procedure.

2. Example your VM’s folder is called “myVM”, from console place your current location to that folder by doing:

cd myDisk

3. Multiple dynamic vmware disk needs to prepare first before the migration. You need to perform the following to organize it into a single file.

vmware-vdiskmanager -r mydisk.vmdk -t 0  output.vmdk

4.  The follow up with the Virtualbox clone command

VBoxManage  clonehd  output.vmdk mydisk.vdi

4. Finished! If you are in Linux, the VDI file will be created under ~/.VirtualBox/Harddisks/

5. Completing the process, create your new Virtualbox VM using the migration  VDI disk.

6. Done.





SANE sharing in Ubuntu

10 07 2009

I’ve been an openSuSE user for almost 3 years, and just recently shifted to Ubuntu not for feature wise but for “just work” advantage, and upgrade management is a breeze. Now, back to the topic. Configuring SANE in openSuSE is somewhat much easier than in Ubuntu because of YAST (Yet Another Setup Tool). Installing and sharing a scanner to network is easy as 123. But in Ubuntu, you have to do it manually on SANE configurations. Few kicks more and you will learn it with this HOWTO:

1. Install necessary packages to share SANE over the network. You need to run it in xinetd, to install it run the usually apt-get
command.

         sudo apt-get install xinetd

2.  Then create a sane xinetd service

sudo vi /etc/xinetd.d/sane

3.  Enter the following code as ease. Note the you have to use root in the user and group option

service sane
{
   socket_type = stream
   server = /usr/sbin/saned
   protocol = tcp
   user = root
   group = root
   wait = no
   disable = no
}

4. Then restart the xinetd service.

sudo /etc/init.d/xinetd restart

5.  To access the shared scanner over the network, modify the client’s /etc/sane.d/net.conf and add the IP address of the SANE
server/host.

6. Done.

sudo apt-get install xinetd