… and a tear came to my eye. Go and see the film while it is being played. It’s fantastic… and so was Michael Jackson. RIP.
Archives for November 2009
Why I blog less now
While reading Dan Cederholm’s blog, I found this small gem:
Like anyone who used to blog with frequency pre-2005, I’d like to post here more often — not just to fill up bits and bytes, but to write again. Remember when blogs were more casual and conversational? Before a post’s purpose was to grab search engine clicks or to promise “99 Answers to Your Problem That We’re Telling You You’re Havingâ€. Yeah. I’d like to get back to that here.
Then again, history teaches us that it probably won’t happen.
I guess this is why I blog less now.
Incidentally, I have been listening to a lot of Electroclash (aka Electro IV aka New wave III aka Synthpop II) during those past months. Fischerspooner is excellent. It’s healthy noise…
Installing Avahi and AFP on the DNS-323
The D-Link DNS-323 NAS is great. It runs Linux, is infinitely tweakable and plays nicely with most devices I have at home including my MacBook, my Linux boxes and my Wii running MPlayer CE which I use to watch DivX on my TV.
The only problem I had was that the NAS only offered SMB (via Samba) out of the box which meant that some operations were somewhat slow when initiated from my MacBook. For instance, deletes were slow even though transfer speeds were great. After reading some posts online, I realised that the solution was to activate AFP (Apple Filing Protocol) as well as Multicast DNS (Bonjour) on the NAS. AFP is provided by Netatalk and Bonjour by Avahi.
Of course, to install new software on the DNS-323, you must have fun_plug properly activated.
Installing Avahi on the DNS-323
Install both with
funpkg -i libdaemon-0.13-1.tgz funpkg -i avahi-0.6.24-1.tgz
2) Add an avahi user
groupadd -g 50 avahi useradd -u 50 -g avahi -d /tmp -s /bin/false avahi
3) Create a startup script called /ffp/start/avahi.sh as shown here.
#!/ffp/bin/sh # PROVIDE: avahi # REQUIRE: SERVERS . /ffp/etc/ffp.subr name="avahi" command="/ffp/sbin/avahi-daemon" avahi_daemon_flags="-D -s" required_files="/ffp/etc/avahi/avahi-daemon.conf /ffp/etc/avahi/hosts" start_cmd="avahi_start" avahi_start() { # need avahi user and group for priviledge separation if ! grep '^avahi:' /etc/passwd >/dev/null; then echo 'avahi:x:50:50:Avahi Daemon:/no/where:/bin/false' >>/etc/passwd fi if ! grep '^avahi:' /etc/shadow >/dev/null; then echo 'avahi:*:14493:0:99999:7:::' >>/etc/shadow fi if ! grep '^avahi:' /etc/group >/dev/null; then echo 'avahi::50:avahi' >>/etc/group fi proc_start $command } run_rc_command "$1"
4) Make the file executable so that avahi starts when the DNS-323 boots
chmod +x /ffp/start/avahi.sh
5) Create /ffp/etc/avahi/services/smb.service
<?xml version="1.0" standalone="no"?><!--*-nxml-*--> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_smb._tcp</type> <port>445</port> </service> </service-group>
6) Create /ffp/etc/avahi/services/http.service
<?xml version="1.0" standalone="no"?><!--*-nxml-*--> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_http._tcp</type> <port>80</port> </service> </service-group>
7) Create /ffp/etc/avahi/services/device-info.service (This changes the ICON shown in Mac OS X)
<?xml version="1.0" standalone="no"?><!--*-nxml-*--> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=RackMac</txt-record> </service> </service-group>
8 ) Launch avahi
/ffp/start/avahi.sh
Installing AFP (netatalk) on the DNS-323
1) Get db42 and netatalk and install both with
funpkg -i db42-4.2.52-1.tgz funpkg -i netatalk-2.0.4-1.tgz
2010-10-27: an important update courtesy of David:
It looks like netatalk-2.1.3-1 now requires db48-4.8.30-1 instead of db42-4.2.52-1. I installed db48 and removed db42, and I can connect to the DNS-321 via AFP without any problems, including over a reboot.
2) Create a startup script called /ffp/start/afpd.sh as shown here.
(Important update for Snow Leopard users: It seems that netatalk 2.0.4 does not work properly with Snow Leopard and provokes CNID errors. You should use the latest netatalk 2.1 and follow Ivan’s recommendations to start the cnid_meta daemon automatically for everything to work. Thanks Ivan!
Furthermore, according to Ole, /ffp/etc/netatalk/afpd.conf needs to be modified to have the following line (make sure that you have everything on one line):
"servername" -uamlist uams_dhx.so,uams_clrtxt.so -setuplog "default log_info /ffp/var/run/afpd.log" -cnidserver
He says: “It is important to have the -cnidserver at the end. Dont know why, but it is.”)
#!/ffp/bin/sh # PROVIDE: afpd # BEFORE: # REQUIRE: . /ffp/etc/ffp.subr name="afpd" start_cmd="afpd_start" stop_cmd="afpd_stop" status_cmd="afpd_status" afpd_start() { /ffp/sbin/afpd } afpd_stop() { killall afpd } afpd_status() { ps -A | grep /ffp/sbin/afpd | grep -v grep } run_rc_command "$1"
3) Make it executable with
chmod +x /ffp/start/afpd.sh
4) Create /ffp/etc/avahi/services/afpd.service as show here.
<?xml version="1.0" standalone="no"?><!--*-nxml-*--> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_afpovertcp._tcp</type> <port>548</port> </service> </service-group>
5) Use the “vipw” command and change some details for the default “nobody” user so that Mac OS X can use that user to log in.
nobody:x:501:501:Linux User,,,:/home/nobody:/ffp/bin/bash
Give a password to that user and store the password (in clear text) in the user’s home directory as shown here.
passwd nobody cd /home mkdir nobody echo "secret" > nobody/.passwd chown -R nobody: nobody
It is essential to store this user’s information in the flash memory of the DNS-323. Do this with:
store-passwd.sh
6) Modify /ffp/etc/netatalk/AppleVolumes.default to add the required shares. Mine looks like:
# The "~" below indicates that Home directories are visible by default. # If you do not wish to have people accessing their Home directories, # please put a pound sign in front of the tilde or delete it. # ~ /mnt/HD_a2 Volume_1 /mnt/HD_b2 Volume_2
Notice that I have commented the ~ because I don’t want the user to have a home directory on the DNS-323. I only want to access Volume_1 and Volume_2.
7) Start netatalk
/ffp/start/afpd.sh start
Making Mac OS X Leopard play nice with Netatalk
To allow Leopard to connect to AFP shares with clear text (unencrypted) passwords, do as shown here:
# to be done on the Mac and not the DNS-323 sudo defaults write com.apple.AppleShareClient "afp_cleartext_allow" -bool YES sudo defaults write com.apple.AppleShareClient "afp_cleartext_warn" -bool YES
Enjoy!
You can now connect to the DNS-323 from a Mac and get optimal performance. Phew. Linux is sooooo fun… for geeks like me :-)
5 November 2009 update: Instead of creating a new user, the existing user “nobody” is used. This allows the DNS-323 to be used through AFP and SMB transparently as SMB uses “nobody” by default. Interestingly, when the DNS-323 reboots, its /home directory starts anew and therefore will lack a /home/nobody directory (with its .passwd file) but this does not seem to trouble Mac OS X.