Monday, July 21, 2008

ZFS NAS for Home : A Mini Howto based on OpenSolaris 2008.5

One of my FreeNAS mirror disks packed up 2 weeks ago. It served me well for over 3 years. If you are looking to back up your home media and laptop files, boot from a small thumb drive and get reasonable support from the community, this FreeBSD based product is a good bet.

I decided to attempt an OpenSolaris NAS instead, motivated by Simons' Blogs here - main reason : ZFS. ZFS is the mother of all file systems, now open sourced by Sun. A dated summary here will give you a good idea.

Steps involved:

1. Check the Hardware compatibility list and ensure you have one of the motherboards listed there. This is going to save you huge amount of time, since if the board is not listed there, chances are high that you will have driver problems. You will also need 2 Large Disks (SATA/IDE) for storing data and one small 20 GB is more than enough or a GB Flash Drive for the operating system.

2. Download OpenSolaris from here. My version is 2005.8

3. Make a CD with the ISO. Need a tool for Windows? Go here

4. Boot with the LiveCD and follow the install process - this is going to take a while. Install on to a small disk or the flash drive. Here is the official install help.

5. Login as the user you created (not root), once the system boots up into the great looking desktop. Btw You will have to su, to become root every time. This is Role Based Access Control RBAC.

6. Do a sanity check on the drivers being ok ; go to
System->Administration-> Device Driver Utility Should show Driver Problems : 0

7. At this point I needed to assign a fixed ip address for my box; that needs the following two commands to be executed. (Disable Network Auto Magic nwam and enable the physical network adapter). Get a console from Applications->System Tools -> Terminal.

$ su

Password:
#disable svc:/network/physical:nwam
#enable svc:/network/physical:default

8. Now you can go to System->Administration->Network->Ethernet connection->Properties and fill in the static IP address you want to assign to your NAS.

9. I did not have internet access now. To get to the net edit /etc/resolv.conf (as su) and add the following 2 lines (or whatever is your preferred name servers) and save the file. The following name servers are opendns servers, they are great to keep your home network and kids safe.
nameserver 208.67.222.222
nameserver 208.67.220.220

You also need to edit /etc/nsswitch.conf, look for the line
hosts: files
and change it to
hosts: dns files

Once these two changes are done, you should be able to get on to the internet.

10. Go now to System->Administration->Package Manager and Search for smb and check all except the SUNWsmba and click the Install/Update button. This is to install CIFS so that Windows users can see the shares. Do not be tempted to Update All (See this link on why not), since this will kill your system - which did happen to me. More on recovering from that later.

11. Follow Simon's thread here from the Configuration section on, to set up the zpool and zfs shares. I did not edit the auto_master and auto_smb that the blog suggested.

12. Populate your data now. Once finished, take a snapshot of your stable environment by getting a console and issuing the command

#beadm create NAS-dd-mm-yy


This will ensure that you can always boot into an environement that you know is functional.

13. Just to make sure that you dont get into trouble with the Image Packaging System IPS, follow the instructions here to update package manager.

14. If you did break the system like I did with an Update All from the Package Manager GUI and rebooted to find their system dead; here is what can be done. (Recovery using Opensolaris Live CD)

a. Boot again from live CD and get into console. The username/password is jack/jack ; become su (password is opensolaris)

b. Issue following commands

#zpool import -f rpool

#zfs list

c, See if you can recognize any of the system snapshots that is a good enough starting point to recover. I had none, so I rolled back to the original install time snapshot by:

#zfs rollback -f rpool/ROOT/opensolaris@install


If you had a snapshot opensolaris@NAS-21-July-08 as recommended here, you can roll back to that and all will be well.

d. However if you rolled back to install time stuff, you need to redo steps 7, 8, 9 and 10; edit /etc/pam.conf and add the line as in Simons blog, create new users who were created post install and do a passwd again for all users to renew the passwords and reboot the system.

e. Once it comes up again, import the zpool that is the data pool (tank in my case);

#zpool import -f tank


f. and join the workgroup

#smbadm join -w WORKGROUP


You should be up and running now: Do not forget to execute the beadm given in step 12, so that you have a nice place to roll back from and not just the live CD install time snapshot!

No comments: