Building a home file server with Debian 8.2 (jessie): Part 1

I’ve been running my own home file server for many years now. I’ve used it for everything from storing old documents and photos to running a Minecraft server for my cousins. With online backup services like Dropbox it’s become less of a necessity but I still like having one around.

My current file server has been aging and is starting to sound a bit wheezy. It was originally built into an old desktop “Mid Tower” ATX sized case. So, time for something smaller and hopefully quieter.

The Build

Here is the build as spec’d out on PCPartPicker:

  • Case: Lian-Li PC-Q26B Mini ITX Tower Case
  • CPU: Intel Core i3-4170 3.7GHz Dual-Core Processor
  • Motherboard: ASRock H97M-ITX/AC Mini ITX LGA1150 Motherboard
  • Memory: Crucial Ballistix Sport 16GB (2 x 8GB) DDR3-1600 Memory
  • Storage: 2x Western Digital Caviar Blue 250GB 3.5″ 7200RPM Internal Hard Drive
  • Storage: 3x Western Digital Red 4TB 3.5″ 5900RPM Internal Hard Drive
  • Power Supply: SeaSonic X Series 400W 80+ Platinum Certified Fully-Modular Fanless ATX Power Supply

http://pcpartpicker.com/p/qxJ86h

It could be done cheaper but this is a fun project for me so I splurged a little.

After the parts arrived and I’d put everything together it was time to install Debian.

The Installer

First thing was to build a new live USB installer. I grabbed the standard Debian 8.2 (jessie) iso from my nearest mirror (the OSU Open Source Lab). Then I popped a 4GB thumb drive into my Macbook and ran:

diskutil list
diskutil unmountDisk /dev/disk2
sudo dd if=~/Downloads/debian-live-8.2.0-amd64-standard.iso of=/dev/rdisk2 bs=1m

Debian

My old file server was running RAID 5 for the storage partition but the Operating System was running on a single disk that could fail at any time. If that had happened it would have been a huge hassle to reinstall and reconfigure everything. I wanted to avoid that possibility this time around by installing Debian to a RAID 1 (mirrored) array.

Installing Debian to a RAID 1 array can be done entirely from the built-in installer. I pretty much followed this guide from the Debian wiki to the letter:

https://wiki.debian.org/DebianInstaller/SoftwareRaidRoot

I chose rootfs for my logical volume name. You can ignore the part about lilo at the end.

Note: You can skim the LVM section if you’d like and simply install Debian directly to your RAID volume.

The first boot

After the first successful boot I made sure to run dpkg-reconfigure grub-pc and install grub on both members of /dev/md0, /dev/sda and /dev/sdb, to ensure either drive would be bootable.

Then I went about with my usual configuration.

First I added my laptop’s public key to my user’s ~/.ssh/authorized_keys file so I could access the server remotely without bothering with passwords.

Then I modified the /etc/ssh/sshd_config to disable access for the root user and for password based authentication:

PermitRootLogin no
# ... snip
PasswordAuthentication no

Finally, I wanted to make sure I’d know if one of the members of the RAID array becomes degraded so I needed to make sure e-mail could be sent from the server. To do this I had to configure exim4 to send via Gmail’s SMTP gateway.

This seemed complicated at first glance but proved to be much simpler than it seemed. I basically followed this guide (again from the Debian wiki):

https://wiki.debian.org/GmailAndExim4

You can ignore the part about /etc/email-addresses.

Also, use the command service exim4 restart instead of invoking the rc.d command directly.

Where it asks for your Gmail password I suggest generating a new App Password specifically for your server.

You can send a test message by:

echo 'This is only a test' | mail -s 'Hello World!' test@example.org

Since I was in a monitoring mood I also installed smartmontools to monitor the health of the drives. This includes a daemon that will notify you if any SMART errors are detected.

First, install apt-get install smartmontools. Then, edit etc/default/smartmontools and uncomment the line #start_smartd=yes. Finally, restart the service with service smartmontools restart.

The first problem

I wanted to make sure the system would boot in a degraded state if one of the drives failed. To test this, I shut down the system and removed one of the drives. Upon restarting, I was greeted with the following error:

Unable to find LVM volume vg1/rootfs
  Volume group "vg1" not found

https://goo.gl/photos/5G4ZCQSYrEnwQaAT6

… then dumped into the initramfs recovery console (BusyBox).

After a break and some intense Googling I discovered that mdadm was marking the array as inactive on boot instead of starting it in a degraded state as expected. Because the physical volume was not available LVM was throwing a misleading error.

To fix this problem you can run the following from the initramfs recovery console (BusyBox):

mdadm --run /dev/md0
vgchange -a y
exit

Your system should now boot normally from a degraded state.

After booting, I used the command mdadm --manage /dev/md0 --re-add /dev/sdb1 to restore the removed drive to the array.

This issue appears to be a bug in Debian 8.x (jessie) that should be fixed in future versions:

Read part 2.

Mount your ntfs drive on boot in Ubuntu

So you’ve got an NTFS drive you want mounted when your Ubuntu machine boots? Time to pull up your favorite editor and modify /etc/fstab.

This is what I ended up with:

/dev/mapper/sil_aiaiahddacai1 /media/Storage ntfs-3g defaults,gid=1000,uid=1000,locale=en_US.UTF-8 0 0

Replace the gid and uid values with the ids of your group and user. Run id to get these values.

I also had to make sure I created the mount point, otherwise it would fail:

$ sudo mkdir /media/Storage

Anything I’m missing? So far it seems to work just fine.

upaste

After a brief and torrid affair with Fedora, I gave up and threw Ubuntu 10.04 on my home desktop. One thing that I missed from Fedora was the fpaste utility. This handy little command-line tool lets you paste the results of your shell commands to fpaste.org, a semi-official Fedora pastebin.

After realizing that pastebin.com had an open API, I took it upon myself to write a little Python script that could submit pastes for me.

And so I give you upaste (u for Ubuntu, but it can run on any *nix flavor, including OS X). Please try it out and give me your thoughts. I hope someone will find it useful.

Installing

Download the source from bitbucket.

# Copy the upaste file somewhere in your $PATH
$ sudo cp upaste /usr/local/bin/
 
# Then run!
$ ifconfig | upaste
 
# -h is for help
$ upaste -h
Usage: upaste [options]
  Posts a file to http://pastebin.com/ and returns the URL.
  If no file arguments are given, input is expected on stdin.
 
Options:
  --version           show program's version number and exit
  -h, --help          show this help message and exit
  -p, --private       mark your paste private.
  -f FILENAME         filename whose contents you wish to paste.
  -n PASTE_NAME       add your name or a title to paste.
  -e PASTE_EMAIL      send a confirmation email with paste link.
  -s PASTE_SUBDOMAIN  use a pastebin subdomain.
  -x PASTE_EXPIRE     set paste expiration: N = Never, 10M = 10 Minutes, 1H =
                      1 Hour, 1D = 1 Day (default), 1M = 1 Month.
  -l PASTE_FORMAT     define the default syntax highlighting for your paste.

Vim

So I recently started using Vim as my text-editor of choice. I used to hate Vi with a passion, but lately I’ve grown frustrated with the bloated, laggy IDE’s of today, so I turned to Vim.

Vim is a super lightweight text-editor that you run from the terminal. The command syntax made no sense to me at first, but slowly I started to learn the basics and soon I was working along as fast as I ever had.

The nice thing about Vim is I can ssh into my web-host and edit files right in the terminal without having to muck with a “Save remotely as” feature.

The one thing with Vim is you’ll probably want to enable syntax highlighting right off the bat.

Here’s my ~/.vimrc config file if you’re interested:

syntax on
colorscheme slate
set number
set expandtab
set tabstop=4
set shiftwidth=4

This will turn syntax highlighting and line numbers on, set your default colorscheme to something that isn’t horrible and set your tabs to four spaces (mainly for Python development).

I’m even running split views in Vim now, I feel so 1990’s.

Banshee music player won’t play or seek on Linux

If you install Banshee on your Linux box expecting it to play music, you’re in for a surprise. Banshee depends on the GStreamer codec packages for audio and video decoding (and encoding).

Unfortunately, most of the codecs you want are not packaged with most Linux distros by default.

Does Banshee support audio/video format X (mp3, aac, mpeg, etc)?

Banshee uses GStreamer for audio and video decoding (playing) and encoding (ripping, format conversions). Whatever codecs you have installed for GStreamer, Banshee will be able to use (with a small number of exceptions).

— From the Banshee FAQ.

While installing Banshee you should install a few of the GStreamer packages as well.

Ubuntu

$ apt-get install banshee gstreamer0.10-ffmpeg gstreamer0.10-plugins-ugly

Fedora
First add RPM Fusion to your list of yum repositories. Then install.

$ yum install banshee gstreamer-ffmpeg gstreamer-plugins-ugly

Once you install the GStreamer packages Banshee should work as expected.

Adventures With Moblin Linux

mob-toolbar

About a week ago I decided to throw the Moblin v2.0 beta [Wikipedia] on my netbook (an Acer Aspire One). I’ve previously been running the Ubuntu Netbook Remix and have been pretty happy with it. I haven’t been using my netbook much lately and Moblin’s was rocking new interface really intrigued me. So I decided to try it out.

Moblin’s core release is built on top of Fedora using a custom-built GNOME UI. Moblin uses a wicked-fast animation library called Clutter. This makes the interface a delight to use. I was thrilled the first time I booted up the OS and not just because of the interface. I had heard how fast Moblin boots, but I was blown away when I saw it in person. I clocked the boot time on my Aspire One at 10 seconds flat. That’s absolutely incredible.

Now granted, I haven’t had much time to play with Moblin yet, but here are my impressions so far. It’s buggy. Really buggy, even for a beta. But it has an amazing amount of potential.

Let’s start with the good. Moblin is taking the netbook OS in a totally new direction, the direction they should all have been going from the start. Instead of treating your netbook like a stripped down laptop, it treats the hardware as a portal to your online experience. The Moblin OS quickly and easily integrates updates from sites like Twitter and Last.fm into your “myzone” (the landing page of the OS). Moblin also features a “pasteboard” to collect all your copied data in one easily accessible place.

In all honestly it works a lot like a web application, which is good. Very very good (note: this opinion coming from a web developer). The Moblin team has also included easy access to the terminal and other applications. A wonderful thing for those of us who despise a crippled Linux OS. Let’s hope this doesn’t change in future releases.

Now with the bad. While many of the applications worked flawlessly out of the box (so to speak), many did not. I had numerous issues with the web browser trying to log in to Facebook and MySpace (it just seemed to stall out). The “Instant Messenger” application, which appears to be built on Pidgin, was heinously difficult to configure. It was also missing support for AIM accounts. I mean seriously, who doesn’t support AIM integration these days.

The “Network Manager” did find my wireless network right away and connected without a hitch. However, on subsequent reboots it did not automatically reconnect. Very irritating.

I also experienced multiple segfaults (think blue screen of death on Windows) while trying to take some screencaps for this blog post. I finally had to reboot the netbook to get around this. I have never experienced a segfault in Ubuntu.

Finally, there were a few little issues I noticed, like some hotkeys not working (print screen for one). The top menu bar was also a little touchy for my taste. Whenever I moused up to the address bar in the web browser the menu bar would pop down and obscure my view. I’d also like to see an alternate layout for the “myzone” page. It’s hard to pick out updates as being from Twitter or Last.fm. They sort of all blend together.

Despite these problems, I remain incredibly enthusiastic about Moblin. The software is definitely still in beta, so we can’t rag on them too hard. I’m sure many of these issues will be polished out before it goes into production. Especially with Acer and other OEM manufacturers quickly lining up to embrace Moblin.

I think that Moblin is a step in the right direction for both Linux fans (or fanatics) and Windows or Apple OS X users. Moblin’s UI seems bubbly enough to appeal to even the most die-hard Windows user.

Using an Adesso Barcode Scanner With Ubuntu

We’re gearing up to test out a new ticketing system at work. We’ll be scanning barcoded tickets using an inexpensive USB Adesso Barcode Scanner. Unfortunately, on my Ubuntu (9.04 jaunty) netbook, the scanner would disable itself immediately after I scanned a barcode. Here’s how I fixed it:

1) Add the following lines to the bottom of your /etc/modprobe.d/blacklist file:

# these drivers are very simple, the HID drivers are usually preferred
#blacklist usbmouse
#blacklist usbkbd
blacklist usbhid

2) Add the following line to the bottom of your /etc/modules file:

usbkbd

3) Reboot.

This will make your system prefer the usbkbd driver over the HID one. Apparently the scanner likes the older usbkbd driver better.

Corporations that listen

When I’m talking about public relations what I’m really talking about is communicating. Communication is the key to developing strong relationships, not only between two caring people, but also between businesses and their publics (employees, customers, shareholders, etc). What public relations is all about is people learning about each other and developing a mutual understanding. One of the best ways to do that is of course Grunig’s two-way symmetrical model.

The two-way symmetrical model is basically a way for two groups of people to share ideas and (hopefully) gain something from the experience. This is an ideal way to communicate and technology has made it easier to do than ever before!

Many companies are taking advantage of new web technologies to encourage two-way communication. Just today Asus and Intel launched a new website called WePC (see Engadget). This new website allows users to submit their own designs and ideas for a new notebook computer. The submitted designs and posted feedback will be considered by both Asus and Intel and may actually be incorporated into a finished product. The WePC about page states:

Your designs, feature ideas and community feedback will be evaluated by ASUS and could influence the blueprint for an actual notebook PC built by ASUS with Intel inside.

Dell is another company that has had good experience with the two-way symmetrical model. In February of 2007 Dell launched a new website called IdeaStorm (see entry at Wikipedia). The IdeaStorm website is very similar to the WePC one, in that it allows users to submit articles, comment on existing ones, or vote them up or down. Almost immediately, Dell received an overwhelming number of requests to offer an alternative, open-source operating system as an option on new Dell computers. This flurry of responses eventually convinced Dell to begin offering computers with the Ubuntu (Linux) operating system pre-installed (see here and here).

Now I think that’s a pretty great result. Not only did customers get exactly what they wanted from Dell, but Dell also proved that they were listening to their customers and were willing to give them what they wanted. That’s great communicating and great publicity!