Increase diskspace on an LVM volume

Today i was researching howto increase diskspace on an linuxbox that was running LVM. I have done this before but lost the commands. So here is a quick guide for my own remindings.

First of all, run the command vgs to get information about your volume groups (VGs)
srv01:~# vgs
VG #PV #LV #SN Attr VSize VFree
srv01 1 6 0 wz--n- 29.76g 3.88g

Then run lvdisplay to show your current lv-volumes.
srv01:~# lvdisplay
--- Logical volume ---
LV Name /dev/srv01/tmp
VG Name srv01
LV UUID xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx
LV Write Access read/write
LV Status available
# open 1
LV Size 680.00 MiB
Current LE 170
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:4

Now we know our lv’s name in this case /dev/srv01/tmp. now its time to increase the space. the command below increases the volume by 300mb. Check your VGs to that you have enough space left.
lvresize -L+300M /dev/srv01/tmp

When this is done, you can run the command df -h to check your diskspace, as you can see the space has not increased on the mounted filesystem. You will have to run resize2fs in order to change the filesystem space. my /tmp folder has its filesystem under /dev/dm-4 as shown in the df -h command. resize the ext3 volume to the same size as your lvm.
resize2fs /dev/dm-4 680M



Install NRPE and Nagios plugins on Debian

Lately i have been working alot with Nagios and setting up monitoring of linux host in an large datacenter. I have been looking for an easy way of deploying the NRPE and Nagios plugins to the servers without installing so much crap on them. I didnt find anything good so here is my own guide to installing NRPE and plugins.

Start by adding a nagios user
useradd nagios

Install building tools if they arent present
apt-get install build-essential libssl-dev

Download the package from nagios

Untar and cd into the folder
tar -zxvf nrpe-2.13.tar.gz
cd nrpe-2.13

Configure the package with command args enabled
./configure --enable-command-args
make all

Leave the nrpe folder for now, Download the plugins
cd ..

Untar and cd into folder
tar xvfz nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16

Configure the package

Make it

and then make install it
make install

Now lets go back into the nape folder
cd ..
cd nrpe-2.13

And then install nrpe, plugin, daemon and config
make install-plugin
make install-daemon
make install-daemon-config

add the nrpe init.d script and chmod it..
cp init-script.debian /etc/init.d/nrpe
chmod 700 /etc/init.d/nrpe

it should start just fine now
/etc/init.d/nrpe start

finally update the update-rc.d
update-rc.d nrpe defaults

This always works fine for me!


Autostart VM in free version of XenServer 6

I have been looking for an solution to bypass the HA licens restriction Citrix applied in free version of xenserver. The feature i was looking for and needing inte the HA version was autostart of VM’s upon host-server reboot. It turns the feature is there, only restriction is in GUI.

If you wish to enable that feature in Xenserver run these commands in the servers console:

Get the UUID for your vm.
xe vm-list

Run this command to enable autostart.
xe vm-param-set uuid=your-uuid-here other-config:auto_poweron=true

If you would like to autostart a pool, run these commands.
xe pool-list


xe pool-param-set uuid=your-uuid-here other-config:auto_poweron=true


Flash Media Server on Debian Server

Back again to give some tips. I have lately been trying out Flash Media Server (Interactive ED) on behalf of my previous employer, they are going to add the FMS server to their live-server-farm and it has been my responsibility to implement the server and setup the software.

I started trying out RHEL and CentOs but after failing to get them to start and run properly in Xenserver6 i decided to try to install it on Debian instead, Adobe have in the later versions 4.5+ started allowing the software to run on other servers than RHEL and CentOS.

The server i am installing this machine in is an 2p (12core) server with 32gb ram running Xenserver 6.

Said and done i started by installing the Debian 6 64bit in xenserver, i gave it 4-vcpu, 8gb of ram, 2 1gbit networkcards and 40gb of hard drive (the server will be mounting the san-shares with all VOD files on later).

The Debian server only has the ssh server installed as standard. I manually installed the Xen-tools.

After reading about FMS and debian on various webpages i found out that FMS requires an lib thats called libnspr4. I ran the command below in order to get it installed. apt-get install libnspr4-0d

I also read that the lib32stdc++6 should be installed in order to get the fmscheck tool to work properly. Yes FMS is now 64bit only but this tool remains 32bit for some reason. So the only thing to do is to install the lib and it dependencies. I ran the command below in order to get it installed.
apt-get install lib32stdc++6

Before installation i created an user and a group for the software to run as. The installation creates these for you if you want, but i like to have them in the system UID range instead of in the public UID range. To create the user and group i ran the following command
addgroup --system fms; adduser --system --group fms

Now we finally are ready to run the installation!
I downloaded the FMS package from adobe, the linux installer are inside the zipfile. Unpack it and exec the installFMS shell script.
tar -xzvf FlashMediaServer4.5_x64.tar.gz
cd FMS_4_5_0_r297/

The installation program is pretty straight forward, answer yes to the questions regarding path, user and group. Change the ports if you like, i use the standard ports for compatibility issues with some streaming software. And choose your own user and password, security is important!

You will be asked if you would like to install apache, let FMS do that for you. Its easier than trying to install it yourself, you can alter the config later on. I will cover it in a different post. You will also be asked if you would like to add the fms daemon, do that too.

After the installation is complete you have to change the run levels of the FMS binary. As default the installation skips runlevel 2 which is debians standard runlevel.
update-rc.d fms remove; update-rc.d fms defaults

If the installation asks you if you would like to start the server after installation, select no and reboot the machine first.

After the installation you can point your web browser to your domain oct ipadress, now you will se the console/demo page for FMS! Happy streaming.


Installing FFMpeg in Debian or Ubuntu

I have had the pleasure to install and reinstall ffmpeg on an linux (debian) host and thought that i should share my experience. Or at least save it for myself.

I have tried getting ffmpeg directly from apt-get but it didn’t have all the libraries that i needed for the server dependencies, so i ended up having to install it directly from source.

This simple steps worked fine for me..

First of all, add the debian multimedia deb repositories to your sources.list.

deb etch main
deb-src etch main

run command apt-get install debian-multimedia-keyring and apt-get update to get the package lists.

Install subversion, we will need it to get source from ffmpeg homesite
apt-get install subversion

Get all the libraries needed
apt-get install liba52-dev libdts-dev libgsm1-dev libvorbis-dev libxvidcore4 libxvidcore-dev libdc1394-dev libfaac-dev libfaad-dev liblame-dev libx264-dev libtheora-dev libsdl1.2-dev

Get all the build dependencies for ffmpeg
apt-get build-dep ffmpeg

install yasm, needed for x264

tar xzvf yasm-0.7.1.tar.gz
make install

get and install x264

bunzip2 < x264-snapshot-20080630-2245.tar.bz2 | tar -xf -
./configure --enable-shared
make install

get the ffmpeg code

svn checkout svn://

go into the dir, then configure and make

./configure --enable-libmp3lame --enable-libtheora --enable-liba52 --enable-libx264 --enable-libgsm --enable-postproc --enable-libxvid --enable-libfaac --enable-pthreads --enable-libvorbis --enable-libfaad --enable-gpl --enable-x11grab --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-shared --disable-vhook --prefix=/usr/local --extra-cflags=-I/usr/include --extra-ldflags=-L/usr/lib
make install

Run ldconfig to update lib-paths and then check to se if ffmpeg is responding. If not, reinstall it.. :(

ldconfig -v
ffmpeg -version
0 error

After an php upgrade on one of my web hosts i have gotten an strange error, it tells me that the package is corrupt.

I got the following error thrown in the php-cli and php commands. It appears in various logs aswell..
php: /usr/local/lib/ no version information available (required by php)

I found a solution to the problem, _its just a workaround_ as this error is telling me that the libxml2 package is broken and it needs to be rebuilt. I have built mine from source and it is/was a pain in the ass to get to work. apt-get doesn’t give me the version i want. I know i could always do it but this server is a critical part and can’t be offline that long. I have started building the server from scratch and will move the code/files to this server in a couple of weeks.

Anyways, when this problem was found i ran locate in the console and i found the library in two different places. It should only exist in one place. Mine was in /usr/local/lib and /usr/lib. The file in /usr/lib seems to be the correct working one, so i tried to delete the other one, it didn’t work. After reading around on google i found that this file could exist in two places but there should only be one lib file, the other one should be a symlink.

So i tried to delete the wrong one, and replace it with and symlink to the source file. Boom, it worked.

cd /usr/local/lib/
ln -s /usr/lib/

Nagios XEN plugin

I have tried the new XEN api-plugin for nagios the other day. It works well and i hope the team behind OP5 will make it available in the standard package soon.

The plugin is available here, Download the code from GIT. Move the xen folder to /opt/plugins/xen as this is a dependency, that folder contains the API code for XEN. Move the file to your normal plugin location.

After moving the folder and file to the right location, you can try to see if you’ll get any results from your server.

[root@monitor]# ./ -S -u user -p mypass -l listhost
CHECK_XENAPI.PL OK - 1/1 are enabled: xen1(ENABLED) | hostcount=1units;;

Make sure you use the http:// in the url to the server, otherwise it will fail. Took me a while to figure that one out

If you would like to check the how cpu,

[root@monitor]# ./ -S -u user -p mypass -l cpu -H xen1
CHECK_XENAPI.PL OK - cpu: usage = 0.64 %, loadavg = 0.0300 | cpu_usage=0.64%;; loadavg=0.0300;;

If you would like to check the net status, it displays status for all network cards

[root@monitor]# ./ -S -u user -p mypass -l net -H xen1
CHECK_XENAPI.PL OK - net: send = 0.16 KBps, receive = 0.65 KBps, send errors = 0, receive errors = 0 | send=0.16KBps;; receive=0.65KBps;; send_errors=0;; receive_errors=0;;

If you would like to check the IO,

[root@monitor]# ./ -S -u user -p mypass -l io -H xen1
CHECK_XENAPI.PL OK - disk io: cache size = 0 B, cache misses = 0, cache hits = 0 | cache_size=0B;; cache_misses=0;; cache_hits=0;;

If you would like to show running vm’s on the server,

[root@monitor]# ./ -S -u user -p mypass -l list -H xen1
CHECK_XENAPI.PL OK - 3/3 are Running: server1(Running), server2(Running), server3(Running) | vmcount=3units;;

You can also run checks against a specific vm aswell,

[root@monitor]# ./ -S -u user -p mypass -l cpu -N server1
CHECK_XENAPI.PL OK - VM 'server1' cpu: usage = 0.20 % | cpu_usage=0.20%;;

A daughter is born

I’m so happy and a bit overwhelmed. Today my daughter was born after an intensive morning/day.

She came almost one month to early and had asphyxia when she came out due to something neither we or the doctors could explain. To be honest it’s kind of a blur to talk about this but the clear memory of this day will stick forever.

I had to follow the doctors as they ran from the birth room out to the ”resuscitation” room. She did not breath on her own and after a couple of minutes of heart massage and oxygen she started to manage on her own. When she was stable we went to say help to the mother and then we went up to the neonatal department.

The doctors was a bit pensive about her getting some kind of damage to the brain as she had the asphyxia for so long. they were talking about flying to UmeÃ¥ and cooling her down if the examination was showing any signs of damage. as of now, they don’t see anything that indicate this. We will probably stay here at neonatal for a couple of days for further monitoring.

As you all understand it has been a long day and i really can’t write/talk about everything here.

We will probably call her Ebba.