Mounting an Apple Share on Ubuntu 11.10

I ran into a few problems trying to mount my AFP share (netatalk) being hosted on my Solaris NAS from my Ubuntu 11.10 VM. These are the steps I took to get it to work.

# apt-get install libreadline6 libreadline-dev libreadline6-dev libgcrypt-dev libgmp3-dev libfuse-dev

Then I downloaded the latest version of afpfs-ng and installed from source.

$ ./configure
$ make
# make install

To mount the volume use the following command:

$ mount_afp afp://user:password@192.168.1.101/sharename /media/AFP

It should be noted you can compile, install, and attempt to mount the share but will get the following error without libgcrypt-dev libgmp3-dev packages installed.

Mounting 192.168.1.101 from User on /media/AFP
Could not pick a matching UAM

Bandwidth throughput increase.

Seems like running a virtualized router on the Xeon server will pull faster (60%+) download speeds than my Linksys WRT54G Router would.

woot 45Mb/s

pkg.oracle.com is down; I need some packages, what do I do now?

Okay, so your system had a complete failure without any working snapshots to rollback on or you simply need a few packages and pkg.oracle.com is down. What do you do now? Well thankfully Oracle has added this new feature called Image Packaging System (IPS) in Solaris 11 Express. By the name you can deduct that it is package imaging system; which is exactly what it is. It allows you to run a concurrent repository, mirror of another repository, or just a repository for packages you’ve assembled.

 

First you’ll need to download the Oracle Solaris 11 Express 2010.11 Repository Images. It will require that you concatenate the files together once unzipped. The final iso will expand to a 5.1GB from the two 2GB files you’ve downloaded.


$ wget http://download.oracle.com/otn/solaris/express/sol-11-exp-201011-repo-full-iso-a.zip
$ wget http://download.oracle.com/otn/solaris/express/sol-11-exp-201011-repo-full-iso-b.zip
$ unzip sol-11-exp-201011-repo-full-iso-a.zip
$ unzip sol-11-exp-201011-repo-full-iso-b.zip
$ cat sol-11-exp-201011-repo-full-iso-b >> sol-11-exp-201011-repo-full-iso-a
$ mv sol-11-exp-201011-repo-full-iso-a sol-11-exp-201011-repo-full.iso

 

After you have the ISO you’ll need to mount it. For this you’ll need to mount it as a block device, on Solaris there is lofi, or loopback file driver. -a switch adds a file to known files used as block devices. Later you can use the -d switch to destroy the file association or you could go the way of Windows and wait for a reboot.

# lofiadm -a /home/epijunkie/Downloads/sol-11-exp-201011-repo-full.iso
/dev/lofi/1
# mkdir /mnt/ips
# mount -o ro -F hsfs /dev/lofi/1 /mnt/ips

Next you’ll need to a place for the packages to permanently reside. For this I create another ZFS filesystem as part of my main pool. Doing this allows me to turn on compression as it won’t be accessed often and it will be out of the way. The command below also sets the mount point.

# zfs create -o compression=on -o mountpoint=/mnt/repo2010_11 ZFS/ips_repo

The files from the DVD need to be copied over retaining their attributes. Using rsync with the --archive switch will recurses into directories, copies symlinks as symlinks, and preserves permissions, modification times, user ownership, group ownership, device files and special files.

# rsync --archive /mnt/ips/repo /mnt/repo2010_11/

After this is complete you won’t need the DVD iso so it’s safe to unmount and delete the files.

# umount /mnt/ips
# lofiadm -d /dev/lofi/1
# rm -d /mnt/ips
$ rm ~/Downloads/sol-11-exp-201011-repo-full*

Next is setting options for pkg/server service through Service Management Facility (SMF).

# svccfg -s application/pkg/server setprop pkg/inst_root=/mnt/repo2010_11/

Next is rebuilding index which allows for searches and statistical information.

# pkgrepo -s /mnt/repo2010_11/repo/ refresh
Repository refresh initiated.

 

Next you will need to refresh the configuration and start the pkg/server.

# svcadm refresh application/pkg/server
# svcadm enable application/pkg/server

 

At this point you’ll be able to point your browser to http://localhost and browse your locally repository.

 

This command replaces (-G) the Oracle’s online repository with (-g) your locally hosted one. This is helpful if pkg.oracle.com is down by speeding up queries and downloads.

# pkg set-publisher -G http://pkg.oracle.com/solaris/release/ -g http://localhost/ solaris

 

If you want to leave this offline configuration but still want fresh updates from Oracle setup a cron job to run this periodically:

# pkgrecv -s http://pkg.oracle.com/solaris/release/ -d /mnt/repo2010_11/repo/ --newest

 

Thanks to swinful for his article that first got me kick started on this; I’ve made some additions but swinful’s cat command was a clever one over Oracle’s doc.

OS X Lion – Getting rid of the static / noise from using a Voodoo HDA Kext

This is a simple fix to fix the static noise you get from what I imagine is electronic spill over. I stumbled on this fix after many hours of tinkering to get my Gigabyte GA-EP43T-USB3‘s ALC888 audio chipset to work properly. I setup my Snow Leopard install a while back and completely forgot how I did it. I don’t believe I documented it because once I found out how to do it, well it was too easy.

 

 

After you install the Kext you’ll want to reboot and then turn down the input volume to 0% in the System Preferences > Sound > Input window.

 

How to keep photos safe while on vacation.

This is a script I wrote to backup a friend‘s photos from his Compact Flash cards to both a USB drive and a remote server while he visiting Japan for the next month. This script also verifies data transfers by running md5deep on the source files (CF card) and then checks them against the files on the USB drive. I wrote this for an Ubuntu netbook he is taking along with him but the commands should work on any *nix based system including Mac OS X; a md5deep binary may be needed.

#!/bin/bash
echo "Creating variables"

# This is the compact flash card (The pure data as Chase Javis would say)
# If you have a Canon you'll recognize the folder structure
PHOTOdrv="/media/EOS_DIGITAL/DCIM/100CANON"

# USB Backup device, or perhaps a local folder on your laptop.
USBdrv="/media/My\ Passport"

# SSH Variables. The folder has to exist already on the remote host.
SSHuser=jesus
SSHhost=epijunkie.com
SSHdirectory=~/photos

# Unless you know what you are doing it's suggested not to edit anything below.
DATEcode=`date +%F%k%M`
MD5=$DATEcode".md5"
echo "Success"
echo ""
echo "Creating folder $DATEcode at $USBdrv"
mkdir $USBdrv/$DATEcode
echo "Success"
echo ""
echo "Copying images over"
cp -a $PHOTOdrv/*.CR2 $USBdrv/$DATEcode/
echo "Success"
echo ""
echo "Hashing files in $PHOTOdrv."
md5deep -b -e $PHOTOdrv/*.CR2 > $USBdrv/$MD5
echo "Success"
echo ""
echo "Hashing file from $USBdrv against hashes from $PHOTOdrv using hash file $MD5."
echo "If any files show up here they have become corrupt from the transfer from $PHOTOdrv"
md5deep -r -x $USBdrv/$MD5 $USBdrv/$DATEcode/*.CR2
echo "Done"
echo ""
echo "Copying photos to Remote Server"
scp -r "$USBdrv/$DATEcode/" $SSHuser@$SSHhost:$SSHdirectory
echo "Done"
echo ""
echo "Copying photos to Remote Server"
scp -r "$USBdrv/$MD5" $SSHuser@$SSHhost:$SSHdirectory/$DATEcode/
echo "Done"
echo ""
echo "Checking file integrity on remote server ($SSHhost in $SSHdirectory)"
ssh $SSHuser@$SSHhost 'md5deep -r -x $SSHdirectory/$DATEcode/$MD5 $SSHdirectory/$DATEcode/'
echo "Done"
echo ""
echo ""
echo "Tada!!"

Keep in mind this is a really basic, stupid, non-intuitive, poorly written script; which is also why is doesn’t contain a delete/remove command. The script assumes the cards are emptied after each one of these transfers (but does NOT delete the data itself.) It also prompts you for the password for the remote server three times so the password isn’t stored as plain text in the script.

40TB NAS for under $3,000.

As a previous post stated, I have ran out of space on my 5.4TB NAS. New parts were ordered through Newegg.com and were in transit as this post was first being drafted. A 6TB rented external hard drive was used to backup all data from current NAS so that the old parts may be cannibalized for the revised NAS . The new NAS has approximately 12.4TB of usable space after the RAIDZ3 protection and will be easily expandable to 24.8TB (using another set of 10x 2TB drives in another RAIDZ3 configuration) of space without need for temporary storage or even a system shutdown due to the hot-swappable bays on this new case. This setup will be able to withstand three drive failures of the ten without any data loss. All this is due to the ZFS file system. So lets take a closer look at this versatile NAS setup.

 

The Hardware:

This go around I decided I need to be able to expand the system in the future by having available bays and ports. Throughput of drives doesn’t double every 18 months like other sectors of technology, so buying SATA III hardware is likely a safe bet as it won’t be phased out too quickly. Also as prices continually fall for 2TB drives it makes sense to only create an array that meets current demands while not overbuilding too much as the price for the same drives or equivalents is likely to be significantly cheaper in just a few months time.

I decided early on to reuse my motherboard, processor, power supply, and current 2TB drives for cost reasons.

As for the new hardware I started off by evaluating computer chassises. First I looked into consumer towers, the most 5 ¼” bays I could find in a single tower had 9 bays, it was fairly cheap. Alright, then I started looking at hard drive cages and soon realized, due to the price, that buying a purpose built chassis would be more cost effective than piecing together something that could hold quiet a few HDs. Most of the quality drive cages were in the excess of $90 for a 3x 5¼” bays to a 5x 3½” drive system; if you do decide to go that route I suggest going with Icy Dock as their products are well built and pretty. The chassis I ended up purchasing has 20 hot swappable bays on 5 backplanes using SATA ports; in hindsight I should of gone with backplanes with SAS 8087 connectors as it would of been more efficient for cooling and cable routing.

The next step was getting 20 SATA drives on a motherboard with only 6 SATA ports. My first plan of attack was to use a simple SATA port multiplier. Well after have many issues with them, including IO errors while running some benchmark test on the preliminary testing setup I decided to RMA the cards. The next idea was to use a RocketRAID 2760 card, 24 ports on a PCI Express 2.0 16x interface; it would of been wicked fast if it would of passed the volumes to the OS. So what I ended up settling on was a 16 internal port HBA card by LSI, using this card will require me to use the 4 remaining SATA ports on the motherboard to be able to fully utilize all the bays in my case; not a problem ZFS can handle that as you can even mismatch IDE, PATA, and SATA drives on the same pool without issue.

For the additional hard drives I simply went to NewEgg.com, did a filtered search for SATA hard drives that were 2TB in capacity. Currently 2TB hard drives have the lowest Cost to Capacity ratio, 3TB HDs seem to go for double the cost and the 1TB drives are about $20 cheaper than 2TB drives. The drive I settled on was $59.99 after a $10 rebate and yes they are Deathstars; two died within a few days with I/O errors and eventually not even showing up in the BIOS. NewEgg’s RMA policy sucks; not only do you have to pay for return shipping on the dead devices shipped to you, NewEgg doesn’t ship out the replacement product quickly (2+ days after receiving the broken hard drives.) And forget about cross shipped RMAing.

As for the RAM I went all out, using 16GB to max out the motherboard’s capacity. ZFS is a RAM intensive system and can have a performance loss if not using at least the recommended 2GB+. With large writes ZFS fills the RAM with the data then dumps it to the disks in bulk. ZFS also has an option to attach a SSD to be used as a caching device for writes, that technology is called ZIL.

For the OS drives I went with a couple of 32GB SSDs in a mirrored configuration. Originally I was going to utilized an old CF to IDE card reader but for $10 more I got the 2x 32GB SSDs which had double the capacity as the 16GB CF cards I was looking at with the SDDs having way faster read and write speeds.

 

The operating system – Solaris 11 Express:

Before building my first NAS I had never heard of ZFS. I deducted from the name it was a filesystem but it was foreign. UFS, btrfs, and XFS were all new in my book as well and I didn’t really read any praises for any particular one. As I was set on using FreeNAS at the time I went with UFS, UFS was the recommended filesystem to use due to other filesystems having the possibility of data loss due in part to incompatibility and partly due to a lack of development to patch bugs. In FreeNAS 0.7 there is a point made to make sure the user knows that ZFS is experimental and should only be used in a testing environment. I looked a little into ZFS, saw it had a few nice features but due to the heed of warning from FreeNAS’s lack of support I dropped the idea. There was even a warning message in the dmesg on boot warning of ZFS’s experimental state on FreeNAS 0.7.2.

This time around I decided a WebGUI was not needed. The only time I used it was during the initial setup and occasional status checks so moving on from FreeNAS was easier letting go of that feature. I’m convinced ZFS is the way to go and the best supported OS for ZFS is Solaris 11 from Sun/Oracle. I started running a copy of Solaris from VirtualBox, the virtual machine was setup with several virtual hard drives so I could really test ZFS and try to find fault. Besides being very slow from only allocating 2GB of RAM to the virtual machine everything worked and I decided I could live with Solaris even though it will be a slight learning curve.

 

ZFS – a closer look:

As I mentioned I had never heard of ZFS before my first NAS build and would of used ZFS had FreeNAS 0.7.2 supported it stably. The amount of useful features that ZFS has is remarkable. The key features are as follows:

  • It supports pooled storage which is similar to sticking in more RAM in a PC than the current song and dance required to setup a harddrive which still has the volumes separated by partition required by other filesystems.
  • There is built in data check-summing which most filesystem don’t have. This feature alerts of quiet data corruption(1)(2)(3) and repairs it in cases of mirrored or RAIDZ configurations.
  • Encryption is built in, completely transparent, and from what I can tell doesn’t effect performance too much if using a processor with AES hardware instruction set. Encryption keys can be passwords, fobs, or hex hashes.
  • Within ZFS itself there is the option for improved software RAID 0, 1, 5, 6, 6 + one more parity drive, and nested RAIDs of any of the former options. RAID protects from data loss due to a hard drive crashing which is inevitable.
  • Limitless snapshots which is the same technology that TimeMachine uses on OSX.
  • Transparent compression
  • Data Deduplication. This looks for blocks that have the same pattern and uses a single block for the pattern and references said block for all other occurrences.
  • Background online data scrubbing and resilvering. Which are the repair and rebuild processes.
  • Pool importing. ZFS will recognize drives that were part of a previous pool even if on completely different motherboard, controller, port, order on said controller, and/or whatever else you can throw at it. ZFS just imports the pool and all is well. ZFS will even warn you if you are about to overwrite a drive with part of a pool on it. This was jaw dropping for me when I saw this.
  • Copy-on-write. Files are copied to blank blocks then commits all changes at once.
  • Quick RAID rebuilds due to only requiring the blocks of data with actual used data rather than recreating the entire disk including the empty data. This can be critical if the lower RAIDZ or RAIDZ2 options are used and other drives are starting to fail(1).
  • Scalability. 128 bit filesystem. Which means it can have pools as large as 256,000,000,000,000,000 ZettaBytes (1ZettaByte = 1 billion TB).
  • Pipelined I/O. This manages IO for maximum performance and data safety.
  • Variable block size. Great for optimizing the block size for the size of files.
  • Open sourced. If the licensing was less strick you’d see it on far more OSes, including Linux.

 

Expandability:

As stated before one of the nice things about ZFS is it’s pooled storage. Which means when the need arrises to expand to NAS v3, all that will be needed is additional harddrives as the rest of the current hardware setup has additional bays and ports available. I’ll be able to add another RAIDZ3 array of any sized drives in a concatenated (still one massive pool of data) type setup without erasing any of the data; which will be necessary because I think 10TB drives aren’t in the near future (4+years for consumer level).

 

Cost:

Below is a screenshot of a NewEgg.com cart with all my hardware plus 10 more drives. If you price hunt or utilize NewEgg’s price alert you can lower the cost to about $2500 as of this writing. The LSI HBA card has a huge markup on NewEgg, I ordered from WiredZone.com which had a $100 difference from NewEgg’s price:

 

Other thoughts:

It’s hard to dispute that ZFS is anything short of awesome. Given all of it’s advantages and features you might wonder why it’s not used on a lot more systems and OSes, including whatever you are currently running. Well, it does have one large disadvantage which is ZFS’s opened source CDDL license renders it difficult to implement for the masses on Linux or any other OS for that matter. If you are willing to run Solaris on your NAS box you’ll have one wicked filesystem. There aren’t major differences between Solaris and Linux. The backend on Solaris is slightly different from what you might be used to on Linux but it still uses Gnome for the frontend and a package manager so for the semi-power users converting over won’t be that much of a learning curve.

Another possible solution if you are running some high end hardware or even at the research point and willing to drop the cash is going with a virtualized setup and running VMware’s EXSi virtualizing OS. Basically you could run a virtualized Solaris OS with the hardware controller passed straight to the virtualized OS, ZFS could handle all the storage aspects and you could run a daemon (iSCSI, SFTP, AFP, CIFS, SAMBA or others) to pass that data to a more familiar OS for some more comfortable file serving and handling.

Displaying SATA hard drive temperatures on Solaris 11 Express.

Coming from FreeNAS I used to pull up the Disk Info page on the WebGUI to conveniently check the hard drive temperatures. I did this mostly out of curiosity at the time, as the drives had a 120mm fan per three drives using a Lian Li HDD cage. I’ve since switched to a 20 bay server case and swapped the tornado fans that came with the case for some silent fans which don’t pull as much air but I also can’t hear them across my 850 Sq. Ft. condo. Since I live in Santa Fe I largely don’t run my air conditioner because the daily highs are rarely above 93° F and condo seems to keep cool from the chilly nights. As such monitoring the temperatures has become a little more important.

As far as I can tell Solaris doesn’t have an easy way to monitor/display HD temperatures. So I wrote a little script to parse the drive names from the zpool status output.


#!/bin/bash

POOL=”ZFS”

LIST=`zpool status $POOL | grep -o “c[0-9].*d0″`

foo ()
{
for DRIVE_NAME in $*
do
TEMPerature_C=`pfexec /usr/local/sbin/smartctl -d sat -a /dev/rdsk/$DRIVE_NAME | grep “Temperature_Celsius” | grep -o “\ \ \ \ [0-9][0-9]” | grep -o “[0-9][0-9]“`
TEMP_f=$(echo “scale=2;((9/5) * $TEMPerature_C) + 32″ |bc)

echo “/dev/rdsk/$DRIVE_NAME is $TEMPerature_C degrees celsius or $TEMP_f degrees fahrenheit”

done
}

foo $LIST

Perhaps not the most efficient use of grep with so many nests but it does display to readable output:

/dev/rdsk/c0t5000C5002A8B94A2d0 is 37 degrees celsius or 98.60 degrees fahrenheit
/dev/rdsk/c0t5000C50029D920C0d0 is 41 degrees celsius or 105.80 degrees fahrenheit
/dev/rdsk/c0t5000C50029DA7CD1d0 is 41 degrees celsius or 105.80 degrees fahrenheit
/dev/rdsk/c0t5000C50029EE83C4d0 is 38 degrees celsius or 100.40 degrees fahrenheit
/dev/rdsk/c0t5000CCA221DB6854d0 is 42 degrees celsius or 107.60 degrees fahrenheit
/dev/rdsk/c0t5000CCA369D14DEBd0 is 37 degrees celsius or 98.60 degrees fahrenheit
/dev/rdsk/c0t5000CCA369D14E86d0 is 36 degrees celsius or 96.80 degrees fahrenheit
/dev/rdsk/c0t5000C50037F61096d0 is 37 degrees celsius or 98.60 degrees fahrenheit
/dev/rdsk/c0t5000C5002F1F88F3d0 is 34 degrees celsius or 93.20 degrees fahrenheit
/dev/rdsk/c0t5000CCA369D15061d0 is 38 degrees celsius or 100.40 degrees fahrenheit

This does require compiling smartmontools from source.