Tweaking ClearOS
The ClearOS standard installation works fine, but I've compiled a list of the adjustments I've made that improve the performance of the system to more my needs, these include:
Spin-down the hard drive when not in use
This will not work with the drive containing the operating system as its mounted with the ext3 file system that journals (writes to the disk every few seconds). The additional hard drive I used for file storage (see Adding Extra Hard Drive) was mounted as an ext2 file system, so is suitable for spinning down.With WinSCP double click on the '/etc/rc.d/rc.local' file to edit
Add the following line:
/sbin/hdparm -S120 /dev/sda
This script is ran at boot (so a reboot will be required to start it working) and sets the spin-down time of the /dev/sda drive (obviously change the command if you drive location is different, see Adding Extra Hard Drive).
The drive will now spin-down after 10 minutes of inactivity (120 x 5 seconds = 10 minutes)
Reduce hard drive activity when server is idle
The hard drive is accessed regularly to write log files and update files attributes, this activity can be significantly reduced with a couple of tweaks to the fstab and syslog.conf files without affecting the proper operation of the server.Every time a file is read the file's attributes are modified to record the time of access, so if the file is in memory (as most of the Linux operating system is) this results in the hard drive being written to. The file access time attribute isn't (normally) required, and can be turned off by modifying the drives mounting instructions using the noatime option.
To set the noatime option for the hard drive, login with WinSCP and double click on the '/etc/fstab' file to edit it and modify the first line to this:
LABEL=/ / ext3 defaults,noatime 1 1
The system is set to record various log files at regular intervals, causing regular hard drive activity. These are useful and probably shouldn't be turned off; a better option is to set the logs to be stored in memory and only "synced" to the hard drive when the system is powered down.
To edit the system log configuration file, login with WinSCP and double click on the '/etc/syslog.conf' file...
Add a " - " before the destination of the log file, for example the entry for the cron log file becomes:
# Log cron stuff
cron.* -/var/log/cron
This can be repeated for all the log file destinations in the syslog.conf file.
These two modifications extended the time between hard drive activity from ~30 seconds to several minutes...
Automatic system shutdown
To set you system to shutdown automatically you can create a 'cronjob' to closed down the system. (My Via ITX motherboard supports auto power-on through the BIOS, so I can set it to power up first thing in the morning).
Note:- I don't use this anymore, I leave the server powered up 24 hours a
day, the power usage is negligible, its silent when idle and it auto-updates the
system in the early hours of the morning.
Login with PuTTY and enter:
crontab -e
You will be presented with the vi editor (which isn't very friendly)...
Press the 'a' key to enter the text mode
Enter the following line:
45 22 * * * /sbin/shutdown -h now
Return to the command line by pressing 'Esc' key
Save the file by entering:
:w
Exit the editor by entering:
:q
To check the file enter:
crontab -l
The above example shuts the system down at 22:45 (10:45pm), adjust the values to
suit your requirements.
Stopping a 2.5" laptop hard drive 'clicking'
If you have used a 2.5" laptop drive for you operating system, you might find that it 'clicks' shortly after it has been accessed (the operating system accesses the hard drive quite regularly on my system), I'd recommend you follow this tweak as it could prevent the premature failure of your hard drive...The cause of the clicking is due to the very aggressive Advanced Power Management (APM) option on some portable hard drives unloading the read/write heads shortly after the disk becomes idle. (It reduces the power requirements and minimises the chance of damage cased by external shock - which is important for the hard drive's target use, e.g. in a potable computer).
This is probably fine if you have a laptop running Windows, but on a server running Linux the drive's typical 600,000 maximum unload/load cycles could be exceeded in well under 1 year of use with the journaling ext3 file system.
For more information see this link.
The simplest way to sort this out is to turn off the APM and prevent the
drive constantly loading/unloading the read/write heads (this shouldn't be detrimental to the drive in any
way, it will just use slightly more power):
With WinSCP double click on the '/etc/rc.d/rc.local' file to edit
Add the following line:
/sbin/hdparm -B255 /dev/hda
This script is ran at boot and disables APM on the
/dev/hda drive.
You should now have a quieter hard drive that will last significantly longer!!