Saturday 29 September 2012

Long range router : TL-WR1043ND and openwrt


I lost my internet wireless router 2 day ago and my spare one soon after.
I have replaced it with a TP-LINK TL-WR1043ND. It costed only € 54.

I'm astonished by the long range of this router.
All my wireless devices are working everywhere in the house and outside.
They are all working a lot faster, yes faster !
I think that even my neighbors get a better signal than for their own router :-)

It look like its power is 500mw (if you choose the right country code),
most router are between 50 to 200mw only to match the laws.
It has 3 big antennas that help for reception.

I have installed last openwrt (linux) in 3seconds (I'm a bit from Cosica)

Thumb up for openwrt that work very well ! I was using old kamikaze since 2006 on
the previous router.
The luCI web interface provide all the expected stuff.
The original firmware was also very "generous", including an impressive "parental control" screen.

I have setup my SIXXS IPv6 connection using some SSH, VI and command line, but I can see some part of the setup from the web interface.

The performances looks impressive. The WR1043ND can route up to 29Mo/s between LAN and WAN
and the USB allows up to 22Mo/s for read and write.


WBADMIN don't do incremental backup

WBADMIN use Volume Snapshot Service on both side to mimic what we have the use to call incremental backup.
  • On the source side (the disk your are backing up), wbadmin use VSS to backup blocks that have changed since the last backup.
  • On the target side (where you are backing up), if VSS is enable you can use the previous versions to access old versions of your backup. Network share don't support VSS then you cannot access old versions of your backup, you must backup in different directories. 
Every 14 days or every 14 backups, I don't remember, wbadmin does a full backup. It read all blocks on the source and overwrite all blocks on the destination.

To use the VSS feature, you must use the -vssFull switch.

If you need to do an occasional backup and don't want to disturb your daily backup, you must use -vssCopy switch (or not use -vssFull for old wbadmin than don't know the -vssCopy switch) and the historic will not be updated.

Be careful, each version of wbadmin (on W2K8, Vista, Windows 7) are a bit different and provides different switches.

If you want to use wbadmin in a script to do complex backups and send email reports you should try  MKSBackup instead. MKSBackup is a front end for wbadmin that handle multiple target directory depending the day of the backup and generate a very detailed mail report with an accurate mail subject about he success or the failure.


Tuesday 25 September 2012

Xubuntu 12.04 : failed to hibernate session not authorized

Suspend was working, but hibernate was sowing message : "failed to hibernate session not authorized".

I have created file /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla


[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

Now hibernate is working fine.



Xubuntu 12.04 and Nvidia 7300 multi-screen

After installing Xubuntu 12.04, on my old PC with a Nvidia 7300, only the monitor connected to the VGA port was displaying X. The DVI side stayed dark.

I have created a minimalistic /etc/X11/xorg.conf :



Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


And used nvidia-xconfig to customize it using :

# nvidia-xconfig --twinview  --twinview-orientation="LeftOf"

My DVI monitor (the second one) is on the left of my VGA Monitor.

That's it.
Then I have logged out and in and I got both monitors on and windows sliding between them.

For reference here is my working xorg.conf :


# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 295.40  (buildmeister@swio-display-x86-rhel47-06.nvidia.com)  Thu Apr  5 22:40:54 PDT 2012


Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "True"
    Option         "MetaModes" "nvidia-auto-select, nvidia-auto-select"
    Option         "TwinViewOrientation" "LeftOf"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection




Monday 17 September 2012

VMware ESXi fastcopy.py to quickly copy .vmdk files


Overview


fastcopy.py is a python script for VMware ESXi 4.0 - 5.x that can be used as a replacement for "cp -R" to copy Virtual Machines.
fastcopy use cp to copy normal files but use vmkfstools to copy .vmk files.
Because vmkfstools is 10 to 20 time faster to copy such files, you will see a big difference.
When copying .iso files you will not notice any difference !

The typical use of fastcopy.py is to copy multiple directories containing VMs to a target directory.
fastcopy.py don't handle recursive copy or simple file copy. Sources and target must be directories.

Usage

For example top copy one VM to a new directory :

./fastcopy.py  /vmfs/volumes/SATA1/windows2008 /vmfs/volumes/NEWSATA

or if you want to copy multiple VMs, just list all VM directories. The last one must be the target one.

./fastcopy.py  /vmfs/volumes/SATA1/windows2008 /vmfs/volumes/SATA1/linux /vmfs/volumes/NEWSATA


Installation

Cut&Paste script below to one of your datastore and don't  forget to make it executable using chmod :

chmod a+x

Here is fastcopy.py

#!/bin/python
# fastcopy.py
# copy VMware virtual machine directories using cp and vmkfstools
# (c) alain.spineux@gmail.com
# released under GPL
# usage: fastcopy.py vm_dir1 vm_dir2 ... target_dir
#
# ATTN: don't copy recursively

import sys, os, subprocess, re

def copy(srcdir, dstdir):
    skipped=0
    for filename in os.listdir(srcdir):
        fullfilename=os.path.join(srcdir, filename)
        if os.path.isdir(fullfilename):
            print fullfilename, 'SKIPPED'
            skipped+=1
            continue
        print filename
        if filename.endswith('-flat.vmdk'):
            # this is the data file, it will be copied by the .vmdk
            continue
        if re.match('.*-s[0-9]{3}.vmdk$', filename):
            # this is part of a sparse file, it will be copied by the .vmdk
            continue

        # dont use vmkfstools for snapshot files
        if filename.endswith('.vmdk') and \
            not re.match('.*-[0-9]{6}-delta.vmdk$', filename) and \
            not re.match('.*-[0-9]{6}.vmdk$', filename):
            args=['vmkfstools', '-i', fullfilename, os.path.join(dstdir, filename) ]
        else:
            args=['cp', fullfilename, os.path.join(dstdir, filename) ]
        # print args
        subprocess.call(args)
    return skipped

if len(sys.argv)<3:
    print 'Usage: fastcopy.py src_dir... target_dir'
    sys.exit(1)

srcdirs=map(lambda x:x.rstrip('/'), sys.argv[1:-1])
dstdir=sys.argv[-1].rstrip('/')

if not os.path.isdir(dstdir):
    print 'dst_dir must be a directories'
    sys.exit(1)

for srcdir in srcdirs:
    if not os.path.isdir(srcdir):
        print 'not a directory:', srcdir
        sys.exit(1)
    targetdir=os.path.join(dstdir, os.path.basename(srcdir))

    if os.path.exists(targetdir):
        print 'target dir already exists:', targetdir
        sys.exit(1)

skipped=0
for srcdir in srcdirs:
    targetdir=os.path.join(dstdir, os.path.basename(srcdir))
    os.mkdir(targetdir)
    skipped+=copy(srcdir, targetdir)

if skipped>0:
    print "SKIPPED:", skipped

Monday 10 September 2012

Ubuntu 12.04 sometime stuck in boot menu after boot failure

Ubuntu 12.04, when boot fail and maybe even when computer don't shutdown properly (no sure), grub2 stuck in boot menu at next reboot and wait for a user input.
This is very annoying for servers, just after a power cut or something else  !
To avoid this edit file /etc/grub.d/00_header and comment some line to get :

#if [ \${recordfail} = 1 ]; then
#    set timeout=-1
#else
    set timeout=${GRUB_TIMEOUT}
#fi