FreeBSD 9 file server: Wiggum version 2.0

I’ve recently upgraded Wiggum (my file server) from FreeBSD 8.0 to FreeBSD 9.0.  Since I had made some mistakes when originally setting up Wiggum two years ago, I went for a complete reinstall – and recreation of the zpools. This blog entry is a step-by-step guide for how I did the initial installation and setup.

Continue reading

FreeBSD: Filesystem Performance – The Setup

I’ve run a series of benchmarks on my prototyping server to determine performance differences between a variety of configurations:

  • Single drive UFS2
  • Single drive ZFS
  • ZFS 3-way mirror
  • ZFS stripe across 3 drives
  • ZFS RaidZ across 3 drives
  • ZFS RaidZ across 3 drives, plus a SSD as cache.

All the details on configuration and benchmark methods are below!
Continue reading

FreeBSD ZFS: Advanced format (4k) drives and you

Historically, hard drives have had a sector size of 512 bytes. This changed when drives became large enough for such a small sector size to make the overhead of keeping track of these sectors consume too much storage space, making hard drives more expensive to produce than strictly necessary. Many modern drives are tagged as “advanced format” drives; Right now, this means they have a sector size of 4096 bytes (4KiB). This includes most if not all SSDs, and most 2TB+ magnetic drives.

If you create a partition on such a drive without ensuring the partition begins on a physical sector, the device firmware will have to do some “magic” which takes more time than not doing the magic in the first place, resulting in reduced performance. It is therefore important to make sure you align partitions correctly on these devices. I generally align partitions to the 1MiB mark for the sake of being future proof. Even though my current drives have 512B and 4KiB sector sizes, I don’t want to encounter any problems when larger sector sizes are introduced.

Although ZFS can use entire devices without partitioning, I use GPT to partition and label my drives. My labels are generally reference to physical location in the server. For example, Bay1.2 would mean the drive is located in bay one slot two. This makes it so much easier to figure out which drive to replace when the need arise.

Continue reading

How to secure a websites user database?

How often haven’t you read about entire user databases being retrieved from vulnerable websites? And how often do people use the same password multiple places? Let me answer both those questions: too often.

Let us assume that Ada is running a website for her guild. She has decided to code the thing from scratch, and are about to implement the user management system. She decided she’d only need to store username, password, and user type in the accounts table.

She knows that storing passwords in plain text is unacceptable, and think they need to be hashed. Therefore she decides to store the MD5 hashes of the passwords. When someone try to log in, the code checks if the MD5 hash of the specified password is equal to that stored in the database. She’s thinking that if someone somehow attained a copy of the users table, they wouldn’t get to find the real passwords in a sensible amount of time because the passwords are hashed and they’d have to mount a brute force attack to obtain it.

She’s wrong. A direct hashing of a password is vulnerable to rainbow table attacks. While a few conditions apply, this method makes the process of retrieving the password from the user database instant. Even though she didn’t store the passwords in plain text, they’d still be easily exposed. Knowing this, she decide to salt the passwords. This means the password will be modified in some way before being turned into a hash; usually by adding some string to the end of the input password. She knows of two ways to do this.

Continue reading

Review: Logitech K750

I got a hold of a new keyboard: Logitech K750. This is a wireless keyboard with a battery and two somewhat obvious yet discrete solar panels for charging. I like this keyboard. I really do. It’s tiny, neat, doesn’t get in the way and usually gets the job done. It being wireless makes it easy to get it out of the way when doing paperwork or cleaning the desk. And with my use thus far, it claims to have enough juice for 3 months. Although the keys are elegant, they’re too anonymous. The physical marks on the F, J and numpad 5 are too vague and placed too low on the key to really be noticeable. It’s faster to take a look at where my hands are, than to find these marks. Further, the low profile of the keys makes it impossible to navigate the keyboard at large. As an example, it’s hard if not impossible to feel a difference between the Q and 1 or 2 keys, or the 3 key and F2/F3.

The space bar is slightly too wide, taking up are which feels like it should be taken up by the Alt and Alt Gr keys (Norwegian layout). The FN key is too large, making it equally as prominent as the right Ctrl key (which is also slightly too large), making it virtually impossible to autocorrect hand alignment on the keyboard without looking. When punching numbers using the numpad, all the keys feel the same. Since the keys are so low profile, it’s hard to notice when I’m angling my hand too much, ending up pressing * instead of 9 or num lock instead of 7.

Furthermore, the whole keyboard is too low profile. It’s sleek and looks neat, but after having typed this review, my wrists feel tired/strained from typing; Both because of how close to the table the keys are (even with the back-side feet pulled out to tilt the keyboard), and because of how the keys don’t bounce back at all. I know, this isn’t a mechanical keyboard, but other keyboards such as the G19, G15, or most of the Microsoft keyboards do feel like they bounce back a little bit when you push the keys. I suppose the main problem with the keys on the Logitech K750 is that they are kinda like a switch, either down or up; Nothing in between. Which makes it pretty tiresome to type on.

I’d still definitely use this for a media center PC or PS3 though (if it’s compatible); It’s quite neat for having in the living room, and it sure beats navigating the on-screen keyboards with a console controller.