Swearing at your File System

Recently I was working on a Solaris box remotely and lost my temper.  I can’t remember why, and it’s not relevant.  What is relevant is that in my rage, I swore at my file system.  I know it was childish, and I definitely know better, but in the heat of the moment, I made a mistake.  Unfortunately, I was in the process of naming a file in Vi, and I ended up with a file name full of punctuation marks.  Realising my mistake, I immediately tried to remove the offending file.  To my surprise, while I could see the file by issuing a simple ls, I couldn’t remove it. Bash issued a syntax error, interpreting the punctuation marks as special symbols. I now realise that I could have very easily escaped the offending characters, but I wasn’t that smart at the time, so what follows was my rather roundabout solution. While these steps may not be useful in this scenario, parts of the solution may prove useful for others.

Remembering back to my systems architecture classes at university, I started thinking of how I might get to my file via its inode rather than its file name.  A quick search of the man page for ls revealed that I could list all of the inodes in a directory. Success; I now had another method of accessing the file.  Checking the man page for mv and rm, I couldn’t see any way to rename or delete the file via its inode.  Having recently done some work with find I knew how versatile and useful a tool it is.  Checking its man page, I was pleased to find that I could search for files by their inode number.  Combining this with the exec flag, I was able to rename my file to something sensible.  The code snippet below gives an example of how this all fits together.

ajmccluskey@solaris $ ls
^()$@  Documents
ajmccluskey@solaris $ ls -i
264015 ^()$@    262180 Documents
ajmccluskey@solaris $ find . -inum 264015 -exec mv {} test \;
ajmccluskey@solaris $ ls
test  Documents

So there you have it. My lacking knowledge of Bash will never get in the way of me solving a problem; albeit in a very roundabout manner.

How to Build a 2TB ZFS Fileserver for AUD800

My aspirations to build a Solaris fileserver have finally been realised and I now have 2TB of networked storage sitting beneath my desk as I type this. Now that the server is built and working, I figured it was time to share my experiences with the world.

The Requirements

Put simply, I wanted a fileserver to host all of my music, movies and other files in a central location that was networked with the rest of my house. Not only did I want to store my files, but I wanted around 2TB of actual storage so that it would last me a while, as well as some sort of protection against an inevitable drive failure. Unless you want to run some sort of backup software, which I don’t, then RAID is generally how you protect against drive failures. So RAID it was.

After some research, I decided that a dedicated box with RAID was definitely going to meet my needs the best. I also decided that RAID 1 (a simple mirror) was inefficient as it sacrifices too much drive space. As cheap as storage is these days, I’m still a poor uni student. So, something like RAID 5 is what I wanted. Once this was decided, it was time to look at filesystems. It didn’t take long to see that Sun’s ZFS with raidz was probably the way to go. This made the choice of operating system simple, as ZFS means Solaris unless you want to run your filesystem in userspace. To be honest, I’m not sure how much this would impact performance, but a chance to get acquainted with a new OS was too good to pass up, so Solaris it was.
Continue reading