28 July 2009

19 July 2009

Master your installed tools

Sometimes, we use tools from so long time that we don't know/care/remember where it comes from.
It is particularly true for system tools (e.g. mount, fsck, tune2fs, ls...).

Create a specific user for MySQL Database backup

For security reasons, it is interesting to create a specific user for MySQL Database backup with the less privileges possible.
In fact, only LOCK TABLES and SELECT privileges are requested to use mysqldump.

14 July 2009

Manage SMART disks

Modern hard disks (from ATA-3 and SCSI-3) provide built-in system called SMART (for Self-Monitoring, Analysis and Reporting Technology).

smartmontools provides two utility programs (smartctl and smartd) to control and monitor storage systems using SMART.

It can be installed in RedHat-like systems using yum (yum install smartmontools).

To get "general" Info like device model number, serial number, firmware version... (e.g. /dev/sda):
smartctl -i /dev/sda

To get Health Status of a device - for instance for predicting its own failure within the next 24 hours (e.g. /dev/sda):
smartctl -H /dev/sda

To get SMART Attributes of a device (e.g. /dev/sda):
smartctl -A /dev/sda

To get SMART Capabilities of a device (e.g. /dev/sda):
smartctl -c /dev/sda

To get error information of a device (e.g. /dev/sda):
smartctl -l error /dev/sda

To get all those information and even more about a device (e.g. /dev/sda):
smartctl -a /dev/sda

The smartctl command allows launching some tests.
For instance to launch a short test:
smartctl -t short /dev/sda

To get progress and result information:
smartctl -l selftest /dev/sda

See smartctl MAN page for further information.

Remount a read-only mounted partition

In some cases (kind of maintenance mode for instance), partitions can be read-only mounted, and the situation stays the same after operations (like fsck) and reboot.

For instance, it can happen if the system is wrongly configured, forcing the fsch of unknown (or removed) devices.

To leave such end-less situation, it is possible to remount a read-only mounted partition, which can not be umounted (like /), to update configuration and then get a working boot:
mount -n -o remount,rw /mountPoint

The -n option allows to request the mount without attempting to write on the disk (which is obviously not possible on read-only mounted partition).
The -o option allows updating mount options (same syntax than when mounting the partition the "first" time)