mhelm
Posts by Michael Helm:
Twitter Weekly Updates for 2010-05-23
Webmail not working in Cpanel
Had a problem earlier this week, webmail couldn’t always send e-mail. It was coming back with the following error:
SMTP Error: SMTP error: Connection failed: Failed to connect socket: Connection timed out.
After reading a few things I turned on the SMTP tweak.. things appeared to work for a few hours, then it started failing again.
Searching online said to trying telnet on the command line – so did that, connected to port 25 – all fine… hmm odd – tried webmail again – failed…..
After a more indepth search I found a forum which gave me a hint – apparently other people have had the same problem when using the firewall for cpanel – CSF. CSF is definately one of the best firewalls around for linux and works really well with Cpanel – however every now and again the amount of options can cause you to miss out something obvious:
# If SMTP_BLOCK is enabled but you want to allow local connections to port 25
# on the server (e.g. for webmail or web scripts) then enable this option to
# allow outgoing SMTP connections to 127.0.0.1
SMTP_ALLOWLOCAL = 0
The SMTP_ALLOWLOCAL set to 0 stops webmail etc… not sure when this appeared (the server has been working fine for about 4 months) but change it to 1 – restart CSF and there we go it’s working fine 🙂
Can’t create or edit a file – Linux – but have diskspace?
Have you ever had a linux server or desktop which all of a sudden couldn’t create a file – running “df -h” shows you your disk partitions aren’t full?
You’ve logged in as root to check – and yup you still can’t write any files – even a “touch test.txt” fails with a message saying can’t write file – disk or partition full?
You could be out of inodes! Linux stores file address information in inodes – and if you have a lot of very small files (or quite an oddly setup filesystem) you could be out of inodes…
How do you find out though?
just type in
“df -i” – same as the normal diskfree space command except it tells you inodes, if you have none left (or very few) you may not be able to create a new file (or edit it if your editor creates temporary lockfiles).
In a future blog I’ll go through how to resize the number of inodes available (primarily aimed at your temporary dev/shm space as this can suffer from the inode problem if you allocate more to it from a small size – the number of inodes is not increased so you can run out).
Linux – Calculating Diskspace free
With linux servers a couple of things can take up disk-space unexpectedly. Log files is the usual culprit, but if your server is a rented one you might be stuck with a bit of a weird partition setup.
For some reason some hosts will give little storage to partitions which then get filled up unexpectedly.
To find out how much space you have just use the following command.
df
– want to make it more readable?
Use df-h
Also if you want to see your diskspace changing over time the you can use the watch command. For example
watch -n 1 “df”
This will run the disk space command each second and you can view it’s output on the commandline – useful if you want to monitor some specific activity in real time.
Re-mounting linux filesystems on the fly.
You can remount a linux system on the fly like this:-
umount tmpfs
The above command will ask the OS to unmount the filesystem identified by tmpfs in the fstab file.
This may return an error if you are actively using it – i.e. you have an ssh session open and are in the filesystem or open files exist. – Exit any of these and try again 🙂
mount tmpfs
The above command will attempt to re-mount the drive.
When would you use this? Normally if you have done some dynamic re-sizing of a partition – for example the tmpfs partition – see post:
http://www.ihelm.org.uk/2010/04/resizing-ram-disk-in-linux-devshm/
for more info on how to do that.
Resizing Ram disk in Linux (/dev/shm)
As many people know linux has a built in ramdisk – this is temporary memory and is very very fast (as it’s in ram). AS standard linux allocates 50% of your ram to this (don’t worry if you don’t use it linux uses all your ram anyway).
However sometimes you may decide the 50% is not enough (or is too much) – especially if the server is upgradeable you may decide you would want to manage the percentage.
Below is an example default entry from /etc/fstab
tmpfs /dev/shm tmpfs defaults 0 0
This just creates the temporary system using default settings – nothing fancy – however if you want it to take 75% of your ram (or any other percentage) just change it to the code below
– reboot (or remount) and your done.
tmpfs /dev/shm tmpfs size=75% 0 0 How to unmount the tmpfs umount tmpfs To remount it with the new settings mount tmpfs
Migrating Cpanel accounts to new Cpanel Server – by command line.
Cpanel is a good system for administrating a server with many sites on it, i’ve used ensim, webmin and a couple of others in years gone by (Plesk and parallels were disasters for me!). However occasionally something that you think should work just doesn’t and for no obvious reason.
The Cpanel system has a feature to migrate accounts from another server – be it Cpanel or another webhosting panel – this often works, recently though I’ve had a problem with using it for Cpanel to Cpanel where it would connect but fail to transfer the backup file.
Fortunately it’s really easy to use the commandline with cpanel and you can do it manually (actually it’s easier than the wizard!)
On the server you are migrating from just type (while logged in as root!)
/scripts/pkgacct username
This will create a tar.gz in the /home directory on the server – just copy this to the new server (it could take a while – it has everything from the account you are copying).
On the destination server just type in
/scripts/restorepkg username
This creates (or overwrites the account!) on the server – and your done!. But what if you have a dedicated IP (due to SSL?)
Easy just use this instead
/scripts/restorepkg –ip=y username
This gives it the next free dedicated IP address (make sure you have one free!)
And that’s it – it is honestly easier than the wizard which requires you to add more info to establish the transfer link.
One thing to note is that you should ensure that the versions of cpanel are as near as you can get – otherwise it might fail or do things a little weird.
Twitter Weekly Updates for 2010-02-21
- Hmm blackpool tower on fire – and KFC's fault ? Hot wings? #
Twitter Weekly Updates for 2010-01-24
- Oddly enjoying crunching the ole stats and numbers from 2003 until now! 🙂 #
- RT @Little_Dish found the Love Potatoes site! What a great site it is – packed full of recipes and stuff for kids. http://is.gd/6LmFL #