Digitalquill

My Life and Times by Matt Houldsworth

Flower

Archive for the ‘Linux’ Category

VirtualBox – Part 2

Having just posted a good write-up of Virtualbox I am having a strange problem with my Ubuntu Desktop. I decided to update it all, so ran the ‘apt-get update’ which was fine, but when I ran an ‘apt-get upgrade’ it decided it needed to download 150mb or updates. This was expected so I allowed to to go and get them, which was when the problems started.

The whole PC ground to a halt, task manager showed Virtualbox was using 100% of the CPU constantly.

I managed to get back onto the Virtualbox and cancel the upgrade which then released the CPU. However after repeating the upgrade the same thing happened.

Doing the same on the Virtual Debian works fine…

Very strange… Anyone else had any similar problems?

VirtualBox

Following my recent re-install of my desktop machine I have followed the direction we are heading at work and setup Virtualbox with several environments each with a different OS.

The Desktop PC I am running is relatively old, Pentium 4 1.8Ghz with 3Gb of RAM.

I have the following running in Virtualbox

  • Windows XP
  • Windows Vista Ultimate
  • Windows 7 Beta (more of that later)
  • Ubuntu 8.10 Desktop
  • Ubuntu 8.10 Server
  • Debian 4
  • Debian 4 with ISPConfig Installed (again more of that later)
  • Ubuntu Studio.

I have been trying to get Mac OSX working, which apparently is possible, but as yet I have had no luck.

I want to get Windows 2003 Server up and running as this will then replicate my windows server.

The main idea behind this is so that I have have environments that I can test things in before implementing on my live servers. I have been playing with ISPConfig on a virtual environment to see if there is any mileage with utilizing it. It looks promising.

The main advantage of virtualisation is that firstly you are in an enclosed, non-live environment thus no real harm can be done, and secondly if a mistake is made you can roll back to a saved point in time. It also allows me to save a copy of a basic Ubuntu or Debian setup and quickly create environments from it, meaning that testing things like ISPConfig can be done easily.

In addition to testing software, I have environments setup that are exactly the same as my live web servers, each with a copy of any websites deployed on them, allowing me to check any changes work on the most critical sites before releasing them to the live server.

I would like to be able to ‘mirror’ at least my Linux server to a virtual environment, probably on a day-by-day basis using the rsync’d archive backup.

Memopal Online Backup service

I have suffered several computer failures in the past month or so, including a big failure of my web server. This has caused allot of problems for me personally and my businesses.

I have therefore been looking at online backup services which seem to have been popping up all over the place recently.

My first port of call was the most well known one from Amazon S3 however their payment options do not suit my requirements, so while searching I found Memopal.

After signing up for their free trial, I was quickly impresses and signed up for their 150gb service which should allow me to backup most of my important stuff.

The service comes with a client which you install, the windows client has a GUI which is easy to use and setup, you just choose the folders you want to backup and it just does it in the background, it monitors those folders for changes or new items and backs them up as well.

It also keeps revisions of your files, although I have yet to test this.

They also have a linux client, which can be run from command line. This is ideal for backing things up from my NAS drive and directly from my web servers.

The system is fairly quick althought I have asked it to backup my 60gb digital photograph archive which says it will take over 5 days, whcih I gues is not bad, and this will only be an issue at the start as it catches up with the archive of files.

How to Change the Timezone in Linux

Firstly you should log in as root, and run `date`. This will show you the current time, date and timezone and then backup your current timezone setting

mv /etc/localtime /etc/localtime-old

Create a symbolic link the timezone you want from /usr/share/zoneinfo to /etc/localtime.

For example:

ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

Disabling root ssh access in Debian

Following the disaster that I has with the web/mail servers I have taken an additional step to secure the servers as I am still not clear what the causes of the failure were.

I have disabled direct root ssh login (which in debian is allowed by default) so you have to login as a non-privileged user and then su to root

to do this edit sshd_config

vim /etc/ssh/sshd_config

then find the line:

PermitRootLogin yes

and change it to

PermitRootLogin no

the restart ssh

/etc/init.d/ssh restart

Remember to make sure that you have a non-privileged account that works and you can su from that account to root before you do this.

Still sorting out after server failure

I have at last got my mail serve back on line and checking SPAM although I am not too happy with how much SPAM is still getting through. I will tighten up the rules.

I deliver SPAM to a Spam folder in each users mail boxes, I used to have a script that deleted emails after 7 days, I need to re-write this and get that working again.

There are still some of my sites that are down or out of date. I spent allot of time in the week before the disaster entering all my domains in Domain Name Portfolio and unfortunately did not get a back up of that work so I need to re-enter them all.

I also have some software that I wrote that monitors Google (and others) page rank for all my sites. I also had this as a download on my Digitalquill site, however I must have written this in VIM directly on the production server, which means I do not have a copy of that anywhere. I am hoping that someone who downloaded it will be nice and send me a copy.

I am not sure about all the themes for my blogs, including this one. I had customized themes to be specific to my requirements. I made the fatal mistake of thinking that I did not need to back-up my wordpress folders as I can just download a new copy, but this means of course that both the modified themes and any uploads (media and images) have been lost.

The theme for this blog is not too bad, not sure i like it as much as the old one so I may yet still change it, but the one for Earning From Affiliates is not good enough for what I require, so I will be finding the starting theme that I modified and making my changes to bring it back to what I had.

Other than that, I think we are just about there.

Server failure

If you have been trying to get to this blog over the last week or so you will have found that it has been down, along with all my other sites. This was due to a hardware failure on my web server, which coming as it did over the Christmas period has been somewhat frustrating. Getting support to act quickly has exacerbated the problem, however I have spent the Christmas period setting up my web and mail servers and recovering all my sites from backups.

I really need to work on my disaster recovery position as the backups I had were not in as good an order as I would have liked.

Battle of the Media Centres… Vista Media Centre vs MythTV

I have for a long time been running a media centre in various guises, starting with Ubuntu and MythTV on an old laptop which worked nicely for our requirements until we purchased a new Panasonic Viera TV which took a SVGA input.

This opened up many more possibilities for the media centre to be more than a simple recording station, so I wanted to link the media centre to the TV and Surround sound system, and although the laptop and TV were quite capiable of doing this, I faced the well known ATI/Ubuntu graphics driver problems which at best meant blue lines at the top and bottom of the screen and at worst a totally blue screen on the TV while the laptop was quite happy.

Along with this problem the laptop was showing its lack of power when recording the CPU fan would be at fill speed and thus created quite a bit of noise.

I took the decision to invest in a media centre box and found a nice Elonex Spectra on ebay. It is only a Pentium 4, but it has a stylish case with many controls on the front meaning it does not look out of place in the hifi rack. More importantly it was designed for silent running.

As soon as I got the machine I put in another gigabyte of Ram that I had lying around brining it up to 1.5gb and proceeded to install Ubuntu and MythTV which I had running and nicely configured, and with an Intel graphics card it worked well with the TV, however I found that I could nt quite get it quite right, screen resolutions would reset, it would forget my scheduled recordings and it did not like my MP3 archive as it ran to over 500gb of music and it never seemed to cope.

I started looking into the new version of Windows Media Centre on Microsoft Vista Ultimate and it seems that since I ad last looked at it and discounted it, it had become a contender. I took an evening and got it installed on my original media centre laptop and had a play and was impressed with what I saw. So I bit the bullet and installed it on the media centre.

The benefits this brought were immediate, although trivial; I could now get the front LCD panel working on the media centre and more importantly the surround sound system on the computer working with my hifi system. Along with this we could get office installed and use the system as a computer in the living room.
Te over riding benefit was that I could install the software from our HD Digital Video Camera and record direct onto the hard drive and then downscale to DVD (Eventually I intend to install a Bluray recorder).
Since then I have not looked back, it links to my NAS drive and runs my music and pictures, works as an internet PC, allows us to use the BBC iplayer and of course records TV. I have three TV tuners installed so my only problem now is disk space and as the system is running a Sata hard drive which means that I can easily upgrade to a 1tb disk for around £60

The main feature that I miss from the Ubuntu/MythTV model is the ease of the internet controls, although I have installed a plug-in to control the Windows Media Centre via the net, this was never worked correctly. The one with MythTV was perfect in this regard so much so that I was able to control this via my mobile phone.

On balance I do not think that there is much between the two, however the age old problem of open source software holds up both Ubuntu and MythTV in that they are just somehow not quite there, they are not as slick and are a bit rough round the edges. I have to say that they are getting close and given a few more iterations of development I am sure that I will be able to consider them again in the future.

Getting SpamAssasin to Learn from Emails in mailbox folder

I use this command to learn from spam in a folder on a virtual mail box.

sa-learn –spam /var/spool/postfix/virtual/DomainName.com/emailaddress/.Possible_Spam/cur/* –showdots

This then runs on a Cron Tab each day. Care must be taken that no non-spam messages are added to this folder, so only use this with users you trust.

I am working on a way that it will iterate through each mail box and find the possible_spam folders on all virtual boxes and learn from them all at once.

I also want to get postfix/courier to automatically create the possible_spam folders on all new mail boxes.

Backing Up MySQL Databases on a CRON

With all the websites that I run, keeping backups is essentail.

I first wrote a bash script that I ran on a cron job whcih backed up each database and then zipped the sql file up:

#!/bin/sh
mysqldump -uroot -ppwd --opt db1 > /sqldata/db1.sql
mysqldump -uroot -ppwd --opt db2 > /sqldata/db2.sql

cd /sqldata/
tar -zcvf sqldata.tgz *.sql

This meant that I had to modify this backup script each time I added a database. I then found that you can use the ‘–all-databases’ option to backup all the databases at once:
#!/bin/sh
mysqldump -uroot -ppwd
–all-databases > /sqldata/data.sql

cd /sqldata/
tar -zcvf sqldata.tgz *.sql

This works perfectly.

After creating the Tar file I store it on the server where a secondary script runs copying thes backups off site and deleting fiels older than 21 days, meanind that I have a rolling 3 week backup both on the server and off the server.