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/saned.d/net.conf and add the IP address of the SANE
server/host.

6. Done.

sudo apt-get install xinetd




Google Gears for Firefox 3.5

8 07 2009

This is the Unofficial release of Google Gears for Firefox 3.5. Expect bugs and instability. But from far as I’ve experienced. It’s working well on Gmail Offline. Still worth using IMHO.

Here’s the link:
http://groups.google.com/group/gears-users/msg/70f164020c0f8f4e





Modifying Display Resolution in Ubuntu 9.04

8 07 2009

Although Ubuntu might be installed and  “just work” out of the box. There’s always something that needs to configure manually. Like example adding resolution to the default and configured for your monitor. I’ve encountered this scenario when I’m trying to setup the 16:9 screen mode for my Samsung LCD monitor. The optimum resolution as stated in the LCD manual is 1360×768 on 60Hz, and on my further research on the net, I end up configuring this way:

1. On your console type:

$> gtf  1360  768 60

which means resolution for 1360×768 on 60hz. Copy the modeline  for that resolution, keep it in clipboard for awhile

2. Then backup your current xorg.conf first before modifying anything on that file.

$> sudo cp /etc/X11/xorg.conf   /etc/X11/xorg.conf.bkp

3. Then modify the /etc/X11/xorg.conf, paste the modeline settings for the 1360×768 resolution, your Section “Monitor” should now ended similar to this:

   Section "Monitor"
         Identifier  "Configured Monitor"
         Modeline "1360x768_60.00"  84.72  1360 1424 1568 1776  768 769 772 795  -HSync +Vsync
   EndSection

4. Then add that resolution to your current list of display modes. On your Section “Screen” add the following before the
EndSection

          SubSection "Display"
               ...
                Modes "1360x768"  "1280x1024"     Virtual 2464 900
          EndSubSection

5.  Save the file and restart your desktop.
6. After the reboot, try to change the default resolution on System -> Preferences – > Display. The new resolution should be
now included in the list.

7. Done.