Author: Justin Lee

  • Noisy Neighbours in Singapore

    If you’re wondering, wow, I’m writing a blog at this hour, well that’s because I’ve been awoken at 6AM+ this morning by my neighbour upstairs.

    I had to resort to hammering the ceiling with my fists last night to get them to shut up. That was 1:30AM. Yes, read carefully, my fists. I stood on a stool and hammered the ceiling. This proves that HDB flats are constructed so badly these days. The ceiling vibrated just as it did with the stomping and running upstairs. My flat’s 8 year old BTW. I don’t think my parent’s flat (closing 30 years now) are like that.

    I’m thinking if calling the cops doesn’t work and (according to many online forums) even going to CMC, MP and even court doesn’t work, what works?

    The government loves to take reactive approaches and maybe I should create something to make it happen. It’s called the “I sabo your neighbours, you sabo my neighbours” portal. I am fully committed to funding this portal as long as it brings me peace. I will start putting a plan to get this done. All comments welcome.

  • Tweaking a CF/Flash Linux System

    This is a follow up to my post on Building a CF Card Disk Home Server. I made some simple tweaks so that the system would work faster and more reliably.

    Just to answer JJ’s question on the speed of the CF disk, it’s not faster than a regular hard drive, but that could be due to my cheap CF card. If you’re willing to spend a bit lot more for a faster CF card, it should match the read speeds of regular hard drives, though write speeds may still be lacking.

    So, the focus here is to tweak the system for a CF/flash drive. There are two key differences from hard drives to consider.

    • Flash disks have no problem with random access while hard drives are best accessed sequentially.
    • Flash disks have much more limited write cycles than hard drives.

    With these differences in mind, I picked out the following things to optimize.

    • Encourage random access. This is easily done by changing the default I/O schedulers (e.g. cfq or anticipatory) that buffer I/O requests so that hard drives can process them sequentially. Buffering is not useful for flash disks at all. The best scheduler for random access drives is the noop scheduler, which simply just a n00b (pun intended) FIFO queue. To use it, edit /etc/grub.conf and append elevator=noop at the end of the kernel line, e.g.

      title CentOS (2.6.18-164.11.1.el5)
      root (hd0,0)
      kernel /vmlinuz-2.6.18-164.11.1.el5 ro root=/dev/hda3 elevator=noop
      initrd /initrd-2.6.18-164.11.1.el5.img

    • Discourage swapping to disk. Since the CF disk is slow and has limited write cycles, I reduced the swapping to disk by editing /etc/sysctl.conf and adding a line vm.swappiness=0 at the end.
    • Don’t track file access. Tracking file access means writing the last accessed time to disk every time a file is read, i.e. one write operation for every read. Disable tracking of file access by adding the noatime,nodiratime options to mount points in /etc/fstab, e.g.

      /dev/hda3 / ext3 defaults,noatime,nodiratime 1 1
      /dev/hda1 /boot ext3 defaults,noatime,nodiratime 1 2

    • Don’t write unnecessary files (such as logs) to disk. If you need logs for debugging only while the system is running, mount them as tmpfs. I mounted /tmp and /var/log/httpd (Apache logs) as tmpfs by adding two entries to /etc/fstab as show below.

      tmpfs /tmp tmpfs defaults 0 0
      tmpfs /var/log/httpd tmpfs defaults 0 0

    Anyway, for the curious, here’s the speed of my CF drive. Modern SATA drives can get as much as 60MB/s, PATA drives a little slower around 30-40MB/s.

    # hdparm -t /dev/hda
    /dev/hda:
    Timing buffered disk reads: 58 MB in 3.05 seconds = 19.04 MB/sec

  • Remix of Namewee’s famous CNY Song

    Here’s a remix of Namewee’s famous CNY song that I wrote out of boredom:

    Namewee’s CNY Remix (MIDI, 5Kb)

    For those with old Nokia’ish phones and polyphonic ringtones, you can use the MIDI below.

    If you wish to get your band and a volunteer 唢呐 player, by all means. Here’s the score (click to enlarge) 😛

  • The Beauty of CLI

    While Apple has successfully proven to the world that a well designed Graphical User Interface (GUI) can indeed provide better user experience, the beauty of a good Command Line Interface (CLI) shouldn’t be forgotten either.

    A GUI works well in consumer environments (e.g. SOHO routers), but enterprises and service providers work a little differently.

    I work in a service provider environment and have seen quite a fair bit of “high end” technology products. (These are usually appliance or black box hardware, like firewalls, routers, load balancers, DPIs, etc.) My observation is that while a lot of them have a great solution to an engineering problem, they actually create a management problem. Why? Because of the lack of a proper CLI or a proper management tool.

    There’s only so much a GUI can do to manage something as complicated as, say, a firewall. Check out the screenshots below taken from Mac OS X and Windows XP. They’re surprisingly complicated and not exactly useful. FYI, clicking on the [+] button on the Mac brings you to a file browser; I was expecting a form with IP address, port numbers and protocols.

    Windows XP Firewall Configuration
    Mac OS X Firewall Configuration

    So, how do I add a rule to allow my custom app running on UDP port 15,233? How do I tell the firewall to stop processing further rules if I see a certain TOS marked packet? These aren’t use cases for consumer firewalls, but in enterprises, rules like these are very common.

    Firewalls are actually simple examples of GUI gone wrong. However, there are way more complicated devices than firewalls around, such as load balancers, DPIs and all sorts of routing gear. The problem gets multiplied many folds when there are tens, hundreds or even thousands of these configurations to manage on multiple machines.

    While a fancy GUI gets you through a sales pitch with the higher management folks, it’s really a PITA for the guys (like me) running the show. There’s a certain beauty in CLIs that GUIs cannot emulate. One if them is duplication. It is extremely difficult to duplicate mouse clicks and menu navigation, not to mention getting around errors. Imagine you have 1,000 Windows XP machines. You need to add a new firewall rule to allow your users to access a new mail server. Without Active Directory, you’d have one hell of a time… clicking.

    The other pain of working in enterprise datacenters is the lack of remote access (thanks to NAT and VPN crap) or an actual monitor console. Many engineers run around with a laptop and a RS232 serial cable. That’s all that’s needed to manage a device on the run.

    So if you’re going to build something for the enterprise, particularly appliances/black box devices, please focus some effort on building a proper CLI or centralized management. Learn from the experts – there’s a reason why guys like Cisco, Juniper and Extreme are industry leaders.

  • Building a CF Card Disk Home Server

    Thought I would recycle some old systems in my house, so I dug up an ancient Book PC (Micro ATX?) running Celeron 1GHz with 128MB RAM and decided to do away with the risky hard drive that was generating lots of heat and rebuilt it with a CF card.

    Celeron 1GHz, 128MB RAM

    I got myself several IDE to CF adapters off eBay and also two unbranded 4GB CF cards. Flash disks are getting quite affordable recently and this is a good way to repurpose an ancient machine without having to spend a bomb on SSDs (and maybe a SATA controller).

    IDE (PATA) to CF

    Installed CentOS and I’m off for several hours of Yum update. I’ll turn this into a home development box and print server. No X11 (GUI) on this thing. 128MB is no longer enough to do these fancy stuff on modern distros.

    Good old Socket 7

    One thing though, I’m looking for a more efficient and low profile heat sink/fan combo for Socket 7/370. I can’t find anywhere that sells these stuff now… at least not for a decent price.

    P.S. Due to an ordering error I have two four extra IDE (PATA) to CF adapters. If you’d love to have them, please drop me a message and I’ll happily pass them to you. The wife while (true) { nags(); }takes revenge at my historical archive of  computer hardware, such as the CPU Hall of Fame below by buying more shoes and bags.

    My CPU Hall of Fame
  • No Real Use for Google Wave?

    I can’t seem to think of a very practical use for Google Wave. IMHO it’s a technology that’s neither here nor there. It’s not a very effective replacement for e-mail either as it’s not a scalable model. It’s not exactly a great collaborative tool as well though I agree maybe it has good use for taking meeting minutes and random notes. It’s certainly not a good file sharing or document editing tool.

    I’ve been thinking quite a bit on what I can really do with Wave. It’s frustrating actually 😛

    On a side note, it’s surprising how the ancient DNS and SMTP protocols we take for granted scaled so well. IETF and IEEE are a bunch of geniuses.