HowTo Guides VMWare

Shrinking vmdk disks in VMWare ESXi

I needed to move a VM from the Datastore onto my laptop today, and found that my VM had numerous vmname-001.vmdk / vmname-002.vmdk virtual disks. The size on these disks would mean it taking hours to move the VM from the VM server to my laptop – so I needed to tidy up and shrink if possible.

I first found that deleting any old or redundant snapshots (taken as a safety measure when updating items within my VM!) consolodated all the -001 / -002 / etc .vmkd files into one ‘master’ vmname.vmdk file. But this file was the full size of the allocated disk size – in my example 160Gb, but the VM was infact only using about 40Gb… time to shrink! Via SSH to the console, I ran the following (with the VM shutdown and powered off of course!).

Firstly – get yourself into the VM storage area for your VM :

cd /vmfs/volumes/vmstorename/vmname

Now run the VM Filesystem tools to shrink your .vmdk – this may take a while, in my case from 160Gb down to 36Gb took about 10 mins :

vmkfstools --punchzero vmname.vmdk

36Gb – Much easier to move around.

HowTo Guides Plesk

Handy htaccess file tips

Ok – here is some handy .htaccess bits

If you want to redirect all visitors to a single page, apart from specific IP address (eg your IP or your customers) the following .htaccess file can be used. Simply repeat the REMOTE_ADDR line if you want more IP addresses :

<IfModule mod_rewrite.c>
  RewriteCond %{REMOTE_ADDR} !^82\.16\.14\.130
  RewriteCond %{REMOTE_ADDR} !^82\.87\.43\.123
  RewriteCond %{REQUEST_URI} !/comingsoon.html$ [NC]
  RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
  RewriteRule .* /comingsoon.html [R=302,L]

What about if you want to use Google’s ‘site moved’ facilities, and you already have your 301 redirect in place? When you try to validate your domain with Google it will fail! So… using this .htaccess file, you can redirect all traffic to your new domain, but still let Google access your validation file :

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_HOST} [NC]
  RewriteCond %{REQUEST_URI} !^/google1d5jdk4533a39485.html$
  RewriteRule ^(.*)$$1 [R=301,L]

If you have any .htaccess tips – please leave a comment, and I’ll add them to the list.

CentOS HowTo Guides Linux Plesk

1and1 default Plesk partition – resizing guide

1and1 have been regularly criticized for their unusual partitions on default installations of their dedicated servers – but this is the first time I have been affected. One of our dedicated servers started producing Postfix SMTP errors – caused by low disk space.

Upon investigation, the default partitions on my 1&1 Plesk 10.4 server came set at 4Gb, and my ‘var’ partition was full. The used space is all genuine files, so my only option was to increase the partition. On Windows this is quite a complex procedure, requiring additional applications – however following a simple guide made this a 5 minute procedure. Here are the steps that I took

HowTo Guides Linux Plesk

Plesk API vulnerability – allow anonymous hacker

Great… Nice start to the day, received an email from Parallels regarding a vulnerability within all Plesk Panel versions below 10.4 which allow anonymous access to the server!

In a nutshell – if your server is running below 10.4 – you are at risk and MUST update. I have 3 Plesk servers, 10.4 / 9.5.4 / 8.6.0 – so I was able to carry out the “Micro updates” (MU), versions other than this required a manual patch (unless you opt to go upto the highest subversion to get the MU).

HowTo Guides Linux Plesk

Protecting your Plesk server against the TimThumb hack

Plenty of WordPress themes, and many plugins, scripts and add-ins now make use of the great TimThumb script to modify images on-the-fly. I have used the script numerous times on my own sites, and for clients – either within a custom written Theme/Plugin or pre-attached within a theme. This results in a lot of different versions of the script over the year – which caused a bit of a panic when I read Cleaning Up the TimThumb Hack | WP Theming outlining the possible threat that an out of date script would cause.

The handy walk-through put together by Devin helped me find firstly; where my scripts were buried, and secondly; which versions required updating (in the end, I updated them all to the latest release)

HowTo Guides Linux Plesk

Install mcrypt for PHP on Plesk 9.x and Pesk 10.x

A recent request to install mcrypt for a payment module for Sagepay led me to put together this quick how-to based upon my CentOS Plesk 9.x webserver.