Linux LVM migration

So, you have setup a nice lvm partitioning scheme to future proof life, maybe the system will have a heart attack and need a new mobo; maybe we will fill up 20TB within the next year or so; maybe we get new architecture and want to migrate our huge data store across – ah haa !

So you get the set of lvm drives into the new system, boot up and can see the drives using:

fdisk -l

Great so far so good, now what ?

Well, we dont need to know why, just do this:

pvscan (will search all lvm block devices for physical volumes)

vgscan (scans all disks for volume groups)

If you are here its because you haven’t done this before and therefore have not taken the steps to prepare an lvm migration therefore:

1 – mark the volume group inactive

vgchange -an <volume group name here>

2 – export the volume group

vgexport <volume group>

3 – import the volume group into the system (kernel)

vgimport <volume group>

4 – activate the volume group

vgchange -ay <volume group>

Job done !

You can go ahead and mount as required.

Credited source over here

Linux free memory

Ever find yourself on another Linux system wondering why is this system so slow !

I wonder what RAM is installed I hear you thinking, the answer is the ‘free’ command.

# free

This will show you the amount of free and used memory installed in your machine with the option to use the following switches:

-b this will display the output in bytes

-k again in kilobytes

-m megabytes

-g gigabytes

-h in human readable form

-t will give you column totals

-s <variable> will repeat the command every <var> seconds

Developers Time Cheat Sheet

#      300   5 MIN
#      600  10 MIN
#      900  15 MIN
#     1800  30 MIN
#     2700  45 MIN
#     3600   1 HR
#     7200   2 HR
#    10800   3 HR
#    14400   4 HR
#    18000   5 HR
#    36000  10 HR
#    39600  11 HR
#    43200  12 HR
#    46800  13 HR
#    50400  14 HR
#    54000  15 HR
#    86400  24 HR
#    86400   1 DAY
#   172800   2 DAY
#   259200   3 DAY
#   345600   4 DAY
#   432000   5 DAY
#   518400   6 DAY
#   604800   7 DAY
#   604800   1 WEEK
#  1209600   2 WEEK
#  1814400   3 WEEK
#  2419200   4 WEEK
#  2419200   1 MONTH
#  4838400   2 MONTH
#  7257600   3 MONTH
#  9676800   4 MONTH
# 12096000   5 MONTH
# 14515200   6 MONTH
# 16934400   7 MONTH
# 19353600   8 MONTH
# 21772800   9 MONTH
# 24192000  10 MONTH
# 26611200  11 MONTH
# 29030400  12 MONTH

credit given here

Asterisk dependencies

Dependencies to install asterisk from source:


once having downloaded the asterisk source file into /usr/src and untarred it. There is a useful script that can be found in /usr/src/contrib/scripts/ called ‘install_prereq’.
Pass the parameter ‘install’ and sit back !

Force fsck on reboot

If you want to instigate a filesystem check on a Linux file system during the next reboot, create a blank file called forcefsck in the root directory (/).

I would suggest running the following commands as an administrator or user with elevated permissions:

touch /forcefsck


Imapsync migration from Zimbra to Kerio

If you are setting up a new Kerio mail server and want to use imapsync to port across your emails, this following command helps to re-locate your email folders from the existing server into a nice way on your tidy new Kerio server.

imapsync –syncinternaldates –subscribe –ssl1 –ssl2 –authuser1 admin –user1 user1 –passfile1 /home/user1/.passwordfile –user2 olduser1 –passfile2 /home/user1/.oldpasswordfile –sep2 / –prefix2 “INBOX/” –nofastio1 –nofastio2

That should nicely transfer all existing emails into their respective folders underneath your new Kerio Inbox folder.

replace admin; user1; user2; /home/user1/{.passwordfile, .oldpasswordfile} with your details.



Zimbra Imapsync problems

Seems there has been a breakdown in communication between Imapsync developers and main distro developer teams – perhaps even perl – – who knows !!

Anyhow there is a problem at hand between Imapsync and Mail::Client.


Subroutine Authuser redefined at /usr/bin/imapsync line 2557.

imapsync needs perl lib Mail::IMAPClient release 2.2.9 exactly, future imapsync release may suppoort 3.0.x, but sorry not now. See file BUG_IMAPClient_3.xx

# Looks like your test died before it could output anything.


rpm --nodeps -e perl-Mail && rpm -ivh


SSH Certificate No Password not working

Hi all,

For Linux administrators ,SSH is as important ,if not more so, than a watch.

Typing in a password every time a remote connection is established is detrimental to both workflow and security.

Using the tried and tested

cat .ssh/ | ssh 'cat >> .ssh/authorized_keys'

to bypass the password prompt is a great help.

However, it has been found that sometimes this doesnt work, the answer might be the permissions on the ‘authorized_keys’ file.

The solution (on the remote server – after executing the above command)

cd .ssh && chmod 600 authorized_keys

Now logoout and try to re-connect using ssh again

Hope this helps

How to re-install a package using YUM

If you use many distros you probably think ‘why hasn’t yum got a re-install’..

me too

But i found a work-around

rpm -e --justdb --nodeps %packagename%

yum install %packagename%

Thats a way to ensure you only remove the specified package allowing you to use yum to reinstall it again.

Found the original article and info here


Linux DHCP server bind eth0

So I installed VMWare server and wanted to know how to set my DHCP server to listen on just eth0.

Simple answer on Fedora is to edit


adding the following


Setting up VNC as a service

Hi all,

Question: Many times I wondered why is there a vnc service and why does it always fail on startup?

Answer: Simple configuration of the /etc/sysconfig/vncservers


this sets up a remote desktop service for user ‘john’ with a resolution of 1024×768

edit /etc/sysconfig/vncservers


VNCERSVERARGS=[2]="-geometry 1024x768"

If you want more than one user to have access, do the following:

VNCSERVERS="2:john 3:paul 4:harry"

VNCSERVERARGS[3]="-geometry 800x600"

VNCSERVERARGS[4]="-geometry 1600x1200"

That’s it.

Restart your vnc service and add it to the startup line:

/etc/init.d/vncserver restart

chkconfig vncerver on


Ifconfig add an IP address

It’s easy, just run as root:

;ifconfig eth0 192.168.1.x netmask;

The example shows a class c address with a common subnet mask.

The example above also assumes eth0 as the example network adapter. Other common interfaces may be wlan0 for wireless cards on laptops.

Creating an SSL certificate for your Apache webserver

This is my interpretation on setting up a self-signed SSL certificate for an Apache web-server.

The instructions are generic and apply to most versions of Apache on almost any Linux platform.

Firstly, I suggest creating a separate directory to store your SSL certificates e.g.

mkdir /var/www/ssl/mydomain

Now lets browse to the directory we just created:

cd /var/www/ssl/mydomain

We are using the ‘openssl‘ utility to generate our SSL certificate.

Firstly, we create a private key** using:

openssl genrsa -out mydomain.key

Now we generate a certificate signing request or CSR for short using:

openssl rsa -in mydomain.key -out mydomain.csr

Fill in the appropriate fields with relative information….

and, finally create the self-signed certificate using:

openssl x509 -req days 365 -in mydomain.csr -signkey mydomain.key -out mydomain.crt

This creates a selfsigned ‘mydomain.crt’ for 365 days.

**For safety only allow root to read the private key using:

chown root mydomain.key && chmod 600 mydomain.key

Create an m3u playlist

Using Linux BASH environment I needed to find a way to create m3u playlists.

I first trawled the Internet looking a program to automate this for me — none!

So I then decided to find the m3u file syntax to create my own by hand — none!

Reverse engineering an existing m3u (and speaking with an Apple creative genius) I found that m3u files are simply text files which point to mp3 files.

Simple I thought — just use a loop to write file names to an m3u file.

Therefore, current working directory ($CWD) /your/music, within $CWD we have many directories, listed by artist name i.e. /your/music/abba.

Furthermore, within artist directories we have albums i.e. /your/music/abba/album1; /your/music/abba/album2.

This procedure requires entering each album artist i.e. cd /your/music/abba == present working directory.

Now for the script:

for x in */*.mp3; do echo "$x" >> "${PWD##*/}.m3u"; done


We have a file with the name of the artist i.e. abba.m3u which contains a list of all mp3’s within the albums !!

Voila – Amend as necessary


I created a new script file below that allows you to pass directories into – not 100% for everyone but its a good start.

1 – Copy the code into the script

echo "m3u= $m3u"

for x in “$1″/*/*.mp3; do echo “$x” >> “/your/music/M3u/$m3u”; done

2 – add execute permissions chmod +x

3 – run sh /your/music !! do not add trailing ‘/’ !!

4 – [optional] run a for loop to recurse your main music folder for M in /your/music/*; do /bin/sh $M; done

Done I hope – let me know if you have trouble or can suggest improvements please

Enjoy !

** latest **

finished perfecting the script after many attempts and here is the final code

for i in /your/music/*; do find "$i" -maxdepth 3 -iname "*.mp3" > "$i/${i##'/your/music/'}.m3u";done

BASH SubStrings

I used this command to truncate the beginnings of strings of text from files

for x in *.mp3; do echo "orig: ${x##*'text string'}";done

Another great article is here

and then to move them

for x in *.mp3; do mv "$x" "${x##*'text string'}";done

Folder and file sizes using Linux


I have ben using Linux for ages and always wanted to know the size of folders when using the command line.

I often used ..

df -h

.. to find how much space was left on the system drives – but what if you were in a sub-directory of your device and wanted to know which folders were the culprits for eating your away at your ~500GB drive…

du -hs *

That code will tell you the disk usage (du), using options to display the results in human readable form (-h) summarizing the folders only (s).

The * will recurse the current directory displaying results for all directories within you current directory.


Gentoo Mac Samba Copy Problems


If you have followed some instructions on setting up Gentoo and eventually have trouble with samba, I reckon its because your /etc/samba/smb.conf file is bloated with a hole load of unnecessary code.

It just needs to look like this:

workgroup = MSHOME
security = user
local master = yes

valid users = %S
read only = no
browseable = no

That’s it!

Nice simple and secure. Allowing users to login to their home directories.


Linux Setting rsync to use a different port number

So you have tightened security on your main server by changing the default port number.

Once a week to backup your server data by using the rsync application on a local backup server – possibly even running a crontab script.

All of a sudden you get errors such as:

ssh: connect to host port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-24.1/rsync/io.c(359)

Why is this ???

The option rsh allows the desired port to be specified through ssh.

In the following example, the -r option specifies ‘recursive’; -z enables compression; –rsh=’ssh -p1234′ tells rsync to use port number 1234 for transfers/connection.

The code would look something like this:

rsync -r -z --rsh='ssh -p1234' /dir1 --progress --stats

That’s it enjoy

Zimbra backup Scripting

Hello all,

I have been busy working on some code that helps admins to backup their Zimbra email servers.

The link to the forum thread is here

I have had some good feedback from my posting and also created a Wiki page for Zimbra.

The link to the Wiki page is here

Blogged with Flock

Ubuntu Picard – No MP3’s

If you are using Ubuntu Feisty and cannot access any MP3’s after installing Picard – I found the best way is use the following procedure:

apt-get build-dep picard -y

apt-get install libtunepimp5-mp3 -y

apt-get source picard

cd picard* && python install

You can check if you now have MP3 support by open Picard and selecting Help >About.



Blogged with Flock

GIMP Scripting for the beginner

Well, it took me approximately three full days of trying and testing, using the Script-Fu console mainly, but I am happy to report that I now understand the way to use the GIMP command line.

I will try to report on my finding, some solutions and assist with future use of GIMP in the best way I can here in this blog.

A script has also surfaced that presents the results of my hard work. (Covered later)

Some of the problems I encountered when tackling this subject for the first time were:

  • understanding the parenthesis syntax
  • using and ssigning variables and their values

However for now I will just attach the script, which should be saved into ~/.gimp**/scripts/

Once done open gimp and Xtns/Script-Fu/Refresh Scripts…..hopefully no errors and you can access it by the toolbox menu Xtns > Script-Fu/Misc/Levels.

Please bear with me as i am writing this in a hurry and will amend it when i get a minute.

Continue reading


Using BloGTK on Linux is easy to write and upload blog entries on WordPress.

Thanks to the article here it was easy to setup as well.

Using Ubuntu (you may need to add multiverse and universe repositories), simply run:

apt-get install blogtk

Now open Applications > Internet > BloGTK.

In the Account and Prefernces window, use the following info:

Server URL:
Username: Username
Password: Password
Bloggin System: MetaWeblog API

Now click SAVE and then OK.

In the main BloGTK window, select File Connect to get a list of your blogs.

Type away till your heart is content and then publish.

Custom Tags

To make full use of the tags available on, such as , open Edit > Custom Tags …

Tag Name: Code Tags
Start Tag:
End Tag:


When back in the main window you can simply insert the code tags by selecting your code tag and clickling the big green tick arrow.

Have fun

Print Directory Listing to a csv file

If you have a whole load of music albums on your hard drive and want to print a listing of those you have:
dir -C -1 -N -R /music/ > music-listing.csv

This effectively uses the dir command with the options:

-C <- this allows the results to be formatted into columns, useful for our csv (comma seperated values) file

-1 <- this ensures only one entry per line

-N <- this removes any ‘\ ‘ characters, linux users know what I mean

-R <- this recursively lists the contents of each folder

/musc/ <- this is your folder location

> music.csv <- this is the output file, which the results are stored in

This will give a nice csv file, ready to be opened in OpenOffice or Micro$oft Excel.

It nicely lists the folders at the top and then the music tracks in the relevant recursive section below.

Something like this:

/mnt/western/Music Library/Various Artists/R&B Classics (disc 3):
01 Nelly – Dilemma (feat. Kelly Rowland).mp3
02 Blackstreet – No Diggity (feat. Dr. Dre).mp3
03 R. Kelly – Bump ‘N’ Grind.mp3
04 Aaliyah – Back & Forth.mp3
05 Fugees – Fu-Gee-La.mp3
06 Eve – Let Me Blow Ya Mind (feat. Gwen Stefani).mp3
07 Foxy Brown – Get Me Home (feat. Blackstreet).mp3
08 Next – Too Close.mp3
09 Mary Mary – Shackles (Praise You).mp3
10 Boyz II Men – I’ll Make love To You.mp3
11 India.Arie – Brown Skin.mp3
12 702 – Where My Girls At.mp3
13 Horace Brown – Things We Do for Love (feat. Jay-Z) (Eddie F’s Paradise mix).mp3
14 Erykah Badu – On & On.mp3
15 Solange – Feelin’ You, Part 1 (feat. Slim Thug).mp3
16 Dru Hill – In My Bed (So So Def remix).mp3
17 Jodeci – Freek ‘N You.mp3
18 Toni Braxton – You’re Makin’ Me High.mp3
19 Ginuwine – Pony.mp3
20 Alicia Keys – You Don’t Know My Name.mp3

Ubuntu 7.04 – VMWare-Server Network Problem Solved


Running the very cool Ubuntu and trying to setup VMWare-Server to host Vista.

If you cannot for the life of you get the networking to connect to your LAN – simply add the following to your vm’s .vmx file – using these steps:

  1. locate your vmx file e.g vista.vmx (within the folder that you store your virtual machines in)
  2.  scroll down to just under the line Ethernet0.present = “TRUE”
  3. add, on a new line, ethernet0.virtualDev = “e1000”
  4. restart /etc/init.d/vmware

et voila !!

worked a treat for me – from the original thread