Format Your External Hard Disk That Support Mac and Windows with Apple OSX

If you have an external hard disk or thumb drive and you would like to access(read/write) the hard disk on both Mac and Windows, you can format the hard disk with Disk Utility in Mac into several partitions like FAT32, UFS and Max OS Format.

Disk Utility

Go to Finder, and Application > Utilities, and launch the program Disk Utility. Next, I will show you how to format a Thumb Drive into 2 Partitions. When Disk Utility is launched, you can see your Hard Disk/Thumb Drive is shown on the left Panel as the picture shown below;

Next, go to Partition tab to start partition your Drive, you can split the Drive into 2 partitions and on the Format menu, select one for MS-DOS (FAT) and another as Mac OS Extended. Depend on your own requirement, you can split it into 50% 50% or 70% 30%. After you have configured the setting, click on apply (If you are confirmed with the setting.). Your thumb drive will now partition and format.

MySQL 5 Server Cannot Start on Apple Mac Leopard

There were some problem during configuring MySQL5 Server on Leopard with MacPorts when creating default db with command;

sudo -u mysql mysql_install_db5

Error Messages;

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
mkdir: /opt/local/var/db/mysql5: Permission denied
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
chmod: /opt/local/var/db/mysql5: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
mkdir: /opt/local/var/db/mysql5: Permission denied
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
chmod: /opt/local/var/db/mysql5/mysql: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
mkdir: /opt/local/var/db/mysql5: Permission denied
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
chmod: /opt/local/var/db/mysql5/test: No such file or directory

It’s the permission issue, to generate default, try this command;

sudo mysql_install_db5

Now MySQL5’s default DB should be successfully initializes to /opt/local/var/db/mysql5. But there is some problem when starting MySQL;

shell> sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start
Starting MySQL
/opt/local/share/mysql5/mysql/mysql.server: line 159: kill: (31272) – No such process
ERROR!

Have a look at the system.log file on your Leopard;

Jun 9 17:09:59 redarrows com.apple.launchd[1] (0×10bac0.nohup[31285]): Could not setup Mach task special port 9: (os/kern) no access
Jun 9 17:09:59 redarrows com.apple.launchd[1] (0×10bac0.nohup[31286]): Could not setup Mach task special port 9: (os/kern) no access
Jun 9 17:09:59 redarrows com.apple.launchd[1] (0×10bac0.nohup[31291]): Could not setup Mach task special port 9: (os/kern) no access

This should be the permission issue on MySQL database folder, to solve this, chown your mySQL db folder to _mysql:_mysql…

sudo chown -R _mysql:_mysql /opt/local/var/db/mysql5

Now go to the db dir and see the permission;

shell> cd /opt/local/var/db/
shell> ls -al mysql5
drwx—— 5 _mysql _mysql 170B Jun 9 17:09 mysql5

Now, try to start MySQL5 Server again;

shell> sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start
Starting MySQL
SUCCESS!

Hell ya, MySQL5 successfully running on your machine! Voila, Happy MySQL-ing with your Apple Mac Leopard!

Install MySQL5 Server on Apple Mac Leopard with MacPorts

Previously I wrote a post on “installing postgresql 8.2 on Leopard with macports“, seem like quite a no. of people also interested to know how to MySQL5 as server on Mac Leopard with MacPorts.

As usual, it’s advice to update your port before installing any latest software from Macports. To update your Macports;



sudo port -v selfupdate

To configure MySQL5 as server on your Mac Leopard, here are the steps.



sudo port -v install mysql5 +server

After installation, you have to run this command to installd default database;



sudo -u mysql mysql_install_db5

To start MySQL5, run this command;



sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start

After you have started MySQL, change your MySQL’s root default password;



mysqladmin5 -u root password 

If you would like to start MySQL when machine boot up, add the start up script into launchctl. To learn more about launchctl, type



man launchctl

Enjoy MySQL!

Exim, Recipient Verify on Relay and Mail Server

How many of you got dictionary/ratware attack on your mail server which take unnecessary processing load to do virus scanning or spam scoring? We have more than thousand (average) dictionary attack on our mail server in an hour and it has taken a lot processor load (memory even more!), especially it also does scanning with Spam Assassin or SA-Exim.

On Exim, if you have a relay server that does spam scoring or virus scanning, you might need a high processor server to serve the attack or unnecessary scanning, investing on high processor just to do that is not worth it. (That is why we hate Barracuda’s vendor, keep on asking us upgrade to higher end hardware which cost like >RM50k?) .

To overcome the “load”, you can put some trick on Exim’s acl_smtp_rcpt/acl_check_rcpt, let see how it works.

Usually most system admin use verify=recipient/callout=10s,no_cache,defer_ok, but it will always do RCPT call to server to check for valid recipient, it might take a lot of connection resources. To make thing easier, you can generate a list of valid recipient (since it’s your own server), dump it into a text file for example recipients.verified.list with the format as below;

recipient-a@exim.com.my
recipient-b@exim.com.my
recipient-c@exim.com.my

After that, at acl_check_rcpt, put this line in,

deny message = invalid recipient
domains = +relayed_domains
recipients = !/etc/exim/recipients.verified.list

You can put this line before or after accept host = : at acl_check_rcpt. What will the rule do? Very obvious if the recipient is not in the recipients list, it will deny to receive the email and do further process.

Hope this tip will help, continue fighting with Spam ;)

p/s: this was what we get yesterday

shell> grep ‘invalid recipient’ /var/log/exim/mainlog | wc -l
shell> 129794

129794 attacks / day ;) and it was Monday!

Apple Mac Startup Scripts – launchd

Wonder how does Apple Mac machine start up background services automatically? It’s using a daemon called “launchd” for those who are interested to know how mac manages startup programs/services, check our launchd official documentationon Apple’s website.