Greyhole (Alternative for Windows Home Server Drive Extender)

Greyhole Storage Pool

Previous Storage Solutions

So I had used Windows Home Server when it first came out and loved their Drive Extender feature. It allowed you to add as many drives into a pool and then create shared folders. You can specify how many copies of a file you wanted for each shared folder, therefore providing redundancy. I was extremely sad when they announced that Drive Extender would be removed from Windows Home Server 2011, meaning I would have to look for a new solution.

In the meantime, I had switched to using Macs and had began using SoftRAID as my storage solution. Ultimately, I was highly disappointed with the software given its price. I had set up 2 volumes, a 6TB RAID-0 array and a 3TB RAID-1 array. Both arrays consists of 2 external USB 3TB drives. Things worked great as long as you didn’t reboot. But when you did reboot, there was a 25% chance that the USB drive wouldn’t be mounted in time before SoftRAID times out and marks the array as degraded. Things would be fine if you could just re-add the drive to the array, but unfortunatey it didn’t work like that. It required you to reinitialize the drive and add it as if it was a brand new drive to the array. The rebuild was the worse part as it took 2 days for the drive to be fully rebuilt.

I’ve sent numerous emails to their support requesting the ability to set a drive to read-only until the mirrored drive is remounted or replaced, but it’s fallen on deaf ears. And I’m not the only one that’s hit into this problem. I’m happy to say I’ve officially uninstalled and completely removed SoftRAID from my machine.

Awhile back, I had read about Greyhole being an alternative to Windows Home Server Drive Extender, and finally decided to check it out.

Building the Rig

I decided that I need to build a new rig for my storage server, mainly due to the fact I wanted to take advantage that my external USB drives were USB 3.0.

I had picked up a barebone combo from Newegg a couple weeks ago for less than $200, which included BIOSTAR Hi-Fi A85W, AMD A10-5800K Trinity 3.8GHz, G.SKILL Ripjaws X Series 8GB 240-Pin DDR3 SDRAM. The main reason this combo worked out was because it included everything (sans case and power supply). It also had 8 on-board SATA ports as well as onboard graphics. It’s a pity it only came with 1 stick of RAM, but do I really need more than 8GB of RAM for a file server? There was some free headphones too, but that’ll probably end up in my pile of useless junk in my garage.

I had also picked up a USB 3.0 motherboard adapter, giving me 2 extra USB 3.0 ports.

USB 3.0 Hubs

I don’t know why, but USB hubs tend to fail when dealing with large amounts of data transfers. I’ve tried at least a dozen different USB hubs, and the only one that has work consistently was this Belkin 7-port USB hub, but unfortunately this only supported up to USB 2.0.

Even after the USB 3.0 motherboard adapter, I now had 4x USB 3.0 ports, but 6 external USB drives. So I decided to try Monoprice’s 4-port USB 3.0 hub and am sad to report that it also fails under the high bandwidth scenario. By fail, I mean drives just disappear from the system, and that’s not good for a storage server.

So I ended up connecting 4 of the drives directly to the motherboard’s USB 3.0 ports and 2 of them to USB 2.0 ports. If someone has a good USB 3.0 hub recommendation, I’m all ears.

Installing Amahi + Greyhole

Why Amahi? Greyhole is the storage pool software, but Amahi provides a decent user interface on top of it. Since Amahi recommended Ubuntu 12.04 LTS, that’s what I installed. Ubuntu’s install was rather straight forward. I had to burn a DVD for the first time in a long while. Apparently getting Ubuntu to install via a USB thumbdrive isn’t very straight forward.

Following their instructions, I had a bit of a problem getting Amahi installed. It would failed randomly throughout the installation process, but the third time was the charm. I forgot what I did to fix it, but recall installing some dependencies it was expecting. It also probably explains why Greyhole wasn’t setup properly and I had to rerun the initialization scripts to setup the mysql databases.

Adding Drives

Following their instructions, I got all my drives setup and auto-mounted. I recommend appending nobootwait in your options, so if Ubuntu fails to mount your hdd, it won’t just hang. It’s unfortunate that it will block before the ssh daemon is started, providing no way to fix this remotely, even if you just want it to continue w/o mounting the drive.

I would also recommend physically labeling your drives to match up with their mount location (e.g. drive1, drive2, etc.) so you know which drive is which when it dies and know which one to replace. Fortunately with Greyhole, even if you accidentally remove the wrong drive, sticking it back in is not that big of a deal.

Once the drives are added, they should show up on your Dashboard > Storage:

Amahi Storage

Setting up Greyhole

By default, Greyhole is disabled and you’ll have to enable it in advanced settings. Once enabled, more options under Shares should show up. First you’ll have to select which drives you want to be part of the storage pool. As you can see from screenshot at the top, I’ve enabled everything beside my main OS drive. Adding the main OS drive to the pool is not recommended as you don’t want to run out of space on that drive.

New options should also show up for the shared folders:

Greyhole Shared Folder Options

As you can see, I enabled this specific share to use the pool and to have 2 extra copies (so a total of 3 copies of each file on 3 separate drives). The # of extra copies you can set ranges from 0 to max (# of drives in your pool).

Connecting to Shared Folders

Greyhole exposes these shared folders as SMB/CIFS network drives, very much like Windows shared folders. By default it adds an hda machine name to your network, so to connect to it on a Mac, you’ll connect to smb://hda/name_of_share.

I’ve found that on the Mac, if you want it to automatically connect to the network share, the easiest way is to drag and drop the share to your list of login items in Settings > Users & Groups. Unfortunately this has the side effect of opening all the share windows when you login. In my case I have about 10 different share folders that get opened upon logging in.

How Greyhole Works

One of the things that confused me early on was the fact that after making changes to a particular share, Greyhole didn’t seem to do anything. Logs showed that it was just sleeping, even though I just told it to add an extra copy of everything in this non-empty share.

It turns out Greyhole is a daemon service and it will act when new files show up, but any settings changes you make to an existing share don’t actually execute until it does it’s nightly file system check. I’ve learnt you can manually trigger the file system check by running sudo greyhole -fsck.

When you copy files into a share, they all get dumped into a default location (configurable). The greyhole daemon service will kick in and depending on your settings, begin moving or duplicating files onto drives designated to be part of the pool.

I do have to warn you never to run sudo greyhole -D as it starts a new instance of the Greyhole daemon which confuses the shit out of each other. When one service was copying a file, another was deleting it. When the 1st service sees the file is now gone, it assumed the user deleted it and deletes all its copies. Good thing I always double check with rsync to make sure all copied files are good.

What you should do instead is: sudo service greyhole start | restart | stop

Greyhole also has an option to balance available space among the drives, which I assume means if you added a new drive to the pool, it would shift the files around, so you won’t have one drive that is fully packed, while another is completely empty. The command to do this is sudo greyhole -l, but I haven’t really seen it do much.

Removing / Replacing Drives

One of the best benefits of Greyhole / Drive Extender is the ease of adding/removing drives. I’ve already discussed about adding drives, and removing drives isn’t that much more work. If a drive is still working, but will be removed, you mark it as “going”. Greyhole will begin to move the files off of it onto other drives in the pool. If a drive is dead, you mark it as “gone”. For files that don’t have extra copies, unfortunately those aren’t recoverable. For files that do have duplicate copies, Greyhole will begin duplicating them off other drives to ensure the # of copies matches your settings.

Once the process completes, it’s safe to remove the drive.

Trash

You ever get that dreaded warning when you’re deleting files from a network share warning you that deleting this file will be permanent? Yeah, I always double check to make sure I didn’t accidentally select the wrong file (god forgive, wrong folders). With Greyhole, when you delete a file, it gets moved to a Trash shared folder, which you can mount and access like your recycle bin. To empty the trash, just run sudo greyhole -a

Monitoring Greyhole

There’s a couple ways to monitor what Greyhole is doing.

  • watch greyhole -q displays your list of shares and # of operations queued.
  • greyhole -s shows you the stats of your drives (e.g total/free space)
  • greyhole -S shows you a summary of what Greyhole is doing.
  • greyhole -L tails the log file telling you exactly what it’s doing.

Remote Access

A couple things you want to install right off the bat are openssh server and vncserver.

I found it rather weird that a linux distro didn’t have an ssh daemon installed by default. It does have vnc server, but it requires you to login at the console before you can “share desktop”. The reason why you need VNC is because the Amahi dashboard is only accessible on that machine. For most Greyhole functions, you can control it via SSH.

I had a lot of trouble getting the VNC server working (w/o having a user logged in). Unfortunately detailing how I got it to work would be another giant post in itself, but if you have questions, leave a comment below and I’ll try my best to answer.

BluetoothAdapter.getDefaultAdapter() throws RuntimeException: Can’t create handler inside thread that has not called Looper.prepare()

So I’m using some hardware SDK that attempts to scan for bluetooth devices on Android and hit into this exception below when calling: BluetoothAdapter.getDefaultAdapter()

Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
    at android.os.Handler.<init>(Handler.java:121)
    at android.bluetooth.BluetoothAdapter$1.<init>(BluetoothAdapter.java:984)
    at android.bluetooth.BluetoothAdapter.<init>(BluetoothAdapter.java:984)
    at android.bluetooth.BluetoothAdapter.getDefaultAdapter(BluetoothAdapter.java:329)

After researching this problem, it turns out there’s a bug in Android (which apparently still exists in Android 4.0: Ice Cream Sandwich according to the discussions I’ve been reading). The bug is during the initialization of the default adapter, there exists UI code which means it needs to be ran on the UI thread.

Update 2013/04/22: Martin has brought to my attention that as long as you call BluetoothAdapter.getDefaultAdapter() inside any thread that has already called Looper.prepare(), it should work. It doesn’t have to be the UI thread.

I was attempting to use AsyncTask to search for bluetooth devices in the background. Workaround suggest running the code in the main thread or using Handler so that code is queued in the main thread. Unfortunately both solutions block the UI thread and what you see is a progress dialog with a spinner that stops spinning.

It turns out however if you call BluetoothAdapter.getDefaultAdapter() in the main UI thread, calling it subsequently no longer crashes, even in background threads.

Hope that helps!

Twitter Weekly Updates for 2012-10-14

  • @mendkr Glad you made it back! Sounded like quite a trip. in reply to mendkr #
  • Nowadays, even if one engine fails and blows up, the rocket can still make it into space: http://t.co/4UAkaQGq #
  • A good way to find out which apps are using location services on iOS 6: Settings > General > Restrictions > Location Services. #
  • Turns out Just Landed was still tracking a 3-week old flight and Passbook was constantly checking if I'm near my favorite Starbucks. #
  • @rothgar Picture makes you look like you were face-planted into the sand ;p in reply to rothgar #
  • Not as cute as Om nom, but Petit from Contre Jour is cute and fun. Reminds me of Limbo. Now available on HTML5: http://t.co/trlW7ORn #
  • I wonder if flies and other insects feel pain when they ram into a window. If they do, they certainly don’t learn not to do it again. #
  • @fearthecowboy I know! They say the comment system should be back up soon, but not soon enough! in reply to fearthecowboy #

Twitter Weekly Updates for 2012-09-30

Twitter Weekly Updates for 2012-09-16

Xbox 360 Needs a Better Keyboard UI

Update: This post was drafted back in October 2009. I had submitted it as feedback to Microsoft/Xbox 360, but never really heard back. Steam just announced their Big Picture which featured a keyboard system (Daisywheel) very similar to mine (I know there are quite a few differences), so I decided to publish this post.

During the past Xbox 360 beta, I had made the following suggestion to the Xbox 360 team.

I’ve always found the keyboard UI to be clunky and difficult to use with the controller. I understand the chatpad or a keyboard would make it more easy, but I’m pretty sure most people using the Xbox 360 still use the controller to type in text. When I found out I could redeem codes via their website, it was a blessing. Typing those 25 character codes always took an inane amount of time. Now that they plan on releasing Twitter and Facebook and other apps that can require a lot typing, it’s ridiculous to use the existing keyboard UI with the controllers to type.

That’s what got me thinking of a better keyboard UI with the current controllers.

Currently we use the L-joystick for moving the cursor up/down/left/right and hitting A to select a character. To enter 1 character, I may have have to move the cursor up to 15 steps.

One thing I’ve been thinking of is that we have 2 joysticks, each with 4 axis with 8 degrees of control, which we do not take advantage of. 8 x 8 is a total of 64 possible characters. If you consider the center position (joystick in relaxed position) to be another state, that’s 9 x 9 = 81 possible characters.

Here’s a rough sketch of what the UI would look like:

Xbox 360 Keyboard UI Sketch

To type the number ‘1’, all I would have to do is point the L-joystick left, point the R-joystick up, and then push on R-joystick. Each letter would only take 3 actions (move L-joystick, move R-joystick, push on R-joystick).

That leaves the buttons (A, B, X, Y), bumpers and triggers to do other stuff like delete or move the cursor. You can even dedicate a button to switch back to the current keyboard mode. The D-pad would be perfect for this job.

As you may have noticed in my sketch, there’s a lot of empty spaces. I originally thought of putting every single character (symbols, numbers, both upper and lower case characters) on that, which is still a viable idea. Another option would be to drop that down to 5 circles (center, up, down, left, right), each circle having 8 possible characters like it is now, giving me 40 characters, which is about the same amount of characters on-screen today. You would then use the D-pad to toggle between upper and lower case, as well as symbols.

Of course there’s still more stuff to flush out, but I thought the idea was sound.

Also, given that the PlayStation 3 has a similar controller, I could see this being used on their console UI also.

Twitter Weekly Updates for 2012-09-09

Twitter Weekly Updates for 2012-09-02