How to create software RAID 1 from existing installation on live system

If you have already installation which is installed on disk drive (/dev/sda), which is not part of RAID array and you have second disk drive (/dev/sdb) which is not in usage and you want to create software RAID from existing installation while OS is working, you can do following task to accomplish this:

1. Create RAID partitions on the second disk drive:
fdisk -l /dev/sdb

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2432    19535008+  fd  Linux raid autodetect
/dev/sdb2            2433        2918     3903795   fd  Linux raid autodetect
/dev/sdb3            2919        3404     3903795   fd  Linux raid autodetect
/dev/sdb4            3405      121601   949417402+  fd  Linux raid autodetect
Create RAID 1 arrays using only the second disk and only one device per RAID partition.
mdadm --create /dev/md0 --level=1 --raid-devices=1 /dev/sdb1 --force
mdadm --create /dev/md1 --level=1 --raid-devices=1 /dev/sdb2 --force
mdadm --create /dev/md2 --level=1 --raid-devices=1 /dev/sdb3 --force
mdadm --create /dev/md3 --level=1 --raid-devices=1 /dev/sdb4 --force
Create swap and file systems:
mkfs.ext4 /dev/md0
mkfs.ext4 /dev/md2
mkfs.ext4 /dev/md3
mkswap /dev/md1
Mount and synchronize the existing data to RAID arrays:
mkdir /mnt/tmp
mkdir /mnt/var
mount /dev/md0 /mnt
mount /dev/md1 /mnt/tmp
mount /dev/md2 /mnt/var
mkdir /mnt/sys
mkdir /mnt/proc
rsync -av --exclude="/mnt" --exclude="/proc" --exclude="/sys" / /mnt/
rsync -av /var/ /mnt/var/
rsync -av /tmp /mnt/tmp/
Install grub to the new disk which implements RAID arrays:
grub-install /dev/sdb --root-directory=/mnt/
Update grub config files:
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
Describe the new mount devices in ‘/mnt/etc/fstab’:
~# blkid /dev/md0 
/dev/md0: UUID="64ea9000-3df6-4699-8c2e-df48f5c3835e" TYPE="ext4" 
~# blkid /dev/md1
/dev/md1: UUID="133dabc7-7957-462e-8b5e-1594ded31ec8" TYPE="swap" 
~# blkid /dev/md2
/dev/md2: UUID="a65dcd80-b8fc-49a6-835f-b06b930824b7" TYPE="ext4" 
~# blkid /dev/md3
/dev/md3: UUID="a7cbbd28-0617-4013-9870-714cf75334f4" TYPE="ext4"

cat /mnt/etc/fstab 
# /etc/fstab: static file system information.
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc	/proc	proc	defaults	0	0
UUID=64ea9000-3df6-4699-8c2e-df48f5c3835e	/	ext4	defaults,errors=remount-ro	0	1
UUID=133dabc7-7957-462e-8b5e-1594ded31ec8	none	swap	sw	0	0
UUID=a65dcd80-b8fc-49a6-835f-b06b930824b7	/tmp	ext4	nodev,nosuid	0	2
UUID=a7cbbd28-0617-4013-9870-714cf75334f4	/var	ext4	defaults	0	2
Umount RAID partitions:
umount /mnt/proc
umount /mnt/sys
umount /mnt
Reboot the server and choose from the BIOS to boot from the second disk drive
After starting server again you should see already RAID arrays mounted devices:
/dev/md0 on / type ext4 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/md2 on /tmp type ext4 (rw,nosuid,nodev)
/dev/md3 on /var type ext4 (rw)
We need to mirror partition table from the new RAID block device to the old (/first) disk drive:
sfdisk -d /dev/sdb | sfdisk /dev/sda
Grow RAID arrays size:
mdadm --grow --raid-devices=2 /dev/md0
mdadm --grow --raid-devices=2 /dev/md1
mdadm --grow --raid-devices=2 /dev/md2
mdadm --grow --raid-devices=2 /dev/md3
Add partitions from the first disk to RAID arrays:
mdadm --manage /dev/md0 --add /dev/sda1
mdadm --manage /dev/md1 --add /dev/sda2
mdadm --manage /dev/md2 --add /dev/sda3
mdadm --manage /dev/md3 --add /dev/sda4
Now the new disk arrays should start syncing:
cat /proc/mdstat 
Personalities : [multipath] [faulty] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [linear] 
md0 : active raid1 sda1[2] sdb1[0]
      19533912 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sda2[2] sdb2[0]
      3902759 blocks super 1.2 [2/2] [UU]

md2 : active raid1 sda3[2] sdb3[0]
      3902759 blocks super 1.2 [2/1] [U_]

md3 : active raid1 sda4[2] sdb4[0]
      949416242 blocks super 1.2 [2/1] [U_]
      [==================>..]  recovery = 91.0% (864771072/949416242) finish=21.4min speed=65886K/sec
At the end we need to install grub on the first disk (/dev/sda) so if we can boot from any of disk:
grub-install --recheck /dev/sda

So this way you can create RAID 1 without almost any downtime. Just one server’s reboot and changing drive boot priority.

Configure Firefox to handle callto links in Ubuntu/Debian

Hi all ūüôā

in this post I will show you how to configure Mozilla Firefox to handle callto links. By default if you click on callto link in Firefox shows the following error:

The address wasn't understood

Firefox doesn't know how to open this address, because the protocol (callto) isn't associated with any program.

You might need to install other software to open this address.

These steps are tested on Ubuntu 12.04 LTS i386, Ubuntu 13.10 i386 and Debian Wheezy amd64.

1. Install SFLPhone Software for VOIP calls

apt-get install sflphone-gnome

2.¬†Start the app. First time you will see this screen. Just click ‚ÄúContinue‚ÄĚ:


¬†We need to choose ‚ÄúRegister an existing SIP account‚ÄĚ on the next screen and click ‚ÄúContinue‚ÄĚ:


¬†On the next screen we choose ‚ÄúSIP‚ÄĚ and click ‚ÄúContinue‚ÄĚ:

Here we need to fill our data:

Alias: Our name
Host name: Our SIP Server IP
User name: Your user or ID
Password: Your password

¬†After filling the required data, click ‚ÄúContinue‚ÄĚ:

¬†On the next screen just click ‚ÄúApply‚ÄĚ. We don’t need to setup anything here:

 Next you will see summary for your account.

 4. Save this script to /usr/bin/sflphone-handler

# This script can be used as a callto: (or other) protocol handler in
# Mozilla Firefox-based browser.
# In Firefox use Preferences > Applications and set the callto handler
# to this script.

# Test if a SFLphone client is already open, if not open a new one
# Opening a new client will start sflphoned if not already running
SFLPHONEC=`ps -A | grep sflphone-client`
if [ "$SFLPHONEC" = "" ]; then

# Check 1st argument (phone number)
if [ -z $1 ]; then
echo "Error: argument 1 (phone number) not provided."
    exit 1

# Cleanup destination, keeping numbers only
TO="`echo $1 | sed -e 's/[^0123456789]//g'`"

# Generate call id.

# Dbus placeCallFirstAccount method does not reach sflphoned if starting
# Should find another way to do this
sleep 1

dbus-send \
    --type="method_call" \
    --dest="org.sflphone.SFLphone" \
    "/org/sflphone/SFLphone/CallManager" \
    "org.sflphone.SFLphone.CallManager.placeCallFirstAccount" \
    string:"$CALLID" \

exit 0


 Or you can download it from:

5. Make this script executable:

chown root:root /usr/bin/sflphone-handler
chmod 755 /usr/bin/sflphone-handler

6. Add callto handler

sudo echo "x-scheme-handler/callto=sflphone.desktop" >> /usr/share/applications/defaults.list

7. Configure SFLPhone to accept parameters

nano /usr/share/applications/sflphone.desktop

and change



Exec=sflphone-client-gnome %u

8. Configure Firefox

Open Firefox and click on callto link. First time you will see this screen:

¬†We need to click ‚ÄúChoose‚ÄĚ and navigate to /usr/bin/sflphone-handler.

Then check ‚ÄúRemember my choice for callto links‚ÄĚ and click ‚ÄúOK‚ÄĚ.

After a while SFLPhone application should start and automatically call the number from the link.

Inteligante apache/nginx log analyzer.

Howdy m8s.

In next article i want to show you how to make an easy statistical view for an web page only by using one simple tool called goaccess.

As they say to their site, this tool can provide a various information for your web site just by scanning log files from apache / nginx logs.

 -General Statistics, Bandwidth etc.
 -Top Visitors
 -Requested files
 -Requested static files, images, swf, js, etc.
 -Referrers URLs
 -404 or Not Found
 -Operating Systems
 -Browsers and Spiders
 -Hosts, Reverse DNS, IP Location
 -HTTP Status Codes
 -Referring Sites
 -Unlimited log file size

For this review i’ll use VirtualBox image with Debian wheezey net-install with xfce.

Install methods:

1. debian package manager installer

If you install goaccess via debian wheezy installer it will put all packages needed for that tool and it will be ready for use.
But in that way you can’t use utf8 or geoip support.

sudo aptitude install goaccess

and you will have Version: 0.5-1

If you dont really need utf8/geoip the install part for you end with this simple command.

2. Manually compile

Here we shall install goaccess tool with fully support of utf8/geoip

Download it to your work my case this is /root/Downloads/

you need to install this libs

libglib2.0-dev libgeoip-dev  libncursesw5-dev libncurses5-dev

Than you have to follow the exact instructions from the site:

tar -xzvf goaccess-0.6.tar.gz
cd goaccess-0.6/
./configure --enable-geoip --enable-utf8 
make install

After compile is done you can use it on the fly by typing

goaccess -f /var/log/apache2/access.log -a -c

the “-c” options if for log/date configuration window.
In this window to show correctly apache log files you need to choose “NCSA Combined Log Format”

And this is all…now in console you can see in real time how log statistics is changing ūüôā

Goaccess main window