Linux

I’ve been spending this morning optimizing the Flosoft.biz website in terms of load times in Browsers, and one key element of that is sending the correct expires headers to allow Browsers to cache the data.

Now, as of Plesk 11.5, you can edit nginx settings via the Control Panel, but this isn’t always straight forward, so I thought I’d write a small tutorial.

In the Control Panel:

  1. Select your Domain
  2. Click Web Server Settings
  3. Scroll down to nginx settings
  4. If you have “Serve static files directly by nginx” checked (which I recommend), you’ll need to remove the file extensions you’re going to use below, such as jpg,gif,…
  5. In the text box “Additional nginx directives” copy / paste the following configuration:

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control “public”;
try_files $uri @fallback;
}

That’s it. Just hit OK and enjoy a website that sends the correct headers for your static images and CSS.

 

Read more

One of the main bottlenecks when running high performance virtualization systems is the harddisk. Now, you could of course switch your entire system over to SSDs, but that is costly and you’ll end up with a lot less storage, or a massive RAID array.

Modern filesystems like ZFS have solved this problem by allowing for ‘hybrid’ systems. These use the traditional harddisks for persistent storage, and use SSD drives in front of them to cache the read and write queries. This way you get the best of both worlds. Nearly SSD performance and the storage size of a traditional drive.

At Flosoft.biz we use Proxmox to power our VPS offers, which uses LVM and EXT4 for it’s filesystem which doesn’t have a ‘SSD caching’ method built into it. Facebook seems to have had a similar issue, so they created FlashCache. Flashcache is a kernel module that allows you to add a block caching partition in front of any other partition of your system, resulting in an amazing speedup of your system.

After having spent a night or two on getting this to work on Proxmox 2, I decided to write a small tutorial here. I’d also like to thank @toxicnaan for his l33t hax0r skillz.

 

Updating your system

Get your system up to date and make sure you’ve got the latest Kernel.

apt-get update
apt-get dist-upgrade
apt-get install dkms build-essential git
reboot

 

Kernel Headers

You will now need to install the Kernel Headers for your Kernel so that you can compile the module. Make sure you install the correct version of the headers. These need to be the same as the Kernel you’re running.

uname -a # to get your kernel version
apt-get install pve-headers-2.6.32-17-pve # to install the headers for version 2.6.32-17

 

Get FlashCache

Now that we’ve got the Kernel tools, we can get FlashCache and build it.

git clone git://github.com/facebook/flashcache.git
cd flashcache/

make -f Makefile.dkms boot_conf
make install

 

Load FlashCache

Next we need to load FlashCache into our running Kernel and make sure it’s loaded upon boot.

modprobe flashcache
echo flashcache >> /etc/modules

 

Re-purposing the SSD drives

Now it’s time to find a new use for our SSD drives, namely as cache. You can skip this step if your server doesn’t have the SSD drives mounted as /var/lib/vz

umount /var/lib/vz
vgremove pve
pvremove /dev/md2

 

Re-purposing the 2 HDD drives

Now let’s prepare the 2 HDD drives to be used as the storage for /var/lib/vz.

umount /data
pvcreate /dev/md0
lvcreate -l 100%VG -n storage pve
mkfs.ext4 /dev/mapper/pve-storage

 

Creating the FlashCache partition

Now let’s create the FlashCache partition on the SSD drives & mount it.

flashcache_create -p back pvec-storage /dev/md2 /dev/mapper/pve-storage
mount /dev/mapper/pvec-storage /var/lib/vz
echo 1 > /proc/sys/dev/flashcache/md2+pve-storage/fast_remove

 

Editing /etc/fstab

Next step is to edit /etc/fstab and remove the /data and /var/lib/vz mounts. If you forget to do this (as I did for quite a while), your server will struggle to boot on it’s own, and you’ll end up with the datacenter techs thinking you’re an idiot 🙂

vi /etc/fstab

 

The init.d file

This next step is important. We need to add an init.d file to do some operations, like mounting the filesystem and cleaning it up. It will also unmount the drive before shutting down, as if you don’t do this, your kernel will freeze on shutdown. Make sure you edit your file according to your needs.

#!/bin/sh

# Start or stop Flashcache

### BEGIN INIT INFO
# Provides:          flashcache
# Required-Start:
# Required-Stop:     $remote_fs $network pvedaemon
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Flashcache SSD caching
# Description:       Flashcache SSD caching
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin

flashcache_start() {
if df -h | grep /var/lib/vz > /dev/null
then
echo "Flashcache allready running"
else
flashcache_load /dev/md2
mount /dev/mapper/pvec-storage /var/lib/vz
#mount /dev/mapper/pve-backup /mnt/backup
echo 1 > /proc/sys/dev/flashcache/md2+pve-storage/fast_remove
echo "Flashcache started"
fi
}

flashcache_stop() {
if df -h | grep /var/lib/vz > /dev/null
then
#umount /mnt/backup
umount /var/lib/vz
dmsetup remove pvec-storage
echo "Flashcache stopped"
else
echo "Flashcache not running"
fi
}

case "$1" in
    start)
flashcache_start
    ;;

    stop)
flashcache_stop
    ;;

    restart)
        $0 stop
        $0 start
    ;;
esac

exit 0

 

Enabling the init.d file.

Now we need to make the file executable and make sure it’s run on boot.

chmod +x /etc/init.d/flashcache
update-rc.d flashcache defaults

 

Give it a spin

Right, that should do it. Reboot your machine and see if it comes back.

reboot

If all went well, your drive should be mounted with FlashCache in between.

root@vh43:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
none                   32G  256K   32G   1% /dev
/dev/md1               10G  1.3G  8.2G  14% /
tmpfs                  32G     0   32G   0% /lib/init/rw
tmpfs                  32G     0   32G   0% /dev/shm
/dev/fuse              30M   12K   30M   1% /etc/pve
/dev/mapper/pvec-storage
                      1.8T  196M  1.7T   1% /var/lib/vz

You can also see the statistics of FlashCache by running:

cat /proc/flashcache/md2+pve-storage/flashcache_stats

That’s it! Your Proxmox system should now have it’s VMs on the FlashCache drive.

If you have any questions or feedback, just leave them below.

References:

Read more

e71First off, I have to say that I love my E71. I think it’s a great phone. The 2 year old design still kicks most of the new phones’ asses. It’s just stylish, beautiful, slim … just great. But like with all good things, there’s drawbacks. The E71’s bigget drawback is Symbian. It’s not too bad, since the E71 is not a touch screen device, but I was thinking about getting the N97 as a follow up.

The N97 looks amazing. Again, very very stylish. I love the slightly tilted screen when the keyboard is showing, it’s just great. But while testing the phone, I noticed that Symbian is just not good enough for the phone. The hardware is amazing. The design is amazing. The OS is shit.

So what’s next? The N900!

Nokia finally realized that it’s time to move on.

The N900 looks amazing. It has nearly everything that a phone needs to compete with the HTC Hero and iPhone.

First of all: No more Symbian. The N900 is Maemo powered. Maemo is Nokia’s Linux Distribution, based on Debian and Gnome. Maemo was a great OS for the N800/N810 for geeks to hack around on. You could literally run nearly anything on it. The formfactor of the N800 series wasn’t great though. It was more a Tablet PC, than a Smartphone. But now Nokia is back, with Maemo 5!

Get the Flash Player to see the wordTube Media Player.

All I can say about that video: Wow! The UI looks very slick. It looks extremely fast and like something people would want in 2009. The OS has a lot of Web Integration and being Linux, it would allow to be extended to whatever you want by using apt.

There is one thing missing though: Multi-Touch. All the competition has Multi Touch. Why not add that to the N900 too?

Design wise, I would prefer a more N97 look, especially with the tilting screen. But I guess, the N900 will be the first of many Touchscreen phones by Nokia.

But to say the least, it looks like a very promising phone. So if anyone from Nokia is reading this, pleeease give me a test device 🙂

Read more

Hey,

just got an IM from Alex about this video.

Get the Flash Player to see the wordTube Media Player.

This is why I use a Mac and Linux on my desktop machines.

Read more

This howto will explain to you how to install a frontend on your server which is accessible via NX. This tutorial is for Debian based systems, and has been tested on an Flosoft.biz FlexServ (RPS).

1. Check the basic Debian setup.

We need to modify the sources.list

vi /etc/apt/sources.list

Add the following 2 lines:

deb http://ftp.debian.org/debian etch main contrib non-free
deb-src http://ftp.debian.org/debian etch main contrib non-free

Close and save (:wq) and run this command to update:

apt-get update

Then check if your system is up to date, and if necessary install updates.

apt-get dist-upgrade

2. Installing the X window manager xorg.

Just type in:

apt-get install xserver-xorg-core xorg

There will be a few questions at the end, for now just go with the defaults.

3. The Login Manager

Now you have 3 options. You can install any of the following Login Manager’s. Your options are:

  1. KDM
    KDM is probably the best if you want to use KDE
  2. GDM
    GDM is probably the best if you want to use Gnome
  3. XDM
    XDM is probably the best if you want to use Fluxbox or XFCE

Once you have chosen one of the GUIs run one of the following three commands:

apt-get install kdm
apt-get install gdm
apt-get install xdm

4. The GUI

Now again, you have a choice of different Graphical User Interfaces.

  1. KDE
    Personally my favourite on Debian
  2. Gnome
    My favourite on Ubuntu
  3. Fluxbox
    Never used it
  4. XFCE4
    Never used it

Once you have chosen one of the GUIs run one of the following three commands:

apt-get install kde
apt-get install gnome
apt-get install xfce4
apt-get install fluxbox

Thats all for the base setup.

5. Reboot

You should reboot to make sure the X server starts.

shutdown -r now

6. Create your user

Once your server has rebooted, and you have relogged in, you should create a user which you will use for the GUI.

adduser mynewusername

6. Getting the NX packages

Now we need to setup the NX server, so that you are able to connect to the server from your home. So you need to download the NX server pacakges:

wget http://64.34.161.181/download/3.1.0/Linux/nxclient_3.1.0-2_i386.deb
wget http://64.34.161.181/download/3.1.0/Linux/nxnode_3.1.0-3_i386.deb
wget http://64.34.161.181/download/3.1.0/Linux/FE/nxserver_3.1.0-2_i386.deb

7. Installing the NX packages

As you have the packages now in your directory, you need to install them via dpkg.

dpkg -i nxclient_3.1.0-2_i386.deb
dpkg -i nxnode_3.1.0-3_i386.deb
dpkg -i nxserver_3.1.0-2_i386.deb

8. The Services

Now we need to make sure the services are running.

/etc/init.d/ssh restart
/etc/init.d/nxserver restart

9. The Browser

Last, but not least… well actually least … Firefox! You will need a nice Browser, so Firefox is the way to go.

apt-get install firefox

Now you’re system is setup and you’re ready to use it. Simply setup your NX Client and have fun!

If you have any questions, don’t hesitate to ask me or just leave a comment.

Read more